mirror of
https://github.com/sqlitebrowser/sqlitebrowser.git
synced 2026-01-20 02:50:46 -06:00
Fix possible crashes when using context menu in Browse Data tab
Deactivate all menu actions in the context menu in the Browse Data tab if no database file is opened. Without a database the read-only actions were still enabled and would lead to a crash. See issue #1228.
This commit is contained in:
@@ -106,10 +106,16 @@ ExtendedTableWidget::ExtendedTableWidget(QWidget* parent) :
|
||||
connect(this, &QTableView::customContextMenuRequested,
|
||||
[=](const QPoint& pos)
|
||||
{
|
||||
// Deactivate context menu options if there is no model set
|
||||
bool enabled = model();
|
||||
filterAction->setEnabled(enabled);
|
||||
copyAction->setEnabled(enabled);
|
||||
copyWithHeadersAction->setEnabled(enabled);
|
||||
|
||||
// Try to find out whether the current view is editable and (de)activate menu options according to that
|
||||
bool editable = editTriggers() != QAbstractItemView::NoEditTriggers;
|
||||
nullAction->setEnabled(editable);
|
||||
pasteAction->setEnabled(editable);
|
||||
nullAction->setEnabled(enabled && editable);
|
||||
pasteAction->setEnabled(enabled && editable);
|
||||
|
||||
// Show menu
|
||||
m_contextMenu->popup(viewport()->mapToGlobal(pos));
|
||||
|
||||
Reference in New Issue
Block a user