mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-10-20 05:14:16 +02:00
Fix a closed project staying in the element collection panel
A project opened before the element collection panel's first load is queued until the load starts; one opened during a load goes into the model being loaded. ElementsCollectionWidget::removeProject() only removed the project from the model already shown, so a project closed in either window stayed in the collection, and the next reload read the freed project (crash in XmlElementCollection::root()). removeProject() now also takes the project out of the queue and out of the model being loaded. That model waits for its loading threads, which read the project, and drops the project's items from the list applied when the loading ends. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -526,6 +526,13 @@ void ElementsCollectionModel::removeProject(QETProject *project)
|
||||
if (!m_project_list.contains(project))
|
||||
return;
|
||||
|
||||
//A loading may be setting up this project's items on worker
|
||||
//threads: let it end, and keep the items about to be deleted out of
|
||||
//the list applied when it is finished.
|
||||
m_future.waitForFinished();
|
||||
for (ElementCollectionItem *eci : projectItems(project))
|
||||
m_items_list_to_setUp.removeOne(eci);
|
||||
|
||||
int row = m_project_list.indexOf(project);
|
||||
if (removeRows(row, 1, QModelIndex())) {
|
||||
m_project_list.removeOne(project);
|
||||
|
||||
Reference in New Issue
Block a user