[Libreoffice-commits] .: 4 commits - vcl/unx vcl/util

Lubos Lunak llunak at kemper.freedesktop.org
Thu Oct 14 09:14:28 PDT 2010


 vcl/unx/kde4/KDEData.cxx           |    1 
 vcl/unx/kde4/KDEData.hxx           |    1 
 vcl/unx/kde4/KDESalDisplay.cxx     |   24 ++++
 vcl/unx/kde4/KDESalDisplay.hxx     |   15 ++
 vcl/unx/kde4/KDESalFrame.hxx       |    1 
 vcl/unx/kde4/KDESalGraphics.hxx    |    1 
 vcl/unx/kde4/KDESalInstance.cxx    |    1 
 vcl/unx/kde4/KDESalInstance.hxx    |    1 
 vcl/unx/kde4/KDEXLib.cxx           |  200 ++++++++++++++++++++++++++++++++++++-
 vcl/unx/kde4/KDEXLib.hxx           |   45 +++++++-
 vcl/unx/kde4/VCLKDEApplication.cxx |    4 
 vcl/unx/kde4/VCLKDEApplication.hxx |    5 
 vcl/unx/kde4/makefile.mk           |   10 +
 vcl/util/makefile.mk               |    2 
 14 files changed, 296 insertions(+), 15 deletions(-)

New commits:
commit 2d70b300ed7900327d8f4cb0e2050b4a53ab6105
Author: Luboš Luňák <l.lunak at suse.cz>
Date:   Thu Oct 14 17:54:48 2010 +0200

    Qt event loop integration (when Glib is used) for KDE4 vclplug
    
    So far disabled because of a pending bugfix for Qt, and support
    for Qt's own event loop (without Glib) needs a missing feature
    in Qt.

diff --git a/vcl/unx/kde4/KDESalDisplay.cxx b/vcl/unx/kde4/KDESalDisplay.cxx
index de43f07..b1eb0d6 100644
--- a/vcl/unx/kde4/KDESalDisplay.cxx
+++ b/vcl/unx/kde4/KDESalDisplay.cxx
@@ -66,7 +66,6 @@ void SalKDEDisplay::Yield()
     XEvent event;
     XNextEvent( pDisp_, &event );
     qApp->x11ProcessEvent( &event );
-    // TODO maybe Qt needs locking and unlocking too?
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/unx/kde4/KDEXLib.cxx b/vcl/unx/kde4/KDEXLib.cxx
index c1bd0cf..bde1a41 100644
--- a/vcl/unx/kde4/KDEXLib.cxx
+++ b/vcl/unx/kde4/KDEXLib.cxx
@@ -36,6 +36,7 @@
 #include <kcmdlineargs.h>
 #include <kstartupinfo.h>
 #include <qabstracteventdispatcher.h>
+#include <qclipboard.h>
 #include <qthread.h>
 
 #undef Region
@@ -54,9 +55,24 @@
 #include <stdio.h>
 #endif
 
+#include <stdio.h>
+
+#ifdef KDE_HAVE_GLIB
+#if QT_VERSION >= QT_VERSION_CHECK( 4, 8, 0 )
+#if 0 // wait until fixed in Qt
+#define GLIB_EVENT_LOOP_SUPPORT
+#endif
+#endif
+#endif
+
+#ifdef GLIB_EVENT_LOOP_SUPPORT
+#include <glib-2.0/glib.h>
+#endif
+
 KDEXLib::KDEXLib() : 
     SalXLib(),	m_bStartupDone(false), m_pApplication(0),
-    m_pFreeCmdLineArgs(0), m_pAppCmdLineArgs(0), m_nFakeCmdLineArgs( 0 )
+    m_pFreeCmdLineArgs(0), m_pAppCmdLineArgs(0), m_nFakeCmdLineArgs( 0 ),
+    eventLoopType( LibreOfficeEventLoop )
 {
     // the timers created here means they belong to the main thread
     connect( &timeoutTimer, SIGNAL( timeout()), this, SLOT( timeoutActivated()));
@@ -156,7 +172,8 @@ void KDEXLib::Init()
     m_pApplication = new VCLKDEApplication();
     kapp->disableSessionManagement();
     KApplication::setQuitOnLastWindowClosed(false);
-    
+    setupEventLoop();
+
     Display* pDisp = QX11Info::display();
     SalKDEDisplay *pSalDisplay = new SalKDEDisplay(pDisp);
     
@@ -174,8 +191,52 @@ void KDEXLib::Init()
     pSalDisplay->SetKbdExtension( pKbdExtension );
 }
 
