summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorLuboš Luňák <l.lunak@suse.cz>2011-01-26 17:05:29 +0100
committerLuboš Luňák <l.lunak@suse.cz>2011-01-26 17:06:41 +0100
commit63fa8b60fef2e2d72c16a70246c5b8e4a702d863 (patch)
treea9acb79e9a4bb5e32336a64473d2a8a45b7c7329 /vcl
parentfaa253ee441f9be75e27980595a4b567e52cb9e0 (diff)
proper Qt event loop integration also when Glib is not used
Diffstat (limited to 'vcl')
-rw-r--r--vcl/unx/kde4/KDEXLib.cxx37
-rw-r--r--vcl/unx/kde4/KDEXLib.hxx2
2 files changed, 36 insertions, 3 deletions
diff --git a/vcl/unx/kde4/KDEXLib.cxx b/vcl/unx/kde4/KDEXLib.cxx
index 5c7d2a7cf58a..77a667ad34d4 100644
--- a/vcl/unx/kde4/KDEXLib.cxx
+++ b/vcl/unx/kde4/KDEXLib.cxx
@@ -57,8 +57,9 @@
#include <stdio.h>
-#ifdef KDE_HAVE_GLIB
#if QT_VERSION >= QT_VERSION_CHECK( 4, 8, 0 )
+#define QT_UNIX_EVENT_LOOP_SUPPORT
+#ifdef KDE_HAVE_GLIB
#define GLIB_EVENT_LOOP_SUPPORT
#endif
#endif
@@ -201,6 +202,12 @@ void KDEXLib::Init()
static GPollFunc old_gpoll = NULL;
static gint gpoll_wrapper( GPollFD*, guint, gint );
#endif
+#ifdef QT_UNIX_EVENT_LOOP_SUPPORT
+static int (*qt_select)(int nfds, fd_set *fdread, fd_set *fdwrite, fd_set *fdexcept,
+ const struct timeval *orig_timeout);
+static int lo_select(int nfds, fd_set *fdread, fd_set *fdwrite, fd_set *fdexcept,
+ const struct timeval *orig_timeout);
+#endif
void KDEXLib::setupEventLoop()
{
@@ -221,7 +228,24 @@ void KDEXLib::setupEventLoop()
return;
}
#endif
- // TODO handle also Qt's own event loop (requires fixing Qt too)
+#ifdef QT_UNIX_EVENT_LOOP_SUPPORT
+// When Qt does not use Glib support, it uses its own Unix event dispatcher.
+// That one has aboutToBlock() and awake() signals, but they are broken (either
+// functionality or semantics), as e.g. awake() is not emitted right after the dispatcher
+// is woken up from sleep again, but only later (which is too late for re-acquiring SolarMutex).
+// This should be fixed with Qt-4.8.0 (?) where support for adding custom select() function
+// has been added too (http://bugreports.qt.nokia.com/browse/QTBUG-16934).
+ if( QAbstractEventDispatcher::instance()->inherits( "QEventDispatcherUNIX" ))
+ {
+ eventLoopType = QtUnixEventLoop;
+ QInternal::callFunction( QInternal::GetUnixSelectFunction, reinterpret_cast< void** >( &qt_select ));
+ QInternal::callFunction( QInternal::SetUnixSelectFunction, reinterpret_cast< void** >( lo_select ));
+ // set QClipboard to use event loop, otherwise the main thread will hold
+ // SolarMutex locked, which will prevent the clipboard thread from answering
+ m_pApplication->clipboard()->setProperty( "useEventLoopWhenWaiting", true );
+ return;
+ }
+#endif
}
#ifdef GLIB_EVENT_LOOP_SUPPORT
@@ -232,6 +256,15 @@ gint gpoll_wrapper( GPollFD* ufds, guint nfds, gint timeout )
}
#endif
+#ifdef QT_UNIX_EVENT_LOOP_SUPPORT
+int lo_select(int nfds, fd_set *fdread, fd_set *fdwrite, fd_set *fdexcept,
+ const struct timeval *orig_timeout)
+{
+ YieldMutexReleaser release; // release YieldMutex (and re-acquire at block end)
+ return qt_select( nfds, fdread, fdwrite, fdexcept, orig_timeout );
+}
+#endif
+
void KDEXLib::Insert( int fd, void* data, YieldFunc pending, YieldFunc queued, YieldFunc handle )
{
if( eventLoopType == LibreOfficeEventLoop )
diff --git a/vcl/unx/kde4/KDEXLib.hxx b/vcl/unx/kde4/KDEXLib.hxx
index 7bfc542427a9..21a5a45c4628 100644
--- a/vcl/unx/kde4/KDEXLib.hxx
+++ b/vcl/unx/kde4/KDEXLib.hxx
@@ -58,7 +58,7 @@ class KDEXLib : public QObject, public SalXLib
QHash< int, SocketData > socketData; // key is fd
QTimer timeoutTimer;
QTimer userEventTimer;
- enum { LibreOfficeEventLoop, GlibEventLoop } eventLoopType;
+ enum { LibreOfficeEventLoop, GlibEventLoop, QtUnixEventLoop } eventLoopType;
private:
void setupEventLoop();