From c00c4fc9c2be8e248ea16d84bcc809418def45b4 Mon Sep 17 00:00:00 2001 From: Eike Ziller Date: Mon, 16 Apr 2018 14:21:01 +0200 Subject: [PATCH] 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 --- src/plugins/qmldesigner/shortcutmanager.cpp | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/src/plugins/qmldesigner/shortcutmanager.cpp b/src/plugins/qmldesigner/shortcutmanager.cpp index 066bb350e9f..fe5b640210f 100644 --- a/src/plugins/qmldesigner/shortcutmanager.cpp +++ b/src/plugins/qmldesigner/shortcutmanager.cpp @@ -59,12 +59,6 @@ #include #include -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)