Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit 547d10aa authored by Frank Reininghaus's avatar Frank Reininghaus

Fix crash when clicking an action in context menu for a removed device

Devices can be added and removed while the context menu is open.
Sfter an action has clicked that needs to access a device, we therefore
have to check if its position in the model has changed, and more
importantly, if it is still there at all in order to prevent a crash.

BUG: 315298
FIXED-IN: 4.10.1
REVIEW: 108989
parent e053ecdc
......@@ -262,23 +262,34 @@ void PlacesPanel::slotItemContextMenuRequested(int index, const QPointF& pos)
emptyTrash();
} else if (action == addAction) {
addEntry();
} else if (action == editAction) {
editEntry(index);
} else if (action == removeAction) {
m_model->removeItem(index);
} else if (action == hideAction) {
item->setHidden(hideAction->isChecked());
} else if (action == openInNewTabAction) {
const KUrl url = m_model->item(index)->dataValue("url").value<KUrl>();
emit placeMiddleClicked(url);
} else if (action == showAllAction) {
m_model->setHiddenItemsShown(showAllAction->isChecked());
} else if (action == teardownAction) {
m_model->requestTeardown(index);
} else if (action == ejectAction) {
m_model->requestEject(index);
} else if (iconSizeActionMap.contains(action)) {
m_view->setIconSize(iconSizeActionMap.value(action));
} else {
// The index might have changed if devices were added/removed while
// the context menu was open.
index = m_model->index(item);
if (index < 0) {
// The item is not in the model any more, probably because it was an
// external device that has been removed while the context menu was open.
return;
}
if (action == editAction) {
editEntry(index);
} else if (action == removeAction) {
m_model->removeItem(index);
} else if (action == hideAction) {
item->setHidden(hideAction->isChecked());
} else if (action == openInNewTabAction) {
const KUrl url = m_model->item(index)->dataValue("url").value<KUrl>();
emit placeMiddleClicked(url);
} else if (action == teardownAction) {
m_model->requestTeardown(index);
} else if (action == ejectAction) {
m_model->requestEject(index);
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment