From f72d4bda509c0a0c4147a75a08026917993668db Mon Sep 17 00:00:00 2001 From: BigBahss Date: Fri, 16 Apr 2021 08:22:05 -0400 Subject: [PATCH] Fix duplicate event script label completions --- include/project.h | 2 +- src/core/map.cpp | 2 +- src/project.cpp | 6 ++++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/include/project.h b/include/project.h index b8620fc4..470a0d12 100644 --- a/include/project.h +++ b/include/project.h @@ -180,7 +180,7 @@ public: QString getScriptDefaultString(bool usePoryScript, QString mapName) const; QString getMapScriptsFilePath(const QString &mapName) const; QStringList getEventScriptsFilePaths() const; - QCompleter *getEventScriptLabelCompleter(const QStringList &additionalCompletions) const; + QCompleter *getEventScriptLabelCompleter(QStringList additionalCompletions) const; bool loadMapBorder(Map *map); diff --git a/src/core/map.cpp b/src/core/map.cpp index 3d839ecc..202d797b 100644 --- a/src/core/map.cpp +++ b/src/core/map.cpp @@ -427,8 +427,8 @@ QStringList Map::eventScriptLabels(const QString &event_group_type) const { scriptLabels << event->get("script_label"); } + scriptLabels.removeAll(""); scriptLabels.removeDuplicates(); - scriptLabels.removeAll(QString()); if (scriptLabels.contains("0x0")) scriptLabels.move(scriptLabels.indexOf("0x0"), scriptLabels.count() - 1); if (scriptLabels.contains("NULL")) diff --git a/src/project.cpp b/src/project.cpp index 87590616..6cdb7008 100644 --- a/src/project.cpp +++ b/src/project.cpp @@ -2386,8 +2386,10 @@ QStringList Project::getEventScriptsFilePaths() const { return filePaths; } -QCompleter *Project::getEventScriptLabelCompleter(const QStringList &additionalCompletions) const { - eventScriptLabelModel->setStringList(eventScriptLabels + additionalCompletions); +QCompleter *Project::getEventScriptLabelCompleter(QStringList additionalCompletions) const { + additionalCompletions += eventScriptLabels; + additionalCompletions.removeDuplicates(); + eventScriptLabelModel->setStringList(additionalCompletions); return eventScriptLabelCompleter; }