From 836606feb9d442636cb0e4a70fa7b2ddabf04d14 Mon Sep 17 00:00:00 2001 From: Christian Kandeler Date: Thu, 26 Feb 2015 10:39:00 +0100 Subject: [PATCH] Analyzer: Fix combobox behavior. The code assumed that the items in the combobox correspond to the ones in the m_actions array. This is no longer true, as we now group the combox contents. Change-Id: I97500970fbcda9ac8b5e530dd487f388cc13a5e2 Reviewed-by: hjk --- src/plugins/analyzerbase/analyzermanager.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/plugins/analyzerbase/analyzermanager.cpp b/src/plugins/analyzerbase/analyzermanager.cpp index 60adec51e6b..7d73a347e83 100644 --- a/src/plugins/analyzerbase/analyzermanager.cpp +++ b/src/plugins/analyzerbase/analyzermanager.cpp @@ -52,6 +52,7 @@ #include #include +#include #include #include #include @@ -455,7 +456,12 @@ void AnalyzerManagerPrivate::selectSavedTool() void AnalyzerManagerPrivate::selectToolboxAction(int index) { - selectAction(m_actions[index]); + AnalyzerAction * const action = Utils::findOrDefault(m_actions, + [this, index](const AnalyzerAction *action) { + return action->text() == m_toolBox->itemText(index); + }); + QTC_ASSERT(action, return); + selectAction(action); } void AnalyzerManagerPrivate::selectAction(AnalyzerAction *action) @@ -463,8 +469,8 @@ void AnalyzerManagerPrivate::selectAction(AnalyzerAction *action) if (m_currentAction == action) return; - const int actionIndex = m_actions.indexOf(action); - QTC_ASSERT(actionIndex >= 0, return); + const int toolboxIndex = m_toolBox->findText(action->text()); + QTC_ASSERT(toolboxIndex >= 0, return); // Clean up old tool. if (m_currentAction) { @@ -492,7 +498,7 @@ void AnalyzerManagerPrivate::selectAction(AnalyzerAction *action) QTC_CHECK(m_controlsWidgetFromTool.contains(toolId)); m_controlsStackWidget->setCurrentWidget(m_controlsWidgetFromTool.value(toolId)); - m_toolBox->setCurrentIndex(actionIndex); + m_toolBox->setCurrentIndex(toolboxIndex); updateRunActions(); }