[Libreoffice-commits] .: vcl/unx
Lubos Lunak
llunak at kemper.freedesktop.org
Wed Jan 26 08:06:51 PST 2011
vcl/unx/kde4/KDEXLib.cxx | 37 +++++++++++++++++++++++++++++++++++--
vcl/unx/kde4/KDEXLib.hxx | 2 +-
2 files changed, 36 insertions(+), 3 deletions(-)
New commits:
commit 486581adade446b43011f6e7d2c6496abea8d28d
Author: LuboÅ¡ LuÅák <l.lunak at suse.cz>
Date: Wed Jan 26 17:05:29 2011 +0100
proper Qt event loop integration also when Glib is not used
diff --git a/vcl/unx/kde4/KDEXLib.cxx b/vcl/unx/kde4/KDEXLib.cxx
index 21c3f51..8afc0eb 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 ffe93b4..f6a3279 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();
More information about the Libreoffice-commits
mailing list