diff --git a/src/plugins/projectexplorer/taskwindow.cpp b/src/plugins/projectexplorer/taskwindow.cpp index 75ba8e63916..6b23ac4e5e7 100644 --- a/src/plugins/projectexplorer/taskwindow.cpp +++ b/src/plugins/projectexplorer/taskwindow.cpp @@ -210,11 +210,18 @@ void TaskView::resizeEvent(QResizeEvent *e) class TaskWindowPrivate { public: + ITaskHandler *handler(const QAction *action) + { + ITaskHandler *handler = m_actionToHandlerMap.value(action, nullptr); + return g_taskHandlers.contains(handler) ? handler : nullptr; + } + Internal::TaskModel *m_model; Internal::TaskFilterModel *m_filter; Internal::TaskView *m_listview; Internal::TaskWindowContext *m_taskWindowContext; QMenu *m_contextMenu; + QMap m_actionToHandlerMap; ITaskHandler *m_defaultHandler = nullptr; QToolButton *m_filterWarningsButton; QToolButton *m_categoriesButton; @@ -318,14 +325,6 @@ TaskWindow::~TaskWindow() delete d; } -static ITaskHandler *handler(QAction *action) -{ - QVariant prop = action->property("ITaskHandler"); - ITaskHandler *handler = qobject_cast(prop.value()); - QTC_CHECK(handler); - return handler; -} - void TaskWindow::delayedInitialization() { static bool alreadyDone = false; @@ -340,7 +339,7 @@ void TaskWindow::delayedInitialization() QAction *action = h->createAction(this); QTC_ASSERT(action, continue); - action->setProperty("ITaskHandler", qVariantFromValue(qobject_cast(h))); + d->m_actionToHandlerMap.insert(action, h); connect(action, &QAction::triggered, this, &TaskWindow::actionTriggered); d->m_actions << action; @@ -395,7 +394,7 @@ void TaskWindow::currentChanged(const QModelIndex &index) { const Task task = index.isValid() ? d->m_filter->task(index) : Task(); foreach (QAction *action, d->m_actions) { - ITaskHandler *h = handler(action); + ITaskHandler *h = d->handler(action); action->setEnabled((task.isNull() || !h) ? false : h->canHandle(task)); } } @@ -511,7 +510,7 @@ void TaskWindow::actionTriggered() auto action = qobject_cast(sender()); if (!action || !action->isEnabled()) return; - ITaskHandler *h = handler(action); + ITaskHandler *h = d->handler(action); if (!h) return;