Skip to content

Commit

Permalink
Fixed issue where dialog windows appeared behind the main window that…
Browse files Browse the repository at this point in the history
… made the program appear to freeze or crash.
  • Loading branch information
albar965 committed Oct 12, 2024
1 parent 7b5fa7a commit ee6fb0f
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 50 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.txt
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,8 @@ A big thank you to all who reported bugs and issues!
set, even if no other instance was found.
* From 3.0.10.rc1 to 3.0.11: Fixed wrong error message when reading flight route descriptions from
the command line.
* From 3.0.10.rc1 to 3.0.11: Fixed issue where dialog windows appeared behind the main window that
made the program appear to freeze or crash.

### User Manual

Expand Down
1 change: 0 additions & 1 deletion src/common/dirtool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ void DirTool::run(bool manual, bool& created)
box.setMessage(message);
box.setIcon(QMessageBox::Question);
box.setHelpUrl(lnm::helpOnlineInstallDirUrl, lnm::helpLanguageOnline());
box.setDefaultButton(QDialogButtonBox::No);

if(box.exec() == QDialogButtonBox::Yes)
{
Expand Down
97 changes: 48 additions & 49 deletions src/gui/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3432,12 +3432,6 @@ void MainWindow::mainWindowShown()
{
qDebug() << Q_FUNC_INFO << "enter";

// This shows a warning dialog if failing - start it later within the event loop to avoid a freeze
QTimer::singleShot(0, this, &NavApp::showElevationProviderErrors);

// Show a warning if map theme folders do not exist
QTimer::singleShot(0, this, std::bind(&MapThemeHandler::validateMapThemeDirectories, this));

// Need to set the font again to pass it on to all menus since these are opened later
qDebug() << Q_FUNC_INFO << "QApplication::font()" << QApplication::font();
QApplication::setFont(QApplication::font());
Expand All @@ -3456,47 +3450,13 @@ void MainWindow::mainWindowShown()

mapWidget->showSavedPosOnStartup();

// Show a warning if SSL was not intiaized properly. Can happen if the redist packages are not installed.
if(!QSslSocket::supportsSsl())
dialog->showWarnMsgBox(lnm::ACTIONS_SHOW_SSL_FAILED, tr("<p>Error initializing SSL subsystem.</p>"
"<p>The program will not be able to use encrypted network connections<br/>"
"(i.e. HTTPS) that are needed to check for updates or<br/>"
"to load online maps.</p>"),
tr("Do not &show this dialog again."));

NavApp::logDatabaseMeta();

// If enabled connect to simulator without showing dialog
NavApp::getConnectClient()->tryConnectOnStartup();

// Start weather downloads
weatherUpdateTimeout();

// Update the weather every 15 seconds if connected
weatherUpdateTimer.setInterval(Settings::instance().getAndStoreValue(lnm::OPTIONS_WEATHER_UPDATE_RATE_SIM, 15000).toInt());
weatherUpdateTimer.start();

optionsDialog->checkOfficialOnlineUrls();

// Start regular download of online network files
NavApp::getOnlinedataController()->startProcessing();

// Start webserver
if(ui->actionRunWebserver->isChecked())
{
NavApp::getWebController()->startServer();
updateMapKeys(); // Update API keys and theme dir in web map widget
}
webserverStatusChanged(NavApp::isWebControllerRunning());

renderStatusUpdateLabel(Marble::Complete, true /* forceUpdate */);

// Do delayed dock window formatting and fullscreen state after widget layout is done
// Do delayed dock window formatting and fullscreen state after widget layout is done ================================
QTimer::singleShot(100, this, &MainWindow::mainWindowShownDelayed);

if(ui->actionRouteDownloadTracks->isChecked())
QTimer::singleShot(1000, NavApp::getTrackController(), &TrackController::startDownloadStartup);

// Log screen information ==============
const QList<QScreen *> screens = QGuiApplication::screens();
for(QScreen *screen : screens)
Expand All @@ -3506,8 +3466,6 @@ void MainWindow::mainWindowShown()
<< "geo" << screen->geometry() << "available geo" << screen->availableGeometry()
<< "available virtual geo" << screen->availableVirtualGeometry();

mapThemeHandler->showThemeLoadingErrors();

qDebug() << Q_FUNC_INFO << "leave";
}

Expand Down Expand Up @@ -3565,9 +3523,7 @@ void MainWindow::mainWindowShownDelayed()
// Raise all floating docks and focus map widget
raiseFloatingWindows();

if(migrate::getOptionsVersion().isValid() &&
migrate::getOptionsVersion() <= atools::util::Version("2.6.14") &&
atools::util::Version(QApplication::applicationVersion()) == atools::util::Version("2.6.15"))
if(migrate::getOptionsVersion().isValid() && migrate::getOptionsVersion() <= atools::util::Version("3.0.9"))
{
qDebug() << Q_FUNC_INFO << "Fixing status bar visibility";
ui->statusBar->setVisible(true);
Expand All @@ -3586,6 +3542,51 @@ void MainWindow::mainWindowShownDelayed()
// Map widget draws gray rectangle until main window is visible
mapWidget->update();

// ========================================================================================
// Initialize all late after reopening main window =======================================
NavApp::getConnectClient()->tryConnectOnStartup();

// Start weather downloads
weatherUpdateTimeout();

// Update the weather every 15 seconds if connected
weatherUpdateTimer.setInterval(Settings::instance().getAndStoreValue(lnm::OPTIONS_WEATHER_UPDATE_RATE_SIM, 15000).toInt());
weatherUpdateTimer.start();

optionsDialog->checkOfficialOnlineUrls();

// Start regular download of online network files
NavApp::getOnlinedataController()->startProcessing();

// Start webserver ========================================================
if(ui->actionRunWebserver->isChecked())
{
NavApp::getWebController()->startServer();
updateMapKeys(); // Update API keys and theme dir in web map widget
}
webserverStatusChanged(NavApp::isWebControllerRunning());

// Show a warning if SSL was not intiaized properly.
if(!QSslSocket::supportsSsl())
dialog->showWarnMsgBox(lnm::ACTIONS_SHOW_SSL_FAILED, tr("<p>Error initializing SSL subsystem.</p>"
"<p>The program will not be able to use encrypted network connections<br/>"
"(i.e. HTTPS) that are needed to check for updates or<br/>"
"to load online maps.</p>"),
tr("Do not &show this dialog again."));

// Need to open dialogs here since main window might reopen earlier when initializing thus putting dialogs into back
// This shows a warning dialog if failing - start it later within the event loop to avoid a freeze
NavApp::showElevationProviderErrors();

// Show a warning if map theme folders do not exist
MapThemeHandler::validateMapThemeDirectories(this);
mapThemeHandler->showThemeLoadingErrors();

if(ui->actionRouteDownloadTracks->isChecked())
QTimer::singleShot(1000, NavApp::getTrackController(), &TrackController::startDownloadStartup);

warnTrailPoints(0, true /* doNotShowAgain */);

// Check for missing simulators and databases ====================================================
DatabaseManager *databaseManager = NavApp::getDatabaseManager();
if(!databaseManager->hasSimulatorDatabases() && !databaseManager->hasInstalledSimulators())
Expand Down Expand Up @@ -3673,9 +3674,7 @@ void MainWindow::mainWindowShownDelayed()
NavApp::checkForUpdates(OptionData::instance().getUpdateChannels(), false /* manual */, true /* startup */, false /* forceDebug */);

// Update the information display later delayed to avoid long loading times due to weather timeout
QTimer::singleShot(50, infoController, &InfoController::restoreInformation);

QTimer::singleShot(70, this, std::bind(&MainWindow::warnTrailPoints, this, 0, true /* doNotShowAgain */));
QTimer::singleShot(100, infoController, &InfoController::restoreInformation);

#ifdef DEBUG_INFORMATION
qDebug() << "mapDistanceLabel->size()" << mapDistanceLabel->size();
Expand Down

0 comments on commit ee6fb0f

Please sign in to comment.