Disconnect portgroup before removing from list

Disconnecting _during_ remove sometimes causes crash because disconnect
triggers the logs window alert which **can** lead to repainting of
other windows which access port groups which have not been synced after
the removal of one or more portgroups.

Also emit endRemoveRows after each portgroup so that begin/end signals
match.
This commit is contained in:
Srivats P 2022-02-10 20:34:10 +05:30
parent 041f500e65
commit 2ce7f0c7a0

View File

@ -110,8 +110,10 @@ void PortGroupList::addPortGroup(PortGroup &portGroup)
void PortGroupList::removePortGroup(PortGroup &portGroup)
{
mPortGroupListModel.portGroupAboutToBeRemoved(&portGroup);
// Disconnect before removing from list
portGroup.disconnectFromHost();
mPortGroupListModel.portGroupAboutToBeRemoved(&portGroup);
PortGroup* pg = mPortGroups.takeAt(mPortGroups.indexOf(&portGroup));
qDebug("after takeAt()");
mPortGroupListModel.portGroupRemoved();
@ -128,11 +130,12 @@ void PortGroupList::removeAllPortGroups()
do {
PortGroup *pg = mPortGroups.at(0);
pg->disconnectFromHost();
mPortGroupListModel.portGroupAboutToBeRemoved(pg);
mPortGroups.removeFirst();
delete pg;
mPortGroupListModel.portGroupRemoved();
} while (!mPortGroups.isEmpty());
mPortGroupListModel.portGroupRemoved();
mPortGroupListModel.when_portListChanged();
mPortStatsModel.when_portListChanged();