Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/desktop.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDaniel Molkentin <danimo@owncloud.com>2013-09-18 16:11:19 +0400
committerDaniel Molkentin <danimo@owncloud.com>2013-09-18 17:42:35 +0400
commit8fdf9cac6bab670b946506076783ba62480ad18b (patch)
tree8fc482af1c2497295cbba023ea32672385c77a77 /src
parent525d12f5a284be20d7b230bd5b22e07c29234a51 (diff)
Try to be more graceful during shutdown
- Do not delete _tray, use deleteLater() via QScropedPointer - force closing any dialoges that might want to write their geometry in aboutToQuit(), before the actual destruction of the sync thread, etc starts. This tries to fix #945
Diffstat (limited to 'src')
-rw-r--r--src/mirall/application.cpp30
-rw-r--r--src/mirall/application.h7
2 files changed, 22 insertions, 15 deletions
diff --git a/src/mirall/application.cpp b/src/mirall/application.cpp
index 1f6436832..21a637342 100644
--- a/src/mirall/application.cpp
+++ b/src/mirall/application.cpp
@@ -179,18 +179,13 @@ Application::Application(int &argc, char **argv) :
connect( ownCloudInfo::instance(), SIGNAL(quotaUpdated(qint64,qint64)),
SLOT(slotRefreshQuotaDisplay(qint64, qint64)));
+ connect (this, SIGNAL(aboutToQuit()), SLOT(slotCleanup()));
+
qDebug() << "Network Location: " << NetworkLocation::currentLocation().encoded();
}
Application::~Application()
{
- if (_settingsDialog) {
- delete _settingsDialog.data();
- }
-
- delete _logBrowser;
- delete _tray; // needed, see ctor
-
qDebug() << "* Mirall shutdown";
}
@@ -229,6 +224,17 @@ void Application::slotCredentialsFetched()
runValidator();
}
+void Application::slotCleanup()
+{
+ // explicitly close windows. This is somewhat of a hack to ensure
+ // that saving the geometries happens ASAP during a OS shutdown
+ if (!_logBrowser.isNull()) _logBrowser->close();
+ if (!_settingsDialog.isNull()) _settingsDialog->close();
+ if (!_progressDialog.isNull()) _progressDialog->close();
+ if (!_folderWizard.isNull()) _folderWizard->close();
+ if (!_tray.isNull()) _tray->deleteLater();
+}
+
void Application::runValidator()
{
_startupFail.clear();
@@ -347,10 +353,10 @@ void Application::setupSystemTray()
{
// Setting a parent heres will crash on X11 since by the time qapp runs
// its childrens dtors, the X11->screen variable queried for is gone -> crash
- _tray = new Systray();
+ _tray.reset(new Systray());
_tray->setIcon( _theme->syncStateIcon( SyncResult::NotYetStarted, true ) );
- connect(_tray,SIGNAL(activated(QSystemTrayIcon::ActivationReason)),
+ connect(_tray.data(), SIGNAL(activated(QSystemTrayIcon::ActivationReason)),
SLOT(slotTrayClicked(QSystemTrayIcon::ActivationReason)));
setupContextMenu();
@@ -428,7 +434,7 @@ void Application::setupContextMenu()
void Application::setupLogBrowser()
{
// might be called from second instance
- if (!_logBrowser) {
+ if (_logBrowser.isNull()) {
// init the log browser.
qInstallMsgHandler( mirallLogCatcher );
_logBrowser = new LogBrowser;
@@ -699,7 +705,7 @@ void Application::slotSettings()
}
_settingsDialog->setGeneralErrors( _startupFail );
- Utility::raiseDialog(_settingsDialog);
+ Utility::raiseDialog(_settingsDialog.data());
}
void Application::slotItemProgressDialog()
@@ -710,7 +716,7 @@ void Application::slotItemProgressDialog()
_progressDialog->setupList();
_progressDialog->show();
}
- Utility::raiseDialog(_progressDialog);
+ Utility::raiseDialog(_progressDialog.data());
}
void Application::slotParseOptions(const QString &opts)
diff --git a/src/mirall/application.h b/src/mirall/application.h
index 035cdcb8e..cd4b90ec9 100644
--- a/src/mirall/application.h
+++ b/src/mirall/application.h
@@ -107,13 +107,14 @@ protected slots:
void slotDisplayIdle();
void slotHelp();
void slotCredentialsFetched();
+ void slotCleanup();
private:
void setHelp();
void raiseDialog( QWidget* );
void rebuildRecentMenus();
void runValidator();
- Systray *_tray;
+ QPointer<Systray> _tray;
QAction *_actionOpenoC;
QAction *_actionSettings;
QAction *_actionQuota;
@@ -124,7 +125,6 @@ private:
QNetworkConfigurationManager *_networkMgr;
- QPointer<FolderWizard> _folderWizard;
SslErrorDialog *_sslErrorDialog;
ConnectionValidator *_conValidator;
@@ -134,7 +134,8 @@ private:
Theme *_theme;
QSignalMapper *_folderOpenActionMapper;
- LogBrowser *_logBrowser;
+ QPointer<FolderWizard> _folderWizard;
+ QPointer<LogBrowser>_logBrowser;
QPointer<SettingsDialog> _settingsDialog;
QPointer<ItemProgressDialog> _progressDialog;