[containmentinterface] Workaround self-destructing menu

Basically, if the "determining mimetype" QMenu is shown, and then afterwards we
re-use this menu to show the possible actions, we clear it and then it just destroys
itself on exec() returning a null QAction, rather than waiting for the user to make
a selection. It doesn't matter when, as soon as the menu becomes empty, be it because
we call clear() or we remove the action before populating it. Hence, we just populate
the menu and then remove the first action which will be the "determining mimetype" placeholder.

CHANGELOG: Fix dropping files onto the desktop/panel not offering a selection of actions to take

REVIEW: 125939
This commit is contained in:
Kai Uwe Broulik 2015-11-07 13:12:32 +01:00
parent db7f198a19
commit af32d8b42f

View File

@ -610,7 +610,6 @@ void ContainmentInterface::mimeTypeRetrieved(KIO::Job *job, const QString &mimet
}
if (!appletList.isEmpty() || !wallpaperList.isEmpty()) {
choices->clear();
QHash<QAction *, QString> actionsToApplets;
choices->addSection(i18n("Widgets"));
foreach (const KPluginInfo &info, appletList) {
@ -648,6 +647,11 @@ void ContainmentInterface::mimeTypeRetrieved(KIO::Job *job, const QString &mimet
}
}
// HACK If the QMenu becomes empty at any point after the "determining mimetype"
// popup was shown, it self-destructs, does not matter if we call clear() or remove
// the action manually, hence we remove the aforementioned item after we populated the menu
choices->removeAction(choices->actions().first());
QAction *choice = choices->exec();
if (choice) {
// Put the job on hold so it can be recycled to fetch the actual content,