Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix crash when removing drag and drop form elements
If both a container and a item within that container are selected
and then the "remove" button is pressed, QGIS will crash

Avoid the crash by removing items one-by-one, so that we don't try
to delete a child item which was already deleted by its parent.
  • Loading branch information
nyalldawson committed May 9, 2023
1 parent 3174221 commit 0b0f52b
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/gui/vector/qgsattributesformproperties.cpp
Expand Up @@ -696,7 +696,17 @@ void QgsAttributesFormProperties::addTabOrGroupButton()

void QgsAttributesFormProperties::removeTabOrGroupButton()
{
qDeleteAll( mFormLayoutTree->selectedItems() );
// deleting an item may delete any number of nested child items -- so we delete
// them one at a time and then see if there's any selection left
while ( true )
{
const QList<QTreeWidgetItem *> items = mFormLayoutTree->selectedItems();
if ( items.empty() )
break;

delete items.at( 0 );
}

}


Expand Down

0 comments on commit 0b0f52b

Please sign in to comment.