Fix crash when exporting SQL files

Exporting SQL files crashed because of the multi-threaded loading of
data which also affects the SQL export. Because the table models were
destructed relatively quickly during the export's progress estimation,
their threads were still running and trying to access invalid data
structures.

See issue #1228.
This commit is contained in:
Martin Kleusberg
2017-11-17 13:36:44 +01:00
parent ccb1fd4ca8
commit 3b511f83c3
2 changed files with 7 additions and 0 deletions

View File

@@ -22,6 +22,12 @@ SqliteTableModel::SqliteTableModel(DBBrowserDB& db, QObject* parent, size_t chun
reset();
}
SqliteTableModel::~SqliteTableModel()
{
m_futureFetch.cancel();
m_futureFetch.waitForFinished();
}
void SqliteTableModel::reset()
{
m_futureFetch.cancel();

View File

@@ -20,6 +20,7 @@ class SqliteTableModel : public QAbstractTableModel
public:
explicit SqliteTableModel(DBBrowserDB& db, QObject *parent = nullptr, size_t chunkSize = 50000, const QString& encoding = QString());
~SqliteTableModel();
void reset();
int rowCount(const QModelIndex &parent = QModelIndex()) const;