mirror of
https://invent.kde.org/system/dolphin
synced 2024-08-22 01:40:02 +00:00
Do not crash if QApplication::clipboard()->mimeData() is a null pointer
This removes the remaining unchecked accesses to the clipboard mime
data after commit 7828b057da
. According
to a bug report, it can be a null pointer on Wayland.
BUG: 335053
REVIEW: 118649
This commit is contained in:
parent
3b119c4ff9
commit
9dc1513f8b
|
@ -429,10 +429,9 @@ QAction* DolphinContextMenu::createPasteAction()
|
||||||
QAction* action = 0;
|
QAction* action = 0;
|
||||||
const bool isDir = !m_fileInfo.isNull() && m_fileInfo.isDir();
|
const bool isDir = !m_fileInfo.isNull() && m_fileInfo.isDir();
|
||||||
if (isDir && (m_selectedItems.count() == 1)) {
|
if (isDir && (m_selectedItems.count() == 1)) {
|
||||||
|
const QPair<bool, QString> pasteInfo = KonqOperations::pasteInfo(m_fileInfo.url());
|
||||||
action = new QAction(KIcon("edit-paste"), i18nc("@action:inmenu", "Paste Into Folder"), this);
|
action = new QAction(KIcon("edit-paste"), i18nc("@action:inmenu", "Paste Into Folder"), this);
|
||||||
const QMimeData* mimeData = QApplication::clipboard()->mimeData();
|
action->setEnabled(pasteInfo.first);
|
||||||
const KUrl::List pasteData = KUrl::List::fromMimeData(mimeData);
|
|
||||||
action->setEnabled(!pasteData.isEmpty() && selectedItemsProperties().supportsWriting());
|
|
||||||
connect(action, SIGNAL(triggered()), m_mainWindow, SLOT(pasteIntoFolder()));
|
connect(action, SIGNAL(triggered()), m_mainWindow, SLOT(pasteIntoFolder()));
|
||||||
} else {
|
} else {
|
||||||
action = m_mainWindow->actionCollection()->action(KStandardAction::name(KStandardAction::Paste));
|
action = m_mainWindow->actionCollection()->action(KStandardAction::name(KStandardAction::Paste));
|
||||||
|
|
|
@ -55,6 +55,14 @@ KFileItemClipboard::~KFileItemClipboard()
|
||||||
void KFileItemClipboard::updateCutItems()
|
void KFileItemClipboard::updateCutItems()
|
||||||
{
|
{
|
||||||
const QMimeData* mimeData = QApplication::clipboard()->mimeData();
|
const QMimeData* mimeData = QApplication::clipboard()->mimeData();
|
||||||
|
|
||||||
|
// mimeData can be 0 according to https://bugs.kde.org/show_bug.cgi?id=335053
|
||||||
|
if (!mimeData) {
|
||||||
|
m_cutItems.clear();
|
||||||
|
emit cutItemsChanged();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const QByteArray data = mimeData->data("application/x-kde-cutselection");
|
const QByteArray data = mimeData->data("application/x-kde-cutselection");
|
||||||
const bool isCutSelection = (!data.isEmpty() && data.at(0) == QLatin1Char('1'));
|
const bool isCutSelection = (!data.isEmpty() && data.at(0) == QLatin1Char('1'));
|
||||||
if (isCutSelection) {
|
if (isCutSelection) {
|
||||||
|
|
|
@ -62,11 +62,10 @@ void TreeViewContextMenu::open()
|
||||||
QAction* copyAction = new QAction(KIcon("edit-copy"), i18nc("@action:inmenu", "Copy"), this);
|
QAction* copyAction = new QAction(KIcon("edit-copy"), i18nc("@action:inmenu", "Copy"), this);
|
||||||
connect(copyAction, SIGNAL(triggered()), this, SLOT(copy()));
|
connect(copyAction, SIGNAL(triggered()), this, SLOT(copy()));
|
||||||
|
|
||||||
QAction* pasteAction = new QAction(KIcon("edit-paste"), i18nc("@action:inmenu", "Paste"), this);
|
const QPair<bool, QString> pasteInfo = KonqOperations::pasteInfo(m_fileItem.url());
|
||||||
const QMimeData* mimeData = QApplication::clipboard()->mimeData();
|
QAction* pasteAction = new QAction(KIcon("edit-paste"), pasteInfo.second, this);
|
||||||
const KUrl::List pasteData = KUrl::List::fromMimeData(mimeData);
|
|
||||||
connect(pasteAction, SIGNAL(triggered()), this, SLOT(paste()));
|
connect(pasteAction, SIGNAL(triggered()), this, SLOT(paste()));
|
||||||
pasteAction->setEnabled(!pasteData.isEmpty() && capabilities.supportsWriting());
|
pasteAction->setEnabled(pasteInfo.first);
|
||||||
|
|
||||||
popup->addAction(cutAction);
|
popup->addAction(cutAction);
|
||||||
popup->addAction(copyAction);
|
popup->addAction(copyAction);
|
||||||
|
@ -172,17 +171,7 @@ void TreeViewContextMenu::copy()
|
||||||
|
|
||||||
void TreeViewContextMenu::paste()
|
void TreeViewContextMenu::paste()
|
||||||
{
|
{
|
||||||
QClipboard* clipboard = QApplication::clipboard();
|
KonqOperations::doPaste(m_parent, m_fileItem.url());
|
||||||
const QMimeData* mimeData = clipboard->mimeData();
|
|
||||||
|
|
||||||
const KUrl::List source = KUrl::List::fromMimeData(mimeData);
|
|
||||||
const KUrl& dest = m_fileItem.url();
|
|
||||||
if (KonqMimeData::decodeIsCutSelection(mimeData)) {
|
|
||||||
KonqOperations::copy(m_parent, KonqOperations::MOVE, source, dest);
|
|
||||||
clipboard->clear();
|
|
||||||
} else {
|
|
||||||
KonqOperations::copy(m_parent, KonqOperations::COPY, source, dest);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TreeViewContextMenu::rename()
|
void TreeViewContextMenu::rename()
|
||||||
|
|
Loading…
Reference in a new issue