QmlDesigner: Do not access clipboard if not requested to by user

QClipboard documentation states for X11:

"Lastly, the X11 clipboard is event driven, i.e. the clipboard will not
function properly if the event loop is not running. Similarly, it is
recommended that the contents of the clipboard are stored or retrieved
in direct response to user-input events, e.g. mouse button or key
presses and releases. You should not store or retrieve the clipboard
contents in response to timer or non-user-input events."

So do not request the clipboard data when the QClipboard signals that
the data has changed, because that locks up if the application providing
the data is unresponsive.

Task-number: QTCREATORBUG-20262
Change-Id: Ifd10150e1de62c8153ab2bb93a3e953a36fb243a
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
Eike Ziller
2018-04-16 14:21:01 +02:00
parent e50b3c1412
commit c00c4fc9c2

View File

@@ -59,12 +59,6 @@
#include <QApplication>
#include <QClipboard>
static void updateClipboard(QAction *action)
{
const bool dataInClipboard = !QApplication::clipboard()->text().isEmpty();
action->setEnabled(dataInClipboard);
}
namespace QmlDesigner {
ShortCutManager::ShortCutManager()
@@ -247,6 +241,7 @@ void ShortCutManager::registerActions(const Core::Context &qmlDesignerMainContex
m_deleteAction.setEnabled(itemsSelected && !rootItemIsSelected);
m_cutAction.setEnabled(itemsSelected && !rootItemIsSelected);
m_copyAction.setEnabled(itemsSelected);
m_pasteAction.setEnabled(true);
});
connect(Core::ICore::instance(), &Core::ICore::contextChanged, this, [&designerActionManager, this](const Core::Context &context){
@@ -260,11 +255,6 @@ void ShortCutManager::registerActions(const Core::Context &qmlDesignerMainContex
}
});
updateClipboard(&m_pasteAction);
connect(QApplication::clipboard(), &QClipboard::QClipboard::changed, this, [this]() {
updateClipboard(&m_pasteAction);
});
}
void ShortCutManager::updateActions(Core::IEditor* currentEditor)