https://bugs.kde.org/show_bug.cgi?id=446640

--- Comment #6 from olehage...@gmail.com ---
I looked more into this over the weekend. Adding the lame clipboard owner
counter to newClipData() when in wayland and synchronize is set, makes it not
crash at least.  It's not a nice fix, but i don't know how to find what
triggers newClipData() on selection sync.

diff --git a/klipper/klipper.cpp b/klipper/klipper.cpp
index b090a2409..75a40264a 100644
--- a/klipper/klipper.cpp
+++ b/klipper/klipper.cpp
@@ -624,14 +624,31 @@ HistoryItemPtr Klipper::applyClipChanges(const QMimeData
*clipData)
     return item;
 }

+// Protection against too many clipboard data changes. Lyx responds to
clipboard data
+// requests with setting new clipboard data, so if Lyx takes over clipboard,
+// Klipper notices, requests this data, this triggers "new" clipboard contents
+// from Lyx, so Klipper notices again, requests this data, ... you get the
idea.
+const int MAX_CLIPBOARD_CHANGES = 10; // max changes per second
+
 void Klipper::newClipData(QClipboard::Mode mode)
 {
+    qCDebug(KLIPPER_LOG) << "New clip data";
     if (m_locklevel) {
+        qCDebug(KLIPPER_LOG) << "Locked";
         return;
     }

     if (mode == QClipboard::Selection && blockFetchingNewData())
         return;
+    if (!KWindowSystem::isPlatformX11() && m_bSynchronize) {
+        if (m_overflowCounter == 0) {
+            m_overflowClearTimer.start(1000);
+        }
+        if (++m_overflowCounter > MAX_CLIPBOARD_CHANGES){
+            qCDebug(KLIPPER_LOG) << "Overflow";
+            return;
+        }
+    }

     checkClipData(mode == QClipboard::Selection ? true : false);
 }
@@ -643,12 +660,6 @@ void Klipper::slotHistoryChanged()
     }
 }

-// Protection against too many clipboard data changes. Lyx responds to
clipboard data
-// requests with setting new clipboard data, so if Lyx takes over clipboard,
-// Klipper notices, requests this data, this triggers "new" clipboard contents
-// from Lyx, so Klipper notices again, requests this data, ... you get the
idea.
-const int MAX_CLIPBOARD_CHANGES = 10; // max changes per second
-
 bool Klipper::blockFetchingNewData()
 {
 #if HAVE_X11

-- 
You are receiving this mail because:
You are watching all bug changes.

Reply via email to