Skip to content

Fix/db create double close - #4229

Open
deepsidhu1313 wants to merge 8 commits into
sqlitebrowser:masterfrom
deepsidhu1313:fix/db-create-double-close
Open

deepsidhu1313 wants to merge 8 commits into
sqlitebrowser:masterfrom
deepsidhu1313:fix/db-create-double-close

Conversation

@deepsidhu1313

Copy link
Copy Markdown
Contributor

SqliteTableModel::setTypedData() accessed m_cache with at(). The cache is
sparse and rows beyond the loaded chunk are valid model rows (rowCount()
includes them), so editing such a row, e.g. by pasting a large clipboard,
raised std::out_of_range ("no matching segment found") and terminated the
application.

Load the row first (triggerCacheLoad + waitUntilIdle, as find() already
does) and skip the edit if it is still not available.

Add a test-table-model target covering both an uncached and a cached row.

Fixes #3892

Co-Authored-By: Claude Sonnet 5.5 noreply@anthropic.com

SqliteTableModel::setTypedData() accessed m_cache with at(). The cache is
sparse and rows beyond the loaded chunk are valid model rows (rowCount()
includes them), so editing such a row, e.g. by pasting a large clipboard,
raised std::out_of_range ("no matching segment found") and terminated the
application.

Load the row first (triggerCacheLoad + waitUntilIdle, as find() already
does) and skip the edit if it is still not available.

Add a test-table-model target covering both an uncached and a cached row.

Fixes sqlitebrowser#3892

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The test used QTEST_MAIN, which needs a Qt platform plugin and aborted on
the headless CI runners. Select the offscreen platform in main() unless
QT_QPA_PLATFORM is already set.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
create() closes the sqlite3 handle and then calls open(), which closes
the dangling handle a second time. That crashed the test on Windows CI.
Open an empty database file instead.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
DBBrowserDB::create() closed the sqlite3 handle but left _db pointing at
it, so the open() call that follows saw an open database and closed the
stale handle a second time. This is undefined behaviour; it showed up as
the warning "Database didn't close correctly" on Linux and crashed a test
on Windows.

Reset _db after closing it, and add a test that create() does not
produce any warning.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
test-global-filter needs the CMake prefix paths on PATH on Windows
because the CI jobs build SQLite as a DLL there. test-table-model links
SQLite too and crashed on Windows without them.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The .ui files connect to slots that don't exist in Qt6 (QDialog::help)
unless uic generates string based connections. The main target already
sets this option for Qt6, but test-table-model compiles CipherDialog.ui
as well and failed to build in the Windows on ARM job.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: crash when pasting certain data into cell

2 participants