[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-core-devel
Subject:    clipboard timeout fix
From:       "Bradley T. Hughes" <bhughes () trolltech ! com>
Date:       2000-09-14 17:47:42
[Download RAW message or body]

this patch fixes the "stalling" problem reported for konqueror
exiting... it's not *just* konqueror either, other applications could do
it as well... 

in the case of konqueror, upon exiting it unloads $library... and
klibloader's destructor tries to convert the clipboard contents to text to
prevent data corruption... only if konqueror doesn't *have* the selection
(X protocol stuff), then it has to request the selection, go into the
local event loop (which has the 5 second timeout) before anything else can
proceed

the solution is to check if we own the selection (more X voodoo) and only
clear it *if* we own it...

please review and tell me when to commit it :)

--
Bradley T. Hughes <bhughes@trolltech.com>
Waldemar Thranes gt. 98B N-0175 Oslo, Norway
Office: +47 21 60 48 92
Mobile: +47 92 01 97 81

["klibloader.diff" (TEXT/PLAIN)]

Index: klibloader.cpp
===================================================================
RCS file: /home/kde/kdelibs/kdecore/klibloader.cpp,v
retrieving revision 1.30
diff -u -b -r1.30 klibloader.cpp
--- klibloader.cpp	2000/08/08 13:48:03	1.30
+++ klibloader.cpp	2000/09/14 17:43:58
@@ -17,12 +17,17 @@
 */
 #include <config.h>
 #include <qclipboard.h>
+#include <qwidgetlist.h>
+#include <qwidget.h>
 #include "kapp.h"
 #include "klibloader.h"
 #include "kglobal.h"
 #include "kstddirs.h"
 #include "kdebug.h"
 
+#include <X11/Xlib.h>
+#include <X11/Xatom.h>
+
 template class QAsciiDict<KLibrary>;
 
 #include <qtimer.h>
@@ -167,7 +172,26 @@
 
     // Well.. let's do something more subtle... convert the clipboard context
     // to text. That should be safe as it only uses objects defined by Qt.
+    QWidgetList *widgetlist = QApplication::topLevelWidgets();
+    QWidget *co = widgetlist->first();
+    while (co) {
+	qDebug("=============== examining %s", co->name());
+	if (qstrcmp(co->name(), "internal clipboard owner") == 0) {
+	    qDebug("=============== found clipboard ownder");
+
+	    Window w = XGetSelectionOwner(co->x11Display(), XA_PRIMARY);
+	    if (w == co->winId()) {
+		qDebug("=========== we own selection, clearing");
     kapp->clipboard()->setText(kapp->clipboard()->text());
+		qDebug("=========== clipboard contents %s",
+		       kapp->clipboard()->text().latin1());
+	    }	
+	    
+	    break;
+	}
+	
+	co = widgetlist->next();
+    }
 
     if (!d->do_not_unload && getenv("KDE_NOUNLOAD")==NULL) {
         if (getenv("KDE_DLCLOSE") != NULL)


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic