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 <hjk@theqtcompany.com>
This commit is contained in:
Christian Kandeler
2015-02-26 10:39:00 +01:00
committed by hjk
parent b30e807fac
commit 836606feb9

View File

@@ -52,6 +52,7 @@
#include <projectexplorer/session.h> #include <projectexplorer/session.h>
#include <projectexplorer/target.h> #include <projectexplorer/target.h>
#include <utils/algorithm.h>
#include <utils/fancymainwindow.h> #include <utils/fancymainwindow.h>
#include <utils/styledbar.h> #include <utils/styledbar.h>
#include <utils/qtcassert.h> #include <utils/qtcassert.h>
@@ -455,7 +456,12 @@ void AnalyzerManagerPrivate::selectSavedTool()
void AnalyzerManagerPrivate::selectToolboxAction(int index) 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) void AnalyzerManagerPrivate::selectAction(AnalyzerAction *action)
@@ -463,8 +469,8 @@ void AnalyzerManagerPrivate::selectAction(AnalyzerAction *action)
if (m_currentAction == action) if (m_currentAction == action)
return; return;
const int actionIndex = m_actions.indexOf(action); const int toolboxIndex = m_toolBox->findText(action->text());
QTC_ASSERT(actionIndex >= 0, return); QTC_ASSERT(toolboxIndex >= 0, return);
// Clean up old tool. // Clean up old tool.
if (m_currentAction) { if (m_currentAction) {
@@ -492,7 +498,7 @@ void AnalyzerManagerPrivate::selectAction(AnalyzerAction *action)
QTC_CHECK(m_controlsWidgetFromTool.contains(toolId)); QTC_CHECK(m_controlsWidgetFromTool.contains(toolId));
m_controlsStackWidget->setCurrentWidget(m_controlsWidgetFromTool.value(toolId)); m_controlsStackWidget->setCurrentWidget(m_controlsWidgetFromTool.value(toolId));
m_toolBox->setCurrentIndex(actionIndex); m_toolBox->setCurrentIndex(toolboxIndex);
updateRunActions(); updateRunActions();
} }