[Libreoffice-commits] core.git: Branch 'private/jmux/libreoffice-4-1+kde4' - config_host/config_kde4.h.in config_host.mk.in configure.ac vcl/Library_vclplug_kde4.mk vcl/unx

Jan-Marek Glogowski glogow at fbihome.de
Tue Mar 11 04:38:01 PDT 2014


 config_host.mk.in               |    3 +-
 config_host/config_kde4.h.in    |    4 ++-
 configure.ac                    |   23 +++++++++++++++---
 vcl/Library_vclplug_kde4.mk     |    9 +++++--
 vcl/unx/kde4/KDE4FilePicker.cxx |    8 ++++--
 vcl/unx/kde4/KDEData.cxx        |    2 +
 vcl/unx/kde4/KDESalInstance.cxx |    2 +
 vcl/unx/kde4/KDESalInstance.hxx |    4 +++
 vcl/unx/kde4/KDEXLib.cxx        |   50 ++++++++--------------------------------
 9 files changed, 56 insertions(+), 49 deletions(-)

New commits:
commit b9dec0ff964002432deb6ec49a5bfb3e7cdb8dec
Author: Jan-Marek Glogowski <glogow at fbihome.de>
Date:   Mon Mar 10 15:05:22 2014 +0000

    KDE4: Don't use native file pickers per default.
    
    Add a configure option to build with native KDE4 file pickers and
    disable them. Even with all the workarounds applied it's impossible
    to work around the bug in the Qt4 glib event loop, which doesn't
    ignore socket events when polling the clipboard through QClipboard.
    
    See https://bugreports.qt-project.org/browse/QTBUG-37380.
    
    Change-Id: I5cad30ead74571e49a075c084cca7a19acff7523

diff --git a/config_host.mk.in b/config_host.mk.in
index 175bab3..6dacd73 100644
--- a/config_host.mk.in
+++ b/config_host.mk.in
@@ -222,10 +222,12 @@ export HAVE_GCC_VISIBILITY_BROKEN=@HAVE_GCC_VISIBILITY_BROKEN@
 export HAVE_GCC_VISIBILITY_FEATURE=@HAVE_GCC_VISIBILITY_FEATURE@
 export HAVE_GETOPT=@HAVE_GETOPT@
 export HAVE_GNUMAKE_FILE_FUNC=@HAVE_GNUMAKE_FILE_FUNC@
+export HAVE_KDE4_NATIVE_FILE_PICKER=@HAVE_KDE4_NATIVE_FILE_PICKER@
 export HAVE_LD_BSYMBOLIC_FUNCTIONS=@HAVE_LD_BSYMBOLIC_FUNCTIONS@
 export HAVE_LD_HASH_STYLE=@HAVE_LD_HASH_STYLE@
 export HAVE_NON_CONST_NPP_GETMIMEDESCRIPTION=@HAVE_NON_CONST_NPP_GETMIMEDESCRIPTION@
 export HAVE_POSIX_FALLOCATE=@HAVE_POSIX_FALLOCATE@
+export HAVE_QT4_GLIB=@HAVE_QT4_GLIB@
 export HAVE_READDIR_R=@HAVE_READDIR_R@
 export HAVE_THREADSAFE_STATICS=@HAVE_THREADSAFE_STATICS@
 export HOST_PLATFORM=@host@
@@ -272,7 +274,6 @@ export KDE4_LIBS=$(gb_SPACE)@KDE4_LIBS@
 export KDE_CFLAGS=$(gb_SPACE)@KDE_CFLAGS@
 export KDE_GLIB_CFLAGS=$(gb_SPACE)@KDE_GLIB_CFLAGS@
 export KDE_GLIB_LIBS=$(gb_SPACE)@KDE_GLIB_LIBS@
-export KDE_HAVE_GLIB=@KDE_HAVE_GLIB@
 export KDE_LIBS=$(gb_SPACE)@KDE_LIBS@
 export KRB5_LIBS=@KRB5_LIBS@
 export LCMS2_CFLAGS=$(gb_SPACE)@LCMS2_CFLAGS@
