Don't allow query execution when no database is opened

Some time ago we changed the Execute SQL tab to allow open SQL files
even if no database is loaded in order to provide an SQL editor without
needing a database.

If no database file is opened the Execute buttons were greyed out but
the F5/Ctrl+R shortcut would still work, causing an "out of memory"
error. That error doesn't cause any harm but is a bit confusing. So this
commit disables the keyboard shortcuts too.
This commit is contained in:
Martin Kleusberg
2017-08-11 17:19:42 +02:00
parent 1becee77ee
commit 5ae5241b95

View File

@@ -897,6 +897,11 @@ void MainWindow::dataTableSelectionChanged(const QModelIndex& index)
*/
void MainWindow::executeQuery()
{
// Make sure a database is opened. This is necessary because we allow opened SQL editor tabs even if no database is loaded. Hitting F5 or similar
// then might call this function.
if(!db.isOpen())
return;
SqlExecutionArea* sqlWidget = qobject_cast<SqlExecutionArea*>(ui->tabSqlAreas->currentWidget());
// Get SQL code to execute. This depends on the button that's been pressed