TableSetBase release Table when going to delete [skip ci]

This commit is contained in:
Hamed Masafi 2019-03-07 19:45:58 +03:30
parent ac2fa1a4ae
commit f555515e5e
3 changed files with 10 additions and 1 deletions

View File

@ -144,7 +144,9 @@ void Table::setParentTableSet(TableSetBase *parent)
{
Q_D(Table);
d->parentTableSet = parent;
d->parentTableSet->add(this);
if (parent)
d->parentTableSet->add(this);
}
TableSetBase *Table::childTableSet(const QString &name) const

View File

@ -37,6 +37,12 @@ TableSetBase::TableSetBase(Table *parent) : QObject(parent),
parent->add(this);
}
TableSetBase::~TableSetBase()
{
foreach (Table *t, _tables)
t->setParentTableSet(nullptr);
}
int TableSetBase::save(Database *db, bool cleanUp)
{
int rowsAffected = 0;

View File

@ -37,6 +37,7 @@ class TableSetBase : public QObject
public:
explicit TableSetBase(Database *parent);
explicit TableSetBase(Table *parent);
virtual ~TableSetBase();
virtual int save(Database *db, bool cleanUp = false);
void clearChilds();