mirror of
https://invent.kde.org/system/dolphin
synced 2024-10-28 03:21:56 +00:00
Do not crash if QApplication::clipboard()->mimeData() is a null pointer
According to a recent bug report, this can happen on Wayland. The root cause of the problem might be a problem in Qt's Wayland support itself, but this patch at least prevents that Dolphin and other applications which check the clipboard state to determine the text of the paste action crash on startup. BUG: 335053 REVIEW: 118450
This commit is contained in:
parent
de197075a7
commit
7828b057da
|
@ -1031,8 +1031,17 @@ QPair<bool, QString> KonqOperations::pasteInfo(const KUrl& targetUrl)
|
||||||
QClipboard* clipboard = QApplication::clipboard();
|
QClipboard* clipboard = QApplication::clipboard();
|
||||||
const QMimeData* mimeData = clipboard->mimeData();
|
const QMimeData* mimeData = clipboard->mimeData();
|
||||||
|
|
||||||
const bool canPasteData = KIO::canPasteMimeSource(mimeData);
|
bool canPasteData = false;
|
||||||
KUrl::List urls = KUrl::List::fromMimeData(mimeData);
|
KUrl::List urls;
|
||||||
|
|
||||||
|
// mimeData can be 0 according to https://bugs.kde.org/show_bug.cgi?id=335053
|
||||||
|
if (mimeData) {
|
||||||
|
canPasteData = KIO::canPasteMimeSource(mimeData);
|
||||||
|
urls = KUrl::List::fromMimeData(mimeData);
|
||||||
|
} else {
|
||||||
|
kWarning(1203) << "QApplication::clipboard()->mimeData() is 0!";
|
||||||
|
}
|
||||||
|
|
||||||
if (!urls.isEmpty() || canPasteData) {
|
if (!urls.isEmpty() || canPasteData) {
|
||||||
// disable the paste action if no writing is supported
|
// disable the paste action if no writing is supported
|
||||||
KFileItem item(KFileItem::Unknown, KFileItem::Unknown, targetUrl);
|
KFileItem item(KFileItem::Unknown, KFileItem::Unknown, targetUrl);
|
||||||
|
|
Loading…
Reference in a new issue