diff --git a/src/sqlitetablemodel.cpp b/src/sqlitetablemodel.cpp index 5d247738..37c5a9af 100644 --- a/src/sqlitetablemodel.cpp +++ b/src/sqlitetablemodel.cpp @@ -10,6 +10,7 @@ SqliteTableModel::SqliteTableModel(QObject* parent, DBBrowserDB* db) , m_iSortColumn(0) , m_sSortOrder("ASC") , m_chunkSize(50000) + , m_valid(false) { } @@ -55,11 +56,20 @@ void SqliteTableModel::setQuery(const QString& sQuery) m_rowCount = sCount.toInt(); } } + else + { + qWarning() << "Count query failed: " << sCountQuery; + sqlite3_finalize(stmt); + m_valid = false; + return; + } + } sqlite3_finalize(stmt); // now fetch the first entries clearCache(); fetchData(0, m_chunkSize); + m_valid = true; emit layoutChanged(); } diff --git a/src/sqlitetablemodel.h b/src/sqlitetablemodel.h index 3ccefc99..04a1b516 100644 --- a/src/sqlitetablemodel.h +++ b/src/sqlitetablemodel.h @@ -32,6 +32,8 @@ public: Qt::ItemFlags flags(const QModelIndex& index) const; + bool valid() const { return m_valid; } + typedef QList QByteArrayList; signals: @@ -65,6 +67,8 @@ private: * to that row count. */ size_t m_chunkSize; + + bool m_valid; //! tells if the current query is valid. }; #endif // SQLITETABLEMODEL_H