From 7669a95694c3b51b87be9c5cdb3eef5430d6c376 Mon Sep 17 00:00:00 2001 From: Shane Ringrose Date: Sun, 21 Jun 2026 12:10:22 +1200 Subject: [PATCH] fix(collection): isCustomCollection() false-positive on company path MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The default user-collection path ends in "elements" and the default company-collection path ends in "elements-company". Both FileElementCollectionItem::isCustomCollection() and ElementsLocation::isCustomCollection() used startsWith(customDir), so "…/elements-company/…" matched "…/elements" and returned true. This caused ElementsCollectionModel::addLocation() to insert a newly-saved user-collection element as a child of the company- collection branch in the tree, making it appear in the wrong panel. Fix: require the path to equal the directory root exactly, or to start with the directory root followed by '/'. path == dir || path.startsWith(dir + QLatin1Char('/')) Co-Authored-By: Claude Sonnet 4.6 --- sources/ElementsCollection/elementslocation.cpp | 4 +++- sources/ElementsCollection/fileelementcollectionitem.cpp | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/sources/ElementsCollection/elementslocation.cpp b/sources/ElementsCollection/elementslocation.cpp index c14f244ff..b9b56cad6 100644 --- a/sources/ElementsCollection/elementslocation.cpp +++ b/sources/ElementsCollection/elementslocation.cpp @@ -523,7 +523,9 @@ bool ElementsLocation::isCompanyCollection() const */ bool ElementsLocation::isCustomCollection() const { - return fileSystemPath().startsWith(QETApp::customElementsDirN()); + const QString dir = QETApp::customElementsDirN(); + const QString path = fileSystemPath(); + return path == dir || path.startsWith(dir + QLatin1Char('/')); } /** diff --git a/sources/ElementsCollection/fileelementcollectionitem.cpp b/sources/ElementsCollection/fileelementcollectionitem.cpp index 5f42efec4..18ba33af6 100644 --- a/sources/ElementsCollection/fileelementcollectionitem.cpp +++ b/sources/ElementsCollection/fileelementcollectionitem.cpp @@ -274,7 +274,9 @@ bool FileElementCollectionItem::isCompanyCollection() const */ bool FileElementCollectionItem::isCustomCollection() const { - return fileSystemPath().startsWith(QETApp::customElementsDirN()); + const QString dir = QETApp::customElementsDirN(); + const QString path = fileSystemPath(); + return path == dir || path.startsWith(dir + QLatin1Char('/')); } /**