From c71f4daa84b62e0a9b30576ac1330d5cb3820d84 Mon Sep 17 00:00:00 2001 From: vng Date: Sat, 26 May 2012 17:08:08 +0300 Subject: [PATCH] [desktop] Fix crash on shutdown. Create and destroy UpdateDialog on demand. --- qt/mainwindow.cpp | 8 ++------ qt/mainwindow.hpp | 7 ++----- qt/update_dialog.cpp | 8 ++------ qt/update_dialog.hpp | 2 +- 4 files changed, 7 insertions(+), 18 deletions(-) diff --git a/qt/mainwindow.cpp b/qt/mainwindow.cpp index 7436746ce0..1aa9369c94 100644 --- a/qt/mainwindow.cpp +++ b/qt/mainwindow.cpp @@ -37,9 +37,6 @@ namespace qt { MainWindow::MainWindow() -#ifndef NO_DOWNLOADER - : m_updateDialog(0) -#endif // NO_DOWNLOADER { m_pDrawWidget = new DrawWidget(this); m_locationService.reset(CreateDesktopLocationService(*this)); @@ -368,9 +365,8 @@ void MainWindow::OnPreferences() #ifndef NO_DOWNLOADER void MainWindow::ShowUpdateDialog() { - if (!m_updateDialog) - m_updateDialog = new UpdateDialog(this, m_pDrawWidget->GetFramework().Storage()); - m_updateDialog->ShowDialog(); + UpdateDialog dlg(this, m_pDrawWidget->GetFramework().Storage()); + dlg.ShowModal(); } void MainWindow::ShowClassifPanel() diff --git a/qt/mainwindow.hpp b/qt/mainwindow.hpp index 38f9511b15..9ff7d65048 100644 --- a/qt/mainwindow.hpp +++ b/qt/mainwindow.hpp @@ -6,6 +6,7 @@ #include + class QDockWidget; namespace search { class Result; } @@ -13,7 +14,6 @@ namespace search { class Result; } namespace qt { class DrawWidget; - class UpdateDialog; class MainWindow : public QMainWindow, location::LocationObserver { @@ -23,10 +23,6 @@ namespace qt QDockWidget * m_Docks[3]; -#ifndef NO_DOWNLOADER - UpdateDialog * m_updateDialog; -#endif // NO_DOWNLOADER - scoped_ptr m_locationService; Q_OBJECT @@ -66,6 +62,7 @@ namespace qt void ShowClassifPanel(); void ShowGuidePanel(); #endif // NO_DOWNLOADER + void OnPreferences(); void OnAbout(); void OnMyPosition(); diff --git a/qt/update_dialog.cpp b/qt/update_dialog.cpp index cf9c06ed39..722648bd1b 100644 --- a/qt/update_dialog.cpp +++ b/qt/update_dialog.cpp @@ -42,9 +42,6 @@ enum namespace qt { -/////////////////////////////////////////////////////////////////////////////// -// Helpers -/////////////////////////////////////////////////////////////////////////////// /// adds custom sorting for "Size" column class QTreeWidgetItemWithCustomSorting : public QTreeWidgetItem { @@ -54,7 +51,7 @@ namespace qt return data(KColumnIndexSize, Qt::UserRole).toULongLong() < other.data(KColumnIndexSize, Qt::UserRole).toULongLong(); } }; -//////////////////////////////////////////////////////////////////////////////// + UpdateDialog::UpdateDialog(QWidget * parent, Storage & storage) : QDialog(parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint), @@ -335,7 +332,7 @@ namespace qt } } - void UpdateDialog::ShowDialog() + void UpdateDialog::ShowModal() { // if called for first time if (!m_tree->topLevelItemCount()) @@ -343,5 +340,4 @@ namespace qt exec(); } - } diff --git a/qt/update_dialog.hpp b/qt/update_dialog.hpp index 12a061b1f1..6d788ee028 100644 --- a/qt/update_dialog.hpp +++ b/qt/update_dialog.hpp @@ -26,7 +26,7 @@ namespace qt pair const & progress); //@} - void ShowDialog(); + void ShowModal(); private slots: void OnItemClick(QTreeWidgetItem * item, int column);