Skip to content

Commit 1fa0eb9

Browse files
committed
Revert all workarounds for #3706 and apply a fix
Let's hope :)
1 parent db25f4e commit 1fa0eb9

File tree

2 files changed

+15
-25
lines changed

2 files changed

+15
-25
lines changed

src/MainWindow.cpp

Lines changed: 9 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -79,35 +79,11 @@ MainWindow::MainWindow(QWidget* parent)
7979

8080
activateFields(false);
8181
updateRecentFileActions();
82-
QApplication::processEvents();
83-
84-
auto update_structure = [this] {
85-
const auto docks = allTableBrowserDocks();
86-
std::vector<sqlb::ObjectIdentifier> old_tables;
87-
old_tables.reserve(docks.size());
88-
for(const auto &dock: docks) {
89-
old_tables.push_back(dock->tableBrowser()->currentlyBrowsedTableName());
90-
}
91-
92-
dbStructureModel->reloadData();
93-
// Process all waiting events before we call populateStructure,
94-
// giving the Application a chance to attach all Widgets.
95-
// See #3706
96-
QApplication::processEvents();
97-
populateStructure(old_tables);
98-
};
9982

10083
if (!Settings::getValue("tmp", "fileWillBeOpenedFromCLI").toBool() &&
10184
Settings::getValue("General", "autoLoadLastDBFileAtStartup").toBool()) {
10285
recentFileActs[0]->trigger();
103-
update_structure();
104-
if (ui->mainTab->currentWidget() == ui->browser)
105-
refreshTableBrowsers();
10686
}
107-
108-
connect(&db, &DBBrowserDB::structureUpdated, this, [update_structure = std::move(update_structure)]() {
109-
update_structure();
110-
});
11187
}
11288

11389
MainWindow::~MainWindow()
@@ -160,6 +136,15 @@ void MainWindow::init()
160136

161137
// Set up DB structure tab
162138
dbStructureModel = new DbStructureModel(db, this);
139+
connect(&db, &DBBrowserDB::structureUpdated, this, [this]() {
140+
std::vector<sqlb::ObjectIdentifier> old_tables;
141+
for(const auto& d : allTableBrowserDocks())
142+
old_tables.push_back(d->tableBrowser()->currentlyBrowsedTableName());
143+
144+
dbStructureModel->reloadData();
145+
146+
populateStructure(old_tables);
147+
});
163148
ui->dbTreeWidget->setModel(dbStructureModel);
164149
ui->dbTreeWidget->setColumnWidth(DbStructureModel::ColumnName, 300);
165150
ui->dbTreeWidget->setColumnHidden(DbStructureModel::ColumnObjectType, true);

src/SqlUiLexer.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,12 @@ void SqlUiLexer::setupAutoCompletion()
195195
listFunctions.append(keyword.first);
196196
}
197197

198-
autocompleteApi->prepare();
198+
// Push the QsciAPIs::prepare method call to the
199+
// execution queue, callers should receive
200+
// callbacks in order.
201+
QMetaObject::invokeMethod(this, [this] {
202+
autocompleteApi->prepare();
203+
}, Qt::QueuedConnection);
199204
}
200205

201206
void SqlUiLexer::setTableNames(const QualifiedTablesMap& tables)

0 commit comments

Comments
 (0)