@@ -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
11389MainWindow::~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 );
0 commit comments