diff --git a/sources/ElementsCollection/elementscollectionmodel.cpp b/sources/ElementsCollection/elementscollectionmodel.cpp index a32eeb674..95af6a050 100644 --- a/sources/ElementsCollection/elementscollectionmodel.cpp +++ b/sources/ElementsCollection/elementscollectionmodel.cpp @@ -63,6 +63,7 @@ QVariant ElementsCollectionModel::data(const QModelIndex &index, int role) const { if (role == Qt::DecorationRole) { QStandardItem *item = itemFromIndex(index); + if (!item) return QStandardItemModel::data(index, role); if (item->type() == FileElementCollectionItem::Type) static_cast(item)->setUpIcon(); @@ -330,7 +331,6 @@ void ElementsCollectionModel::loadMacrosCollection() void ElementsCollectionModel::addMacrosCollection(bool set_data) { QString macrosPath = QETApp::userMacrosDir(); - qDebug() << "=== MAKRO PFAD CHECK ===" << macrosPath; if (macrosPath.endsWith("/")) { macrosPath.remove(macrosPath.length() - 1, 1); } diff --git a/sources/ElementsCollection/fileelementcollectionitem.cpp b/sources/ElementsCollection/fileelementcollectionitem.cpp index 5e5c7e844..15a6cdb83 100644 --- a/sources/ElementsCollection/fileelementcollectionitem.cpp +++ b/sources/ElementsCollection/fileelementcollectionitem.cpp @@ -430,7 +430,7 @@ void FileElementCollectionItem::setUpData() */ void FileElementCollectionItem::setUpIcon() { - // Must return unconditionally once an icon is set: setIcon() calls + // Must return unconditionally once setUpIcon has run: setIcon() calls // setData(), which emits dataChanged() regardless of whether the new // icon differs from the old one (QIcon has no meaningful equality). // QTreeView responds to dataChanged() by recomputing the row's size @@ -438,13 +438,18 @@ void FileElementCollectionItem::setUpIcon() // guard, any repeated setIcon() here recurses until the stack // overflows. Confirmed by crash report on PR #633. // + // We use a dedicated bool instead of icon().isNull() because + // some items intentionally keep a null icon (e.g. .qetmak), + // which would bypass a null-based guard and still recurse. + // // This item's m_qet_directory_unreadable is already final by the time // this can run at all: ElementsCollectionModel only attaches itself // to the tree view (making data() reachable) from loadingFinished(), // which fires after the QtConcurrent::map over every item -- this one // included -- has completed. So there is no race to work around here. - if (!icon().isNull()) + if (m_icon_initialized) return; + m_icon_initialized = true; if (isCollectionRoot()) { QString macrosPath = QETApp::userMacrosDir(); diff --git a/sources/ElementsCollection/fileelementcollectionitem.h b/sources/ElementsCollection/fileelementcollectionitem.h index 4c9885f79..6cb78aa08 100644 --- a/sources/ElementsCollection/fileelementcollectionitem.h +++ b/sources/ElementsCollection/fileelementcollectionitem.h @@ -69,6 +69,7 @@ class FileElementCollectionItem : public ElementCollectionItem /// rather than acted on in localName(), because setUpData() resets /// the tooltip afterwards and would otherwise discard it. bool m_qet_directory_unreadable = false; + bool m_icon_initialized = false; }; #endif // FILEELEMENTCOLLECTIONITEM2_H