+// When we use Qt event loop, it can actually use its own event loop handling, or wrap
+// the Glib event loop (the latter is the default is Qt is built with Glib support
+// and $QT_NO_GLIB is not set). We mostly do not care which one it is, as QSocketNotifier's
+// and QTimer's can handle it transparently, but it matters for the SolarMutex, which
+// needs to be unlocked shortly before entering the main sleep (e.g. select()) and locked
+// immediatelly after. So we need to know which event loop implementation is used and
+// hook accordingly.
+#ifdef GLIB_EVENT_LOOP_SUPPORT
+static GPollFunc old_gpoll = NULL;
+static gint gpoll_wrapper( GPollFD*, guint, gint );
+#endif
+
+void KDEXLib::setupEventLoop()
+{
+#ifdef GLIB_EVENT_LOOP_SUPPORT
+// Glib is simple, it has g_main_context_set_poll_func() for wrapping the sleep call.
+// The catch is that Qt has a bug that allows triggering timers even when they should
+// not be, leading to crashes caused by QClipboard re-entering the event loop.
+// (http://bugreports.qt.nokia.com/browse/QTBUG-14461), so enable only with Qt>=4.8.0,
+// where it is(?) fixed.
+    if( QAbstractEventDispatcher::instance()->inherits( "QEventDispatcherGlib" ))
+    {
+        eventLoopType = GlibEventLoop;
+        old_gpoll = g_main_context_get_poll_func( NULL );
+        g_main_context_set_poll_func( NULL, gpoll_wrapper );
+        // 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
+    // TODO handle also Qt's own event loop (requires fixing Qt too)
+}
+
+#ifdef GLIB_EVENT_LOOP_SUPPORT
+gint gpoll_wrapper( GPollFD* ufds, guint nfds, gint timeout )
+{
+    YieldMutexReleaser release; // release YieldMutex (and re-acquire at block end)
+    return old_gpoll( ufds, nfds, timeout );
+}
+#endif
+
 void KDEXLib::Insert( int fd, void* data, YieldFunc pending, YieldFunc queued, YieldFunc handle )
 {
+    if( eventLoopType == LibreOfficeEventLoop )
+        return SalXLib::Insert( fd, data, pending, queued, handle );
     SocketData sdata;
     sdata.data = data;
     sdata.pending = pending;
@@ -189,21 +250,22 @@ void KDEXLib::Insert( int fd, void* data, YieldFunc pending, YieldFunc queued, Y
 
 void KDEXLib::Remove( int fd )
 {
+    if( eventLoopType == LibreOfficeEventLoop )
+        return SalXLib::Remove( fd );
     SocketData sdata = socketData.take( fd );// according to SalXLib::Remove() this should be safe
     delete sdata.notifier;
 }
 
 void KDEXLib::socketNotifierActivated( int fd )
 {
-    SalData *pSalData = GetSalData();
     const SocketData& sdata = socketData[ fd ];
-    pSalData->m_pInstance->GetYieldMutex()->acquire();
     sdata.handle( fd, sdata.data );
-    pSalData->m_pInstance->GetYieldMutex()->release();
 }
 
 void KDEXLib::Yield( bool bWait, bool bHandleAllCurrentEvents )
 {
+    if( eventLoopType == LibreOfficeEventLoop )
+        return SalXLib::Yield( bWait, bHandleAllCurrentEvents );
     // if we are the main thread (which is where the event processing is done),
     // good, just do it
     if( qApp->thread() == QThread::currentThread())
@@ -217,7 +279,6 @@ void KDEXLib::Yield( bool bWait, bool bHandleAllCurrentEvents )
 
 void KDEXLib::processYield( bool bWait, bool bHandleAllCurrentEvents )
 {
-    YieldMutexReleaser aReleaser;
     QAbstractEventDispatcher* dispatcher = QAbstractEventDispatcher::instance( qApp->thread());
     bool wasEvent = false;
     for( int cnt = bHandleAllCurrentEvents ? 100 : 1;
@@ -234,6 +295,8 @@ void KDEXLib::processYield( bool bWait, bool bHandleAllCurrentEvents )
 
 void KDEXLib::StartTimer( ULONG nMS )
 {
+    if( eventLoopType == LibreOfficeEventLoop )
+        return SalXLib::StartTimer( nMS );
     timeoutTimer.setInterval( nMS );
     // QTimer's can be started only in their thread (main thread here)
     if( qApp->thread() == QThread::currentThread())
@@ -249,25 +312,28 @@ void KDEXLib::startTimeoutTimer()
 
 void KDEXLib::StopTimer()
 {
+    if( eventLoopType == LibreOfficeEventLoop )
+        return SalXLib::StopTimer();
     timeoutTimer.stop();
 }
 
 void KDEXLib::timeoutActivated()
 {
-    SalData *pSalData = GetSalData();
-    pSalData->m_pInstance->GetYieldMutex()->acquire();
     GetX11SalData()->Timeout();
     // QTimer is not single shot, so will be restarted immediatelly
-    pSalData->m_pInstance->GetYieldMutex()->release();
 }
 
 void KDEXLib::Wakeup()
 {
+    if( eventLoopType == LibreOfficeEventLoop )
+        return SalXLib::Wakeup();
     QAbstractEventDispatcher::instance( qApp->thread())->wakeUp(); // main thread event loop
 }
 
 void KDEXLib::PostUserEvent()
 {
+    if( eventLoopType == LibreOfficeEventLoop )
+        return SalXLib::PostUserEvent();
     if( qApp->thread() == QThread::currentThread())
         startUserEventTimer();
     else
@@ -281,14 +347,11 @@ void KDEXLib::startUserEventTimer()
 
 void KDEXLib::userEventActivated()
 {
-    SalData *pSalData = GetSalData();
-    pSalData->m_pInstance->GetYieldMutex()->acquire();
     SalKDEDisplay::self()->EventGuardAcquire();
     if( SalKDEDisplay::self()->userEventsCount() <= 1 )
         userEventTimer.stop();
     SalKDEDisplay::self()->EventGuardRelease();
     SalKDEDisplay::self()->DispatchInternalEvent();
-    pSalData->m_pInstance->GetYieldMutex()->release();
     // QTimer is not single shot, so will be restarted immediatelly
 }
 
diff --git a/vcl/unx/kde4/KDEXLib.hxx b/vcl/unx/kde4/KDEXLib.hxx
index 30b2c87..5654f02 100644
--- a/vcl/unx/kde4/KDEXLib.hxx
+++ b/vcl/unx/kde4/KDEXLib.hxx
@@ -58,6 +58,10 @@ class KDEXLib : public QObject, public SalXLib
         QHash< int, SocketData > socketData; // key is fd
         QTimer timeoutTimer;
         QTimer userEventTimer;
+        enum { LibreOfficeEventLoop, GlibEventLoop } eventLoopType;
+
+    private:
+        void setupEventLoop();
 
     private slots:
         void socketNotifierActivated( int fd );
diff --git a/vcl/unx/kde4/makefile.mk b/vcl/unx/kde4/makefile.mk
index f4ea187..83ac1c0 100644
--- a/vcl/unx/kde4/makefile.mk
+++ b/vcl/unx/kde4/makefile.mk
@@ -57,12 +57,16 @@ dummy:
 
 .IF "$(ENABLE_KDE4)" != ""
 
-CFLAGS+=$(KDE4_CFLAGS)
+CFLAGS+=$(KDE4_CFLAGS) $(KDE_GLIB_CFLAGS)
 
 .IF "$(ENABLE_RANDR)" != ""
 CDEFS+=-DUSE_RANDR
 .ENDIF
 
+.IF "$(KDE_HAVE_GLIB)" != ""
+CDEFS+=-DKDE_HAVE_GLIB
+.ENDIF
+
 SLOFILES=\
     $(SLO)$/main.obj \
     $(SLO)$/VCLKDEApplication.obj \
diff --git a/vcl/util/makefile.mk b/vcl/util/makefile.mk
index eb54531..a5d8689 100644
--- a/vcl/util/makefile.mk
+++ b/vcl/util/makefile.mk
@@ -434,7 +434,7 @@ SHL6IMPLIB=ikde4_plug_
 SHL6LIBS=$(LIB6TARGET)
 SHL6DEPN=$(SHL2TARGETN)
 # libs for KDE4 plugin
-SHL6LINKFLAGS+=$(KDE4_LIBS)
+SHL6LINKFLAGS+=$(KDE4_LIBS) $(KDE_GLIB_LIBS)
 SHL6STDLIBS+=-l$(SHL2TARGET)
 SHL6STDLIBS+=\
         $(VCLLIB)       \
commit d8801c86f1e7ced83db9a0343f3a2625cbb564b7
Author: Luboš Luňák <l.lunak at suse.cz>
Date:   Wed Oct 13 14:39:16 2010 +0200

    make KDE4 vclplug use Qt event loop as the event loop

diff --git a/vcl/unx/kde4/KDESalDisplay.cxx b/vcl/unx/kde4/KDESalDisplay.cxx
index a192c6e..de43f07 100644
--- a/vcl/unx/kde4/KDESalDisplay.cxx
+++ b/vcl/unx/kde4/KDESalDisplay.cxx
@@ -29,8 +29,10 @@
 #include "KDESalDisplay.hxx"
 
 #include "KDEXLib.hxx"
+#include "VCLKDEApplication.hxx"
 
 #include <assert.h>
+#include <saldata.hxx>
 
 SalKDEDisplay* SalKDEDisplay::selfptr = NULL;
 
@@ -52,4 +54,19 @@ SalKDEDisplay::~SalKDEDisplay()
     pDisp_ = NULL;
 }
 
+void SalKDEDisplay::Yield()
+{
+    if( DispatchInternalEvent() )
+        return;
+
+    DBG_ASSERT( static_cast<SalYieldMutex*>(GetSalData()->m_pInstance->GetYieldMutex())->GetThreadId() ==
+                osl::Thread::getCurrentIdentifier(),
+                "will crash soon since solar mutex not locked in SalKDEDisplay::Yield" );
+
+    XEvent event;
+    XNextEvent( pDisp_, &event );
+    qApp->x11ProcessEvent( &event );
+    // TODO maybe Qt needs locking and unlocking too?
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/unx/kde4/KDESalDisplay.hxx b/vcl/unx/kde4/KDESalDisplay.hxx
index 8fd0cef..1a79c86 100644
--- a/vcl/unx/kde4/KDESalDisplay.hxx
+++ b/vcl/unx/kde4/KDESalDisplay.hxx
@@ -36,6 +36,11 @@ class SalKDEDisplay : public SalX11Display
         SalKDEDisplay( Display* pDisp );
         virtual ~SalKDEDisplay();
         static SalKDEDisplay* self();
+        inline int userEventsCount() const { return m_aUserEvents.size(); }
+        inline void EventGuardAcquire() { osl_acquireMutex( hEventGuard_ ); }
+        inline void EventGuardRelease() { osl_releaseMutex( hEventGuard_ ); }
+//        virtual long Dispatch( XEvent *event );
+        virtual void Yield();
     private:
         static SalKDEDisplay* selfptr;
 };
diff --git a/vcl/unx/kde4/KDEXLib.cxx b/vcl/unx/kde4/KDEXLib.cxx
index 061db97..c1bd0cf 100644
--- a/vcl/unx/kde4/KDEXLib.cxx
+++ b/vcl/unx/kde4/KDEXLib.cxx
@@ -35,6 +35,8 @@
 #include <kaboutdata.h>
 #include <kcmdlineargs.h>
 #include <kstartupinfo.h>
+#include <qabstracteventdispatcher.h>
+#include <qthread.h>
 
 #undef Region
 
@@ -56,6 +58,17 @@ KDEXLib::KDEXLib() :
     SalXLib(),	m_bStartupDone(false), m_pApplication(0),
     m_pFreeCmdLineArgs(0), m_pAppCmdLineArgs(0), m_nFakeCmdLineArgs( 0 )
 {
+    // the timers created here means they belong to the main thread
+    connect( &timeoutTimer, SIGNAL( timeout()), this, SLOT( timeoutActivated()));
+    connect( &userEventTimer, SIGNAL( timeout()), this, SLOT( userEventActivated()));
+    // QTimer::start() can be called only in its (here main) thread, so this will
+    // forward between threads if needed
+    connect( this, SIGNAL( startTimeoutTimerSignal()), this, SLOT( startTimeoutTimer()), Qt::QueuedConnection );
+    connect( this, SIGNAL( startUserEventTimerSignal()), this, SLOT( startUserEventTimer()), Qt::QueuedConnection );
+    // this one needs to be blocking, so that the handling in main thread is processed before
+    // the thread emitting the signal continues
+    connect( this, SIGNAL( processYieldSignal( bool, bool )), this, SLOT( processYield( bool, bool )),
+        Qt::BlockingQueuedConnection );
 }
 
 KDEXLib::~KDEXLib()
@@ -161,6 +174,124 @@ void KDEXLib::Init()
     pSalDisplay->SetKbdExtension( pKbdExtension );
 }
 
+void KDEXLib::Insert( int fd, void* data, YieldFunc pending, YieldFunc queued, YieldFunc handle )
+{
+    SocketData sdata;
+    sdata.data = data;
+    sdata.pending = pending;
+    sdata.queued = queued;
+    sdata.handle = handle;
+    // qApp as parent to make sure it uses the main thread event loop
+    sdata.notifier = new QSocketNotifier( fd, QSocketNotifier::Read, qApp );
+    connect( sdata.notifier, SIGNAL( activated( int )), this, SLOT( socketNotifierActivated( int )));
+    socketData[ fd ] = sdata;
+}
+
+void KDEXLib::Remove( int fd )
+{
+    SocketData sdata = socketData.take( fd );// according to SalXLib::Remove() this should be safe
+    delete sdata.notifier;
+}
+
+void KDEXLib::socketNotifierActivated( int fd )
+{
+    SalData *pSalData = GetSalData();
+    const SocketData& sdata = socketData[ fd ];
+    pSalData->m_pInstance->GetYieldMutex()->acquire();
+    sdata.handle( fd, sdata.data );
+    pSalData->m_pInstance->GetYieldMutex()->release();
+}
+
+void KDEXLib::Yield( bool bWait, bool bHandleAllCurrentEvents )
+{
+    // if we are the main thread (which is where the event processing is done),
+    // good, just do it
+    if( qApp->thread() == QThread::currentThread())
+        processYield( bWait, bHandleAllCurrentEvents );
+    else
+    { // if this deadlocks, event processing needs to go into a separate thread
+      // or some other solution needs to be found
+        emit processYieldSignal( bWait, bHandleAllCurrentEvents );
+    }
+}
+
+void KDEXLib::processYield( bool bWait, bool bHandleAllCurrentEvents )
+{
+    YieldMutexReleaser aReleaser;
+    QAbstractEventDispatcher* dispatcher = QAbstractEventDispatcher::instance( qApp->thread());
+    bool wasEvent = false;
+    for( int cnt = bHandleAllCurrentEvents ? 100 : 1;
+         cnt > 0;
+         --cnt )
+    {
+        if( !dispatcher->processEvents( QEventLoop::AllEvents ))
+            break;
+        wasEvent = true;
+    }
+    if( bWait && !wasEvent )
+        dispatcher->processEvents( QEventLoop::WaitForMoreEvents );
+}
+
+void KDEXLib::StartTimer( ULONG nMS )
+{
+    timeoutTimer.setInterval( nMS );
+    // QTimer's can be started only in their thread (main thread here)
+    if( qApp->thread() == QThread::currentThread())
+        startTimeoutTimer();
+    else
+        emit startTimeoutTimerSignal();
+}
+
+void KDEXLib::startTimeoutTimer()
+{
+    timeoutTimer.start();
+}
+
+void KDEXLib::StopTimer()
+{
+    timeoutTimer.stop();
+}
+
+void KDEXLib::timeoutActivated()
+{
+    SalData *pSalData = GetSalData();
+    pSalData->m_pInstance->GetYieldMutex()->acquire();
+    GetX11SalData()->Timeout();
+    // QTimer is not single shot, so will be restarted immediatelly
+    pSalData->m_pInstance->GetYieldMutex()->release();
+}
+
+void KDEXLib::Wakeup()
+{
+    QAbstractEventDispatcher::instance( qApp->thread())->wakeUp(); // main thread event loop
+}
+
+void KDEXLib::PostUserEvent()
+{
+    if( qApp->thread() == QThread::currentThread())
+        startUserEventTimer();
+    else
+        emit startUserEventTimerSignal();
+}
+
+void KDEXLib::startUserEventTimer()
+{
+    userEventTimer.start( 0 );
+}
+
+void KDEXLib::userEventActivated()
+{
+    SalData *pSalData = GetSalData();
+    pSalData->m_pInstance->GetYieldMutex()->acquire();
+    SalKDEDisplay::self()->EventGuardAcquire();
+    if( SalKDEDisplay::self()->userEventsCount() <= 1 )
+        userEventTimer.stop();
+    SalKDEDisplay::self()->EventGuardRelease();
+    SalKDEDisplay::self()->DispatchInternalEvent();
+    pSalData->m_pInstance->GetYieldMutex()->release();
+    // QTimer is not single shot, so will be restarted immediatelly
+}
+
 void KDEXLib::doStartup()
 {
     if( ! m_bStartupDone )
diff --git a/vcl/unx/kde4/KDEXLib.hxx b/vcl/unx/kde4/KDEXLib.hxx
index 89ef314..30b2c87 100644
--- a/vcl/unx/kde4/KDEXLib.hxx
+++ b/vcl/unx/kde4/KDEXLib.hxx
@@ -30,22 +30,59 @@
 
 #include <saldisp.hxx>
 
+#include <fixx11h.h>
+
+#include <qhash.h>
+#include <qsocketnotifier.h>
+#include <qtimer.h>
+
 class VCLKDEApplication;
 
-class KDEXLib : public SalXLib
+class KDEXLib : public QObject, public SalXLib
 {
+    Q_OBJECT
     private:
         bool m_bStartupDone;
         VCLKDEApplication* m_pApplication;
         char** m_pFreeCmdLineArgs;
         char** m_pAppCmdLineArgs;
         int m_nFakeCmdLineArgs;
+        struct SocketData
+            {
+            void* data;
+            YieldFunc pending;
+            YieldFunc queued;
+            YieldFunc handle;
+            QSocketNotifier* notifier;
+            };
+        QHash< int, SocketData > socketData; // key is fd
+        QTimer timeoutTimer;
+        QTimer userEventTimer;
+
+    private slots:
+        void socketNotifierActivated( int fd );
+        void timeoutActivated();
+        void userEventActivated();
+        void startTimeoutTimer();
+        void startUserEventTimer();
+        void processYield( bool bWait, bool bHandleAllCurrentEvents );
+    signals:
+        void startTimeoutTimerSignal();
+        void startUserEventTimerSignal();
+        void processYieldSignal( bool bWait, bool bHandleAllCurrentEvents );
         
     public:
         KDEXLib();
-                
         virtual ~KDEXLib();
+
         virtual void Init();
+        virtual void Yield( bool bWait, bool bHandleAllCurrentEvents );
+        virtual void Insert( int fd, void* data, YieldFunc pending, YieldFunc queued, YieldFunc handle );
+        virtual void Remove( int fd );
+        virtual void StartTimer( ULONG nMS );
+        virtual void StopTimer();
+        virtual void Wakeup();
+        virtual void PostUserEvent();
             
         void doStartup();
 };
diff --git a/vcl/unx/kde4/makefile.mk b/vcl/unx/kde4/makefile.mk
index fd1e9ca..f4ea187 100644
--- a/vcl/unx/kde4/makefile.mk
+++ b/vcl/unx/kde4/makefile.mk
@@ -67,6 +67,7 @@ SLOFILES=\
     $(SLO)$/main.obj \
     $(SLO)$/VCLKDEApplication.obj \
     $(SLO)$/KDEXLib.obj \
+    $(SLO)$/KDEXLib.moc.obj \
     $(SLO)$/KDESalDisplay.obj \
     $(SLO)$/KDESalFrame.obj \
     $(SLO)$/KDESalGraphics.obj \
@@ -86,3 +87,6 @@ dummy:
 .INCLUDE :  target.mk
 
 .INCLUDE :  $(PRJ)$/util$/target.pmk
+
+$(MISC)$/KDEXLib.moc.cxx : KDEXLib.hxx
+    $(MOC4) $< -o $@
commit 1e0f460e3cb934998c1b60fd331fd4247a646205
Author: Luboš Luňák <l.lunak at suse.cz>
Date:   Tue Oct 12 15:52:53 2010 +0200

    proper accessor for SalKDEDisplay instead of random public vars

diff --git a/vcl/unx/kde4/KDESalDisplay.cxx b/vcl/unx/kde4/KDESalDisplay.cxx
index 770c481..a192c6e 100644
--- a/vcl/unx/kde4/KDESalDisplay.cxx
+++ b/vcl/unx/kde4/KDESalDisplay.cxx
@@ -30,9 +30,15 @@
 
 #include "KDEXLib.hxx"
 
+#include <assert.h>
+
+SalKDEDisplay* SalKDEDisplay::selfptr = NULL;
+
 SalKDEDisplay::SalKDEDisplay( Display* pDisp )
     : SalX11Display( pDisp )
 {
+    assert( selfptr == NULL );
+    selfptr = this;
 }
 
 SalKDEDisplay::~SalKDEDisplay()
@@ -41,6 +47,7 @@ SalKDEDisplay::~SalKDEDisplay()
     static_cast<KDEXLib*>(GetXLib())->doStartup();
     // clean up own members
     doDestruct();
+    selfptr = NULL;
     // prevent SalDisplay from closing KApplication's display
     pDisp_ = NULL;
 }
diff --git a/vcl/unx/kde4/KDESalDisplay.hxx b/vcl/unx/kde4/KDESalDisplay.hxx
index 06d0655..8fd0cef 100644
--- a/vcl/unx/kde4/KDESalDisplay.hxx
+++ b/vcl/unx/kde4/KDESalDisplay.hxx
@@ -34,7 +34,15 @@ class SalKDEDisplay : public SalX11Display
 {
     public:
         SalKDEDisplay( Display* pDisp );
-            virtual ~SalKDEDisplay();
+        virtual ~SalKDEDisplay();
+        static SalKDEDisplay* self();
+    private:
+        static SalKDEDisplay* selfptr;
 };
 
+inline SalKDEDisplay* SalKDEDisplay::self()
+{
+    return selfptr;
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/unx/kde4/KDEXLib.cxx b/vcl/unx/kde4/KDEXLib.cxx
index 3137b55..061db97 100644
--- a/vcl/unx/kde4/KDEXLib.cxx
+++ b/vcl/unx/kde4/KDEXLib.cxx
@@ -147,8 +147,6 @@ void KDEXLib::Init()
     Display* pDisp = QX11Info::display();
     SalKDEDisplay *pSalDisplay = new SalKDEDisplay(pDisp);
     
-    m_pApplication->disp = pSalDisplay;
-
     pInputMethod->CreateMethod( pDisp );
     pInputMethod->AddConnectionWatch( pDisp, (void*)this );
     pSalDisplay->SetInputMethod( pInputMethod );
diff --git a/vcl/unx/kde4/VCLKDEApplication.cxx b/vcl/unx/kde4/VCLKDEApplication.cxx
index e84209f..678731c 100644
--- a/vcl/unx/kde4/VCLKDEApplication.cxx
+++ b/vcl/unx/kde4/VCLKDEApplication.cxx
@@ -37,14 +37,13 @@
 VCLKDEApplication::VCLKDEApplication() : 
     KApplication()
 {
-    disp = 0;
 }
 
 bool VCLKDEApplication::x11EventFilter(XEvent* event)
 {
     //if we have a display and the display consumes the event
     //do not process the event in qt
-    if (disp && disp->Dispatch(event) > 0)
+    if (SalKDEDisplay::self() && SalKDEDisplay::self()->Dispatch(event) > 0)
     {
         return true;
     }
diff --git a/vcl/unx/kde4/VCLKDEApplication.hxx b/vcl/unx/kde4/VCLKDEApplication.hxx
index 7f1b5be..d86e859 100644
--- a/vcl/unx/kde4/VCLKDEApplication.hxx
+++ b/vcl/unx/kde4/VCLKDEApplication.hxx
@@ -36,8 +36,6 @@
 
 #undef Region
 
-class SalKDEDisplay;
-
 /* #i59042# override KApplications method for session management
  * since it will interfere badly with our own.
  */
@@ -49,8 +47,6 @@ class VCLKDEApplication : public KApplication
         virtual void commitData(QSessionManager&) {};
         
         virtual bool x11EventFilter(XEvent* event);
-        
-        SalKDEDisplay* disp;
 };
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit 30b94bcdbef992b265046430fd4ee13cb9e79382
Author: Luboš Luňák <l.lunak at suse.cz>
Date:   Tue Oct 12 15:46:14 2010 +0200

    newline at end of files

diff --git a/vcl/unx/kde4/KDEData.cxx b/vcl/unx/kde4/KDEData.cxx
index bb8489b..655a759 100644
--- a/vcl/unx/kde4/KDEData.cxx
+++ b/vcl/unx/kde4/KDEData.cxx
@@ -53,4 +53,5 @@ void KDEData::initNWF()
 void KDEData::deInitNWF()
 {
 }
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/unx/kde4/KDEData.hxx b/vcl/unx/kde4/KDEData.hxx
index 54fdf7f..612ea75 100644
--- a/vcl/unx/kde4/KDEData.hxx
+++ b/vcl/unx/kde4/KDEData.hxx
@@ -41,4 +41,5 @@ class KDEData : public X11SalData
         virtual void initNWF();
         virtual void deInitNWF();
 };
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/unx/kde4/KDESalDisplay.cxx b/vcl/unx/kde4/KDESalDisplay.cxx
index f3b87af..770c481 100644
--- a/vcl/unx/kde4/KDESalDisplay.cxx
+++ b/vcl/unx/kde4/KDESalDisplay.cxx
@@ -44,4 +44,5 @@ SalKDEDisplay::~SalKDEDisplay()
     // prevent SalDisplay from closing KApplication's display
     pDisp_ = NULL;
 }
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/unx/kde4/KDESalFrame.hxx b/vcl/unx/kde4/KDESalFrame.hxx
index f01dd60..d6ae5a8 100644
--- a/vcl/unx/kde4/KDESalFrame.hxx
+++ b/vcl/unx/kde4/KDESalFrame.hxx
@@ -57,4 +57,5 @@ class KDESalFrame : public X11SalFrame
         virtual void UpdateSettings( AllSettings& rSettings );
         virtual void Show( BOOL bVisible, BOOL bNoActivate );
 };
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/unx/kde4/KDESalGraphics.hxx b/vcl/unx/kde4/KDESalGraphics.hxx
index e5e49a6..b9f4ec1 100644
--- a/vcl/unx/kde4/KDESalGraphics.hxx
+++ b/vcl/unx/kde4/KDESalGraphics.hxx
@@ -112,4 +112,5 @@ class KDESalGraphics : public X11SalGraphics
                                             const rtl::OUString& aCaption,
                                             Rectangle &rNativeBoundingRegion, Rectangle &rNativeContentRegion );
 };
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/unx/kde4/KDESalInstance.cxx b/vcl/unx/kde4/KDESalInstance.cxx
index dc23884..976e77a 100644
--- a/vcl/unx/kde4/KDESalInstance.cxx
+++ b/vcl/unx/kde4/KDESalInstance.cxx
@@ -34,4 +34,5 @@ SalFrame* KDESalInstance::CreateFrame( SalFrame *pParent, ULONG nState )
 {
     return new KDESalFrame( pParent, nState );
 }
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/unx/kde4/KDESalInstance.hxx b/vcl/unx/kde4/KDESalInstance.hxx
index c3c46e7..ed46360 100644
--- a/vcl/unx/kde4/KDESalInstance.hxx
+++ b/vcl/unx/kde4/KDESalInstance.hxx
@@ -40,4 +40,5 @@ class KDESalInstance : public X11SalInstance
         virtual ~KDESalInstance() {}
         virtual SalFrame* CreateFrame( SalFrame* pParent, ULONG nStyle );
 };
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/unx/kde4/VCLKDEApplication.cxx b/vcl/unx/kde4/VCLKDEApplication.cxx
index 2ae59c6..e84209f 100644
--- a/vcl/unx/kde4/VCLKDEApplication.cxx
+++ b/vcl/unx/kde4/VCLKDEApplication.cxx
@@ -51,4 +51,5 @@ bool VCLKDEApplication::x11EventFilter(XEvent* event)
     
     return false;
 }
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/unx/kde4/VCLKDEApplication.hxx b/vcl/unx/kde4/VCLKDEApplication.hxx
index fd871a7..7f1b5be 100644
--- a/vcl/unx/kde4/VCLKDEApplication.hxx
+++ b/vcl/unx/kde4/VCLKDEApplication.hxx
@@ -52,4 +52,5 @@ class VCLKDEApplication : public KApplication
         
         SalKDEDisplay* disp;
 };
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */


More information about the Libreoffice-commits mailing list