diff --git a/src/plugins/debugger/debuggeractions.cpp b/src/plugins/debugger/debuggeractions.cpp index f92ad7eed79b95249c4287f7ac53efe1f70b97c5..355eac5130a5db6b7d934ce40f12a426005ed90a 100644 --- a/src/plugins/debugger/debuggeractions.cpp +++ b/src/plugins/debugger/debuggeractions.cpp @@ -172,6 +172,8 @@ void DebuggerAction::writeSettings(QSettings *settings) void DebuggerAction::connectWidget(QWidget *widget, ApplyMode applyMode) { using namespace Core::Utils; + QTC_ASSERT(!m_widget, + qDebug() << "ALREADY CONNECTED: " << widget << m_widget << toString(); return); m_widget = widget; m_applyMode = applyMode; @@ -200,6 +202,12 @@ void DebuggerAction::connectWidget(QWidget *widget, ApplyMode applyMode) } } +void DebuggerAction::disconnectWidget() +{ + QTC_ASSERT(m_widget, + qDebug() << "ALREADY DISCONNECTED: " << m_widget << toString(); return); + m_widget = 0; +} void DebuggerAction::apply(QSettings *s) { using namespace Core::Utils; @@ -209,7 +217,6 @@ void DebuggerAction::apply(QSettings *s) setValue(lineEdit->text()); else if (PathChooser *pathChooser = qobject_cast<PathChooser *>(m_widget)) setValue(pathChooser->path()); - m_widget = 0; if (s) writeSettings(s); } @@ -270,6 +277,31 @@ void DebuggerAction::trigger(const QVariant &data) } +////////////////////////////////////////////////////////////////////////// +// +// DebuggerSettingsGroup +// +////////////////////////////////////////////////////////////////////////// + +void DebuggerSettingsGroup::insert(DebuggerAction *action, QWidget *widget) +{ + m_list.append(action); + action->connectWidget(widget); +} + +void DebuggerSettingsGroup::apply(QSettings *settings) +{ + foreach (DebuggerAction *action, m_list) + action->apply(settings); +} + +void DebuggerSettingsGroup::finish() +{ + foreach (DebuggerAction *action, m_list) + action->disconnectWidget(); +} + + ////////////////////////////////////////////////////////////////////////// // // DebuggerSettings diff --git a/src/plugins/debugger/debuggeractions.h b/src/plugins/debugger/debuggeractions.h index 9423974ba1b4c3d7196b1c544bb8a2bb07764c8e..172969aee230045a803f9b239d5b3f1cb26a9232 100644 --- a/src/plugins/debugger/debuggeractions.h +++ b/src/plugins/debugger/debuggeractions.h @@ -75,6 +75,7 @@ public: Q_SLOT virtual void writeSettings(QSettings *settings); virtual void connectWidget(QWidget *widget, ApplyMode applyMode = DeferedApply); + virtual void disconnectWidget(); Q_SLOT virtual void apply(QSettings *settings); virtual QString textPattern() const; @@ -102,6 +103,21 @@ private: ApplyMode m_applyMode; }; +class DebuggerSettingsGroup +{ +public: + DebuggerSettingsGroup() {} + ~DebuggerSettingsGroup() {} + + void insert(DebuggerAction *action, QWidget *widget); + void apply(QSettings *settings); + void finish(); + +private: + QList<DebuggerAction *> m_list; +}; + + class DebuggerSettings : public QObject { Q_OBJECT diff --git a/src/plugins/debugger/debuggerplugin.cpp b/src/plugins/debugger/debuggerplugin.cpp index 34152a52ca5bff419fb17cb495e78b94f44627f6..86803a34b057785ce11417cabfbfce8e691ad6a8 100644 --- a/src/plugins/debugger/debuggerplugin.cpp +++ b/src/plugins/debugger/debuggerplugin.cpp @@ -251,14 +251,15 @@ public: QString trCategory() const { return tr("Debugger"); } QWidget *createPage(QWidget *parent); - void apply(); - void finish() {} // automatically calls "apply" + void apply() { m_group.apply(ICore::instance()->settings()); } + void finish() { m_group.finish(); } private: friend class DebuggerPlugin; Ui::GdbOptionPage m_ui; DebuggerPlugin *m_plugin; + DebuggerSettingsGroup m_group; }; QWidget *GdbOptionPage::createPage(QWidget *parent) @@ -272,30 +273,28 @@ QWidget *GdbOptionPage::createPage(QWidget *parent) m_ui.terminalChooser->setExpectedKind(Core::Utils::PathChooser::Command); m_ui.terminalChooser->setPromptDialogTitle(tr("Choose Location of Terminal Application")); - theDebuggerAction(GdbLocation) - ->connectWidget(m_ui.gdbLocationChooser); - theDebuggerAction(GdbScriptFile) - ->connectWidget(m_ui.scriptFileChooser); - theDebuggerAction(GdbEnvironment) - ->connectWidget(m_ui.environmentEdit); - theDebuggerAction(TerminalApplication) - ->connectWidget(m_ui.terminalChooser); - - theDebuggerAction(AllPluginBreakpoints) - ->connectWidget(m_ui.radioButtonAllPluginBreakpoints); - theDebuggerAction(SelectedPluginBreakpoints) - ->connectWidget(m_ui.radioButtonSelectedPluginBreakpoints); - theDebuggerAction(NoPluginBreakpoints) - ->connectWidget(m_ui.radioButtonNoPluginBreakpoints); - theDebuggerAction(SelectedPluginBreakpointsPattern) - ->connectWidget(m_ui.lineEditSelectedPluginBreakpointsPattern); - - theDebuggerAction(SkipKnownFrames) - ->connectWidget(m_ui.checkBoxSkipKnownFrames); - theDebuggerAction(UseToolTips) - ->connectWidget(m_ui.checkBoxUseToolTips); - theDebuggerAction(SelectedPluginBreakpointsPattern) - ->connectWidget(m_ui.lineEditSelectedPluginBreakpointsPattern); + m_group.insert(theDebuggerAction(GdbLocation), + m_ui.gdbLocationChooser); + m_group.insert(theDebuggerAction(GdbScriptFile), + m_ui.scriptFileChooser); + m_group.insert(theDebuggerAction(GdbEnvironment), + m_ui.environmentEdit); + m_group.insert(theDebuggerAction(TerminalApplication), + m_ui.terminalChooser); + + m_group.insert(theDebuggerAction(AllPluginBreakpoints), + m_ui.radioButtonAllPluginBreakpoints); + m_group.insert(theDebuggerAction(SelectedPluginBreakpoints), + m_ui.radioButtonSelectedPluginBreakpoints); + m_group.insert(theDebuggerAction(NoPluginBreakpoints), + m_ui.radioButtonNoPluginBreakpoints); + m_group.insert(theDebuggerAction(SelectedPluginBreakpointsPattern), + m_ui.lineEditSelectedPluginBreakpointsPattern); + + m_group.insert(theDebuggerAction(SkipKnownFrames), + m_ui.checkBoxSkipKnownFrames); + m_group.insert(theDebuggerAction(UseToolTips), + m_ui.checkBoxUseToolTips); m_ui.lineEditSelectedPluginBreakpointsPattern-> setEnabled(theDebuggerAction(SelectedPluginBreakpoints)->value().toBool()); @@ -312,25 +311,6 @@ QWidget *GdbOptionPage::createPage(QWidget *parent) return w; } -void GdbOptionPage::apply() -{ - QSettings *s = ICore::instance()->settings(); - - theDebuggerAction(GdbLocation)->apply(s); - theDebuggerAction(GdbScriptFile)->apply(s); - theDebuggerAction(GdbEnvironment)->apply(s); - theDebuggerAction(TerminalApplication)->apply(s); - - theDebuggerAction(AllPluginBreakpoints)->apply(s); - theDebuggerAction(SelectedPluginBreakpoints)->apply(s); - theDebuggerAction(NoPluginBreakpoints)->apply(s); - theDebuggerAction(SelectedPluginBreakpointsPattern)->apply(s); - - theDebuggerAction(SkipKnownFrames)->apply(s); - theDebuggerAction(UseToolTips)->apply(s); - theDebuggerAction(SelectedPluginBreakpointsPattern)->apply(s); -} - } // namespace Internal } // namespace Debugger @@ -358,14 +338,15 @@ public: QString trCategory() const { return tr("Debugger"); } QWidget *createPage(QWidget *parent); - void apply(); - void finish() {} // automatically calls "apply" + void apply() { m_group.apply(ICore::instance()->settings()); } + void finish() { m_group.finish(); } private: friend class DebuggerPlugin; Ui::DumperOptionPage m_ui; DebuggerPlugin *m_plugin; + DebuggerSettingsGroup m_group; }; QWidget *DumperOptionPage::createPage(QWidget *parent) @@ -381,19 +362,19 @@ QWidget *DumperOptionPage::createPage(QWidget *parent) connect(m_ui.radioButtonUsePrebuiltDumpers, SIGNAL(toggled(bool)), m_ui.dumperLocationChooser, SLOT(setEnabled(bool))); - theDebuggerAction(UseQtDumpers) - ->connectWidget(m_ui.radioButtonUseQtDumpers); - theDebuggerAction(UsePrebuiltDumpers) - ->connectWidget(m_ui.radioButtonUsePrebuiltDumpers); - theDebuggerAction(BuildDumpersOnTheFly) - ->connectWidget(m_ui.radioButtonBuildDumpersOnTheFly); - theDebuggerAction(PrebuiltDumpersLocation) - ->connectWidget(m_ui.dumperLocationChooser); + m_group.insert(theDebuggerAction(UseQtDumpers), + m_ui.radioButtonUseQtDumpers); + m_group.insert(theDebuggerAction(UsePrebuiltDumpers), + m_ui.radioButtonUsePrebuiltDumpers); + m_group.insert(theDebuggerAction(BuildDumpersOnTheFly), + m_ui.radioButtonBuildDumpersOnTheFly); + m_group.insert(theDebuggerAction(PrebuiltDumpersLocation), + m_ui.dumperLocationChooser); - theDebuggerAction(UseDumpers) - ->connectWidget(m_ui.checkBoxUseDumpers); - theDebuggerAction(DebugDumpers) - ->connectWidget(m_ui.checkBoxDebugDumpers); + m_group.insert(theDebuggerAction(UseDumpers), + m_ui.checkBoxUseDumpers); + m_group.insert(theDebuggerAction(DebugDumpers), + m_ui.checkBoxDebugDumpers); m_ui.dumperLocationChooser-> setEnabled(theDebuggerAction(UsePrebuiltDumpers)->value().toBool()); @@ -411,18 +392,6 @@ QWidget *DumperOptionPage::createPage(QWidget *parent) return w; } -void DumperOptionPage::apply() -{ - QSettings *s = ICore::instance()->settings(); - - theDebuggerAction(UseDumpers)->apply(s); - theDebuggerAction(UseQtDumpers)->apply(s); - theDebuggerAction(UsePrebuiltDumpers)->apply(s); - theDebuggerAction(BuildDumpersOnTheFly)->apply(s); - theDebuggerAction(PrebuiltDumpersLocation)->apply(s); - theDebuggerAction(DebugDumpers)->apply(s); -} - } // namespace Internal } // namespace Debugger