Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:LarisaT:Programs
sqlitebrowser
367665e7f51073dbfa3c9c0c6700c0d761af3389.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 367665e7f51073dbfa3c9c0c6700c0d761af3389.patch of Package sqlitebrowser
From 367665e7f51073dbfa3c9c0c6700c0d761af3389 Mon Sep 17 00:00:00 2001 From: Martin Kleusberg <github@mkleusberg.de> Date: Fri, 22 Jan 2021 14:31:49 +0100 Subject: [PATCH] Fix issues with executing SQL statements This fixes two issues when executing SQL statements: - When reusing a model object the row count was not reset. This meant that when the second query returned less rows than the first a bunch of "loading..." cells were still visible. - The workaround for making sure the plot dock was only updated when the data was ready (instead of just the row count), now that the data is ready before the row count, would stop the worker thread from ever finishing. See issue #2535. --- src/MainWindow.cpp | 28 ++++++++++++---------------- src/sqlitetablemodel.cpp | 5 +++++ 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp index 593c783e2..4b0820a53 100644 --- a/src/MainWindow.cpp +++ b/src/MainWindow.cpp @@ -1286,23 +1286,19 @@ void MainWindow::executeQuery() // Wait until the initial loading of data (= first chunk and row count) has been performed auto conn = std::make_shared<QMetaObject::Connection>(); - *conn = connect(model, &SqliteTableModel::finishedFetch, [=](int fetched_row_begin, int fetched_row_end) { - // Avoid attaching the plot when the signal is notifying the row count, since the - // data wouldn't be available yet. - if(fetched_row_begin != fetched_row_end && fetched_row_begin != model->rowCount()) { - // Disconnect this connection right now. This avoids calling this slot multiple times - disconnect(*conn); - - attachPlot(sqlWidget->getTableResult(), sqlWidget->getModel()); - } else { - connect(sqlWidget->getTableResult()->selectionModel(), &QItemSelectionModel::currentChanged, this, &MainWindow::dataTableSelectionChanged); - connect(sqlWidget->getTableResult(), &QTableView::doubleClicked, this, &MainWindow::doubleClickTable); + *conn = connect(model, &SqliteTableModel::finishedFetch, this, [=](int, int) { + // Disconnect this connection right now. This avoids calling this slot another time for the row count + disconnect(*conn); - auto time_end = std::chrono::high_resolution_clock::now(); - auto time_in_ms = std::chrono::duration_cast<std::chrono::milliseconds>(time_end-time_start); - query_logger(true, tr("%1 rows returned in %2ms").arg(model->rowCount()).arg(time_in_ms.count()+time_in_ms_so_far), from_position, to_position); - execute_sql_worker->startNextStatement(); - } + attachPlot(sqlWidget->getTableResult(), sqlWidget->getModel()); + + connect(sqlWidget->getTableResult()->selectionModel(), &QItemSelectionModel::currentChanged, this, &MainWindow::dataTableSelectionChanged); + connect(sqlWidget->getTableResult(), &QTableView::doubleClicked, this, &MainWindow::doubleClickTable); + + auto time_end = std::chrono::high_resolution_clock::now(); + auto time_in_ms = std::chrono::duration_cast<std::chrono::milliseconds>(time_end-time_start); + query_logger(true, tr("%1 rows returned in %2ms").arg(model->rowCount()).arg(time_in_ms.count()+time_in_ms_so_far), from_position, to_position); + execute_sql_worker->startNextStatement(); }); }, Qt::QueuedConnection); connect(execute_sql_worker.get(), &RunSql::confirmSaveBeforePragmaOrVacuum, sqlWidget, [this]() { diff --git a/src/sqlitetablemodel.cpp b/src/sqlitetablemodel.cpp index b51330466..f23f53ff8 100644 --- a/src/sqlitetablemodel.cpp +++ b/src/sqlitetablemodel.cpp @@ -107,6 +107,12 @@ void SqliteTableModel::handleRowCountComplete (int life_id, int num_rows) void SqliteTableModel::reset() { beginResetModel(); + + // We first clear the cache here in order to unset the cache initialised flag, + // then call the clearCache function to deal with the clean up + // TODO This whole resetting and clearing should be refactored + m_cache.clear(); + clearCache(); m_sQuery.clear(); m_query.clear();
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor