Commit c7eeee65 authored by Kai Uwe Broulik's avatar Kai Uwe Broulik 🍇
Browse files

[Icon Item] Check URL validity and scheme

Creating a KFileItemList with a KFileItem with a URL that doesn't have a scheme triggers an assert in KFileItemListProperties.
It doesn't really make sense to have anyway.

Differential Revision: https://phabricator.kde.org/D26516
parent 025387c9
......@@ -369,28 +369,30 @@ QList<QAction *> IconApplet::contextualActions()
if (desktopFile.hasLinkType()) {
const QUrl linkUrl = QUrl(desktopFile.readUrl());
if (m_openWithActions.isEmpty()) {
if (!m_fileItemActions) {
m_fileItemActions = new KFileItemActions(this);
}
KFileItemListProperties itemProperties(KFileItemList({KFileItem(linkUrl)}));
m_fileItemActions->setItemListProperties(itemProperties);
if (linkUrl.isValid() && !linkUrl.scheme().isEmpty()) {
if (m_openWithActions.isEmpty()) {
if (!m_fileItemActions) {
m_fileItemActions = new KFileItemActions(this);
}
KFileItemListProperties itemProperties(KFileItemList({KFileItem(linkUrl)}));
m_fileItemActions->setItemListProperties(itemProperties);
if (!m_openWithMenu) {
m_openWithMenu.reset(new QMenu());
}
m_openWithMenu->clear();
m_fileItemActions->addOpenWithActionsTo(m_openWithMenu.data());
if (!m_openWithMenu) {
m_openWithMenu.reset(new QMenu());
}
m_openWithMenu->clear();
m_fileItemActions->addOpenWithActionsTo(m_openWithMenu.data());
m_openWithActions = m_openWithMenu->actions();
}
m_openWithActions = m_openWithMenu->actions();
}
if (!m_openContainingFolderAction) {
if (KProtocolManager::supportsListing(linkUrl)) {
m_openContainingFolderAction = new QAction(QIcon::fromTheme(QStringLiteral("document-open-folder")), i18n("Open Containing Folder"), this);
connect(m_openContainingFolderAction, &QAction::triggered, this, [ linkUrl] {
KIO::highlightInFileManager({linkUrl});
});
if (!m_openContainingFolderAction) {
if (KProtocolManager::supportsListing(linkUrl)) {
m_openContainingFolderAction = new QAction(QIcon::fromTheme(QStringLiteral("document-open-folder")), i18n("Open Containing Folder"), this);
connect(m_openContainingFolderAction, &QAction::triggered, this, [ linkUrl] {
KIO::highlightInFileManager({linkUrl});
});
}
}
}
}
......
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