forked from qt-creator/qt-creator
Fix occurrences of the contains/insert anti-pattern
Introduce and make use of Utils::insert() for QSet with a return value that indicates whether insertion actually happened. Change-Id: I655e4bc3553b74fea5ae8956205e4d8070118d63 Reviewed-by: hjk <hjk@qt.io> Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
@@ -13,6 +13,8 @@
|
||||
|
||||
#include <texteditor/texteditorconstants.h>
|
||||
|
||||
#include <utils/algorithm.h>
|
||||
|
||||
#include <QAction>
|
||||
#include <QEvent>
|
||||
|
||||
@@ -55,8 +57,7 @@ bool ActionMacroHandler::executeEvent(const MacroEvent ¯oEvent)
|
||||
|
||||
void ActionMacroHandler::registerCommand(Id id)
|
||||
{
|
||||
if (!m_commandIds.contains(id)) {
|
||||
m_commandIds.insert(id);
|
||||
if (Utils::insert(m_commandIds, id)) {
|
||||
const Command *command = ActionManager::command(id);
|
||||
if (QAction *action = command->action()) {
|
||||
connect(action, &QAction::triggered, this, [this, id, command]() {
|
||||
|
||||
Reference in New Issue
Block a user