diff --git a/config_host/config_kde4.h.in b/config_host/config_kde4.h.in
index 6e91b38..2c7af8e 100644
--- a/config_host/config_kde4.h.in
+++ b/config_host/config_kde4.h.in
@@ -5,6 +5,8 @@ Settings for KDE4 integration.
 #ifndef CONFIG_KDE4_H
 #define CONFIG_KDE4_H
 
-#define KDE_HAVE_GLIB 0
+#define HAVE_QT4_GLIB 0
+
+#define HAVE_KDE4_NATIVE_FILE_PICKER 0
 
 #endif
diff --git a/configure.ac b/configure.ac
index 1662258..7eba7c3 100644
--- a/configure.ac
+++ b/configure.ac
@@ -978,6 +978,15 @@ AC_ARG_ENABLE(kde4,
          both KDE3 and KDE4.]),
 ,)
 
+AC_ARG_ENABLE(kde4-native-file-picker,
+    AS_HELP_STRING([--enable-kde4-native-file-picker],
+        [Just enable the native KDE4 file picker, if you have a Qt4 version,
+         which includes the patch from
+         https://bugreports.qt-project.org/browse/QTBUG-37380. Otherwise
+         Libre Office will quite often crash with native file picker
+         dialogs!]),
+,)
+
 AC_ARG_ENABLE(headless,
     AS_HELP_STRING([--enable-headless],
         [Disable building of GUIs to reduce dependencies. Useful for
@@ -10376,7 +10385,8 @@ QMAKE4="qmake"
 MOC4="moc"
 KDE_GLIB_CFLAGS=""
 KDE_GLIB_LIBS=""
-KDE_HAVE_GLIB=""
+HAVE_QT4_GLIB=""
+HAVE_KDE4_NATIVE_FILE_PICKER=""
 if test "$test_kde4" = "yes" -a "$ENABLE_KDE4" = "TRUE"; then
     qt_incdirs="$QT4INC /usr/include/qt4 /usr/include $x_includes"
     qt_libdirs="$QT4LIB /usr/lib/qt4 /usr/lib $x_libraries"
@@ -10533,8 +10543,12 @@ int main(int argc, char **argv) {
     # Sets also KDE_GLIB_CFLAGS/KDE_GLIB_LIBS if successful.
     PKG_CHECK_MODULES(KDE_GLIB,[glib-2.0 >= 2.4],
         [
-        KDE_HAVE_GLIB=1
-        AC_DEFINE(KDE_HAVE_GLIB,1)
+        HAVE_QT4_GLIB=1
+        AC_DEFINE(HAVE_QT4_GLIB)
+        if test "x$enable_kde4_native_file_picker" = "xyes"; then
+            HAVE_KDE4_NATIVE_FILE_PICKER=1
+            AC_DEFINE(HAVE_KDE4_NATIVE_FILE_PICKER)
+        fi
         ],
         AC_MSG_WARN([[No Glib found, KDE4 support will not integrate with Qt's Glib event loop support]]))
 fi
@@ -10543,7 +10557,8 @@ AC_SUBST(KDE4_LIBS)
 AC_SUBST(MOC4)
 AC_SUBST(KDE_GLIB_CFLAGS)
 AC_SUBST(KDE_GLIB_LIBS)
-AC_SUBST(KDE_HAVE_GLIB)
+AC_SUBST(HAVE_QT4_GLIB)
+AC_SUBST(HAVE_KDE4_NATIVE_FILE_PICKER)
 
 dnl ===================================================================
 dnl Test for the enabling the lockdown pieces
diff --git a/vcl/Library_vclplug_kde4.mk b/vcl/Library_vclplug_kde4.mk
index 45e1042..f40f26b 100644
--- a/vcl/Library_vclplug_kde4.mk
+++ b/vcl/Library_vclplug_kde4.mk
@@ -64,7 +64,7 @@ $(eval $(call gb_Library_add_libs,vclplug_kde4,\
 	-lICE \
 ))
 
-ifneq ($(KDE_HAVE_GLIB),)
+ifneq ($(HAVE_QT4_GLIB),)
 $(eval $(call gb_Library_add_defs,vclplug_kde4,\
     $(KDE_GLIB_CFLAGS) \
 ))
@@ -77,7 +77,6 @@ endif
 
 $(eval $(call gb_Library_add_exception_objects,vclplug_kde4,\
     vcl/unx/kde4/KDEData \
-	vcl/unx/kde4/KDE4FilePicker \
     vcl/unx/kde4/KDESalDisplay \
     vcl/unx/kde4/KDESalFrame \
     vcl/unx/kde4/KDESalGraphics \
@@ -87,6 +86,12 @@ $(eval $(call gb_Library_add_exception_objects,vclplug_kde4,\
     vcl/unx/kde4/VCLKDEApplication \
 ))
 
+ifneq ($(HAVE_KDE4_NATIVE_FILE_PICKER),)
+$(eval $(call gb_Library_add_exception_objects,vclplug_kde4,\
+     vcl/unx/kde4/KDE4FilePicker \
+))
+endif
+
 ifeq ($(OS),LINUX)
 $(eval $(call gb_Library_add_libs,vclplug_kde4,\
 	-lm \
diff --git a/vcl/unx/kde4/KDE4FilePicker.cxx b/vcl/unx/kde4/KDE4FilePicker.cxx
index 1712a72..d54d1e1 100644
--- a/vcl/unx/kde4/KDE4FilePicker.cxx
+++ b/vcl/unx/kde4/KDE4FilePicker.cxx
@@ -237,8 +237,12 @@ sal_Int16 SAL_CALL KDE4FilePicker::execute()
     _dialog->filterWidget()->setEditable(false);
 
     // We're entering a nested loop.
-    // Release the yield mutex to prevent deadlocks.
-    int result = _dialog->exec();
+    int result;
+    {
+        // Release the yield mutex to prevent deadlocks.
+        SalYieldMutexReleaser aReleaser;
+        result = _dialog->exec();
+    }
 
     // HACK: KFileDialog uses KConfig("kdeglobals") for saving some settings
     // (such as the auto-extension flag), but that doesn't update KGlobal::config()
diff --git a/vcl/unx/kde4/KDEData.cxx b/vcl/unx/kde4/KDEData.cxx
index ccbbd99..0e87c62 100644
--- a/vcl/unx/kde4/KDEData.cxx
+++ b/vcl/unx/kde4/KDEData.cxx
@@ -27,6 +27,7 @@
 #include "KDEData.hxx"
 
 #include "KDEXLib.hxx"
+#include "KDESalDisplay.hxx"
 
 
 KDEData::~KDEData()
@@ -37,6 +38,7 @@ void KDEData::Init()
 {
     pXLib_ = new KDEXLib();
     pXLib_->Init();
+    SetDisplay( SalKDEDisplay::self() );
 }
 
 void KDEData::initNWF()
diff --git a/vcl/unx/kde4/KDESalInstance.cxx b/vcl/unx/kde4/KDESalInstance.cxx
index 9670172..8273637 100644
--- a/vcl/unx/kde4/KDESalInstance.cxx
+++ b/vcl/unx/kde4/KDESalInstance.cxx
@@ -31,12 +31,14 @@ SalFrame* KDESalInstance::CreateFrame( SalFrame *pParent, sal_uLong nState )
     return new KDESalFrame( pParent, nState );
 }
 
+#if HAVE_KDE4_NATIVE_FILE_PICKER
 uno::Reference< ui::dialogs::XFilePicker2 > KDESalInstance::createFilePicker(
         const uno::Reference< uno::XComponentContext >& xMSF )
 {
     return uno::Reference< ui::dialogs::XFilePicker2 >(
         static_cast<KDEXLib*>( mpXLib )->createFilePicker(xMSF) );
 }
+#endif
 
 int KDESalInstance::getFrameWidth()
 {
diff --git a/vcl/unx/kde4/KDESalInstance.hxx b/vcl/unx/kde4/KDESalInstance.hxx
index f73af0d..f050816 100644
--- a/vcl/unx/kde4/KDESalInstance.hxx
+++ b/vcl/unx/kde4/KDESalInstance.hxx
@@ -21,6 +21,8 @@
 
 #include <unx/salinst.h>
 
+#include <config_kde4.h>
+
 class SalYieldMutex;
 class SalFrame;
 
@@ -33,9 +35,11 @@ class KDESalInstance : public X11SalInstance
 
         virtual bool hasNativeFileSelection() const { return true; }
 
+#if HAVE_KDE4_NATIVE_FILE_PICKER
         virtual com::sun::star::uno::Reference< com::sun::star::ui::dialogs::XFilePicker2 >
             createFilePicker( const com::sun::star::uno::Reference<
                                   com::sun::star::uno::XComponentContext >& );
+#endif
         int getFrameWidth();
 };
 
diff --git a/vcl/unx/kde4/KDEXLib.cxx b/vcl/unx/kde4/KDEXLib.cxx
index 73c2ebe..58d19c4 100644
--- a/vcl/unx/kde4/KDEXLib.cxx
+++ b/vcl/unx/kde4/KDEXLib.cxx
@@ -17,6 +17,8 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
+#include <config_kde4.h>
+
 #include "VCLKDEApplication.hxx"
 
 #include "KDE4FilePicker.hxx"
@@ -43,17 +45,10 @@
 
 #include <stdio.h>
 
-#include <config_kde4.h>
-
-#if KDE_HAVE_GLIB
-#define GLIB_EVENT_LOOP_SUPPORT 1
-#else
-#define GLIB_EVENT_LOOP_SUPPORT 0
+#if HAVE_KDE4_NATIVE_FILE_PICKER
+#include "KDE4FilePicker.hxx"
 #endif
 
-#if GLIB_EVENT_LOOP_SUPPORT
-#include <glib-2.0/glib.h>
-#endif
 
 KDEXLib::KDEXLib() :
     SalXLib(),  m_bStartupDone(false), m_pApplication(0),
@@ -183,18 +178,6 @@ void KDEXLib::Init()
     pSalDisplay->SetupInput( pInputMethod );
 }
 
-// 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.
-#if GLIB_EVENT_LOOP_SUPPORT
-static GPollFunc old_gpoll = NULL;
-static gint gpoll_wrapper( GPollFD*, guint, gint );
-#endif
-
 static bool ( *old_qt_event_filter )( void* );
 static bool qt_event_filter( void* m )
 {
@@ -208,31 +191,16 @@ static bool qt_event_filter( void* m )
 void KDEXLib::setupEventLoop()
 {
     old_qt_event_filter = QAbstractEventDispatcher::instance()->setEventFilter( qt_event_filter );
-#if 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 QT_VERSION >= QT_VERSION_CHECK( 4, 8, 0 )
+#if HAVE_KDE4_NATIVE_FILE_PICKER
+    // See http://bugreports.qt.nokia.com/browse/QTBUG-37380
     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 );
+        m_pApplication->clipboard()->setProperty( "useEventLoopWhenWaiting", true );
         return;
     }
 #endif
-#endif
-}
-
-#if GLIB_EVENT_LOOP_SUPPORT
-gint gpoll_wrapper( GPollFD* ufds, guint nfds, gint timeout )
-{
-    SalYieldMutexReleaser 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 )
 {
@@ -392,11 +360,15 @@ using namespace com::sun::star;
 uno::Reference< ui::dialogs::XFilePicker2 > KDEXLib::createFilePicker(
         const uno::Reference< uno::XComponentContext >& xMSF )
 {
+#if HAVE_KDE4_NATIVE_FILE_PICKER
     if( qApp->thread() != QThread::currentThread()) {
         SalYieldMutexReleaser aReleaser;
         return Q_EMIT createFilePickerSignal( xMSF );
     }
     return uno::Reference< ui::dialogs::XFilePicker2 >( new KDE4FilePicker( xMSF ) );
+#else
+    return NULL;
+#endif
 }
 
 #define Region QtXRegion


More information about the Libreoffice-commits mailing list