forked from qt-creator/qt-creator
Core: Fix crash after second showOptionsDialog call
Do not destroy QEventLoop until it's exec() call is over. Instead only call exit() for all loops when the settings dialog is closed. Change-Id: I9598270ee5f4d294ffcad9b45dda4543e15d63f0 Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
@@ -59,13 +59,6 @@
|
||||
static const char pageKeyC[] = "General/LastPreferencePage";
|
||||
const int categoryIconSize = 24;
|
||||
|
||||
namespace std {
|
||||
template<>
|
||||
struct default_delete<QEventLoop> {
|
||||
void operator()(QEventLoop* p) { p->exit(); delete p; } // exit event loop
|
||||
};
|
||||
} // namespace std
|
||||
|
||||
namespace Core {
|
||||
namespace Internal {
|
||||
|
||||
@@ -433,7 +426,7 @@ private:
|
||||
Utils::FancyLineEdit *m_filterLineEdit;
|
||||
QListView *m_categoryList;
|
||||
QLabel *m_headerLabel;
|
||||
std::vector<std::unique_ptr<QEventLoop>> m_eventLoops;
|
||||
std::vector<QEventLoop *> m_eventLoops;
|
||||
bool m_running = false;
|
||||
bool m_applied = false;
|
||||
bool m_finished = false;
|
||||
@@ -731,8 +724,10 @@ void SettingsDialog::done(int val)
|
||||
|
||||
ICore::saveSettings(); // save all settings
|
||||
|
||||
|
||||
m_eventLoops.erase(m_eventLoops.begin(), m_eventLoops.end()); // exit event loops in reverse order of addition
|
||||
// exit event loops in reverse order of addition
|
||||
for (QEventLoop *eventLoop : m_eventLoops)
|
||||
eventLoop->exit();
|
||||
m_eventLoops.clear();
|
||||
|
||||
QDialog::done(val);
|
||||
}
|
||||
@@ -761,8 +756,10 @@ bool SettingsDialog::execDialog()
|
||||
// a break point it will complain about missing helper, and offer the
|
||||
// option to open the settings dialog.
|
||||
// Keep the UI running by creating another event loop.
|
||||
m_eventLoops.emplace(m_eventLoops.begin(), std::make_unique<QEventLoop>());
|
||||
m_eventLoops.front()->exec();
|
||||
QEventLoop eventLoop;
|
||||
m_eventLoops.emplace(m_eventLoops.begin(), &eventLoop);
|
||||
eventLoop.exec();
|
||||
QTC_ASSERT(m_eventLoops.empty(), return m_applied;);
|
||||
}
|
||||
return m_applied;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user