mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-09-29 05:44:14 +02:00
Fix #1117: element icon vanishes from the collection after saving
Saving an element from the element editor calls ElementsCollectionWidget::locationWasSaved(), which runs clearData() on the panel item: the icon is set to a null QIcon. The icon only comes back through FileElementCollectionItem::setUpIcon(), but since the #633 recursion guard that returns for good once m_icon_initialized is set, and nothing ever reset it. The row stayed without an icon until the whole collection was reloaded. #1008 refreshed the picture caches on save, but no one asked them for the new picture, so it could not fix this. Resetting the flag in clearData() lets the next paint rebuild the icon, which then comes from those refreshed caches, so the panel shows the new drawing. The flag is reset after the base clearData(): its setIcon() emits dataChanged(), which re-enters setUpIcon() and must still return early. setUpIcon() sets the flag before its own setIcon(), so the #633 guard is unchanged. The same reset should also bring back a folder's icon after editing its properties (editDirectory() calls clearData() too); read, not tested. Project collection items were never affected: their setUpIcon() guards on icon().isNull(). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -480,6 +480,22 @@ void FileElementCollectionItem::setUpIcon()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@brief FileElementCollectionItem::clearData
|
||||
Reset the data, and let setUpIcon() build the icon again.
|
||||
Without this the guard in setUpIcon() keeps the icon cleared here
|
||||
empty until the whole collection is reloaded, e.g. after an element
|
||||
is saved from the element editor (see locationWasSaved()).
|
||||
*/
|
||||
void FileElementCollectionItem::clearData()
|
||||
{
|
||||
// Reset the flag only after the base class has cleared the icon:
|
||||
// its setIcon() emits dataChanged(), which re-enters setUpIcon(),
|
||||
// and that call must still see the flag set and return early.
|
||||
ElementCollectionItem::clearData();
|
||||
m_icon_initialized = false;
|
||||
}
|
||||
|
||||
/**
|
||||
@brief FileElementCollectionItem::setPathName
|
||||
Set the name of this item in the file system path.
|
||||
|
||||
@@ -55,6 +55,7 @@ class FileElementCollectionItem : public ElementCollectionItem
|
||||
|
||||
void setUpData() override;
|
||||
void setUpIcon() override;
|
||||
void clearData() override;
|
||||
|
||||
private:
|
||||
void setPathName(const QString& path_name,
|
||||
|
||||
Reference in New Issue
Block a user