diff --git a/src/RowLoader.cpp b/src/RowLoader.cpp index b639a4a6..484abc2c 100644 --- a/src/RowLoader.cpp +++ b/src/RowLoader.cpp @@ -233,11 +233,11 @@ void RowLoader::process (Task & t) const bool first_chunk = !cache_data.initialised(); if(first_chunk) { - size_t num_columns = static_cast(sqlite3_column_count(stmt)); - for(size_t i=0;i(i))); - data_types.push_back(sqlite3_column_type(stmt, static_cast(i))); + headers.push_back(sqlite3_column_name(stmt, i)); + data_types.push_back(sqlite3_column_type(stmt, i)); } } @@ -271,8 +271,6 @@ void RowLoader::process (Task & t) // If there is no need to query the row count this means the number of rows we just got is the total row count. if(first_chunk) { - cache_data.setInitialised(); - if(row == t.row_end) triggerRowCountDetermination(t.token); else diff --git a/src/sqlitetablemodel.cpp b/src/sqlitetablemodel.cpp index ce7befe0..f87c12d3 100644 --- a/src/sqlitetablemodel.cpp +++ b/src/sqlitetablemodel.cpp @@ -67,17 +67,19 @@ void SqliteTableModel::handleFinishedFetch (int life_id, unsigned int fetched_ro Q_ASSERT(fetched_row_end >= fetched_row_begin); - // Tell the query object about the column names. We also use this property to determine if the number of columns changed for some - // reason and if so, we tell the view to update the table layout. - if(m_query.columnNames().size() != m_headers.size()) + // Tell the query object about the column names + m_query.setColumNames(m_headers); + + // If the cache has been uninitialised so far we set it to initialised now and + // tell the view to update the table layout. + if(!m_cache.initialised()) { + m_cache.setInitialised(); emit layoutChanged(); emit columnsChanged(); } - m_query.setColumNames(m_headers); auto old_row_count = m_currentRowCount; - auto new_row_count = std::max(old_row_count, fetched_row_begin); new_row_count = std::max(new_row_count, fetched_row_end); Q_ASSERT(new_row_count >= old_row_count);