Date: prev next · Thread: first prev next last
2011 Archives by date, by thread · List index



        Fixes a potential crash on shutdown with gtk+ - prolly been there for
years, would love to have the attached cherry-picked to the
libreoffice-3-4 branch (but avoid 3.4.0).

        Thanks,

                Michael.

-- 
 michael.meeks@novell.com  <><, Pseudo Engineer, itinerant idiot

From 7ce1bf0cc4913727c2692bfd1b20fcd497ddcf37 Mon Sep 17 00:00:00 2001
From: Michael Meeks <michael.meeks@novell.com>
Date: Wed, 18 May 2011 06:21:50 +0100
Subject: [PATCH] fix gtk FMR on shutdown - fdo#37302

---
 vcl/unx/gtk/app/gtkdata.cxx         |   38 ++++++++++++++++++----------------
 vcl/unx/inc/plugins/gtk/gtkdata.hxx |    5 +--
 2 files changed, 22 insertions(+), 21 deletions(-)

diff --git a/vcl/unx/gtk/app/gtkdata.cxx b/vcl/unx/gtk/app/gtkdata.cxx
index 2694025..a246371 100644
--- a/vcl/unx/gtk/app/gtkdata.cxx
+++ b/vcl/unx/gtk/app/gtkdata.cxx
@@ -71,6 +71,15 @@ using ::rtl::OUString;
 /***************************************************************************
  * class GtkDisplay                                                        *
  ***************************************************************************/
+extern "C" {
+GdkFilterReturn call_filterGdkEvent( GdkXEvent* sys_event,
+                                     GdkEvent* event,
+                                     gpointer data )
+{
+    GtkSalDisplay *pDisplay = (GtkSalDisplay *)data;
+    return pDisplay->filterGdkEvent( sys_event, event );
+}
+}
 
 GtkSalDisplay::GtkSalDisplay( GdkDisplay* pDisplay )
             : SalDisplay( gdk_x11_display_get_xdisplay( pDisplay ) ),
@@ -81,10 +90,14 @@ GtkSalDisplay::GtkSalDisplay( GdkDisplay* pDisplay )
     for(int i = 0; i < POINTER_COUNT; i++)
         m_aCursors[ i ] = NULL;
     Init ();
+
+    gdk_window_add_filter( NULL, call_filterGdkEvent, this );
 }
 
 GtkSalDisplay::~GtkSalDisplay()
 {
+    gdk_window_remove_filter( NULL, call_filterGdkEvent, this );
+
     if( !m_bStartupCompleted )
         gdk_notify_startup_complete();
     doDestruct();
@@ -107,12 +120,6 @@ void GtkSalDisplay::deregisterFrame( SalFrame* pFrame )
 }
 
 extern "C" {
-GdkFilterReturn call_filterGdkEvent( GdkXEvent* sys_event,
-                                     GdkEvent* event,
-                                     gpointer data )
-{
-    return GtkSalDisplay::filterGdkEvent( sys_event, event, data );
-}
 
 void signalKeysChanged( GdkKeymap*, gpointer data )
 {
@@ -135,13 +142,10 @@ void signalMonitorsChanged( GdkScreen* pScreen, gpointer data )
 }
 
 GdkFilterReturn GtkSalDisplay::filterGdkEvent( GdkXEvent* sys_event,
-                                               GdkEvent*,
-                                               gpointer data )
+                                               GdkEvent* )
 {
     GdkFilterReturn aFilterReturn = GDK_FILTER_CONTINUE;
-
     XEvent *pEvent = (XEvent *)sys_event;
-    GtkSalDisplay *pDisplay = (GtkSalDisplay *)data;
 
     // dispatch all XEvents to event callback
     if( GetSalData()->m_pInstance->
@@ -150,7 +154,7 @@ GdkFilterReturn GtkSalDisplay::filterGdkEvent( GdkXEvent* sys_event,
 
     GTK_YIELD_GRAB();
 
-    if (pDisplay->GetDisplay() == pEvent->xany.display )
+    if (GetDisplay() == pEvent->xany.display )
     {
         // #i53471# gtk has no callback mechanism that lets us be notified
         // when settings (as in XSETTING and opposed to styles) are changed.
@@ -158,16 +162,16 @@ GdkFilterReturn GtkSalDisplay::filterGdkEvent( GdkXEvent* sys_event,
         // these should be rare enough so that we can assume that the settings
         // actually change when a corresponding PropertyNotify occurs
         if( pEvent->type == PropertyNotify &&
-            pEvent->xproperty.atom == pDisplay->getWMAdaptor()->getAtom( WMAdaptor::XSETTINGS ) &&
-            ! pDisplay->m_aFrames.empty()
+            pEvent->xproperty.atom == getWMAdaptor()->getAtom( WMAdaptor::XSETTINGS ) &&
+            ! m_aFrames.empty()
            )
         {
-            pDisplay->SendInternalEvent( pDisplay->m_aFrames.front(), NULL, 
SALEVENT_SETTINGSCHANGED );
+            SendInternalEvent( m_aFrames.front(), NULL, SALEVENT_SETTINGSCHANGED );
         }
         // let's see if one of our frames wants to swallow these events
         // get the frame
-        for( std::list< SalFrame* >::const_iterator it = pDisplay->m_aFrames.begin();
-                 it != pDisplay->m_aFrames.end(); ++it )
+        for( std::list< SalFrame* >::const_iterator it = m_aFrames.begin();
+                 it != m_aFrames.end(); ++it )
         {
             GtkSalFrame* pFrame = static_cast<GtkSalFrame*>(*it);
             if( (GdkNativeWindow)pFrame->GetSystemData()->aWindow == pEvent->xany.window ||
@@ -683,8 +687,6 @@ void GtkXLib::Init()
 
     m_pGtkSalDisplay = new GtkSalDisplay( pGdkDisp );
 
-    gdk_window_add_filter( NULL, call_filterGdkEvent, m_pGtkSalDisplay );
-
     PushXErrorLevel( true );
     SalI18N_KeyboardExtension *pKbdExtension = new SalI18N_KeyboardExtension( pDisp );
     XSync( pDisp, False );
diff --git a/vcl/unx/inc/plugins/gtk/gtkdata.hxx b/vcl/unx/inc/plugins/gtk/gtkdata.hxx
index 90bc80a..93443f9 100644
--- a/vcl/unx/inc/plugins/gtk/gtkdata.hxx
+++ b/vcl/unx/inc/plugins/gtk/gtkdata.hxx
@@ -78,9 +78,8 @@ public:
 
     virtual int GetDefaultMonitorNumber() const;
 
-    static GdkFilterReturn filterGdkEvent( GdkXEvent* sys_event,
-                                           GdkEvent* event,
-                                           gpointer data );
+    GdkFilterReturn filterGdkEvent( GdkXEvent* sys_event,
+                                    GdkEvent* event );
     inline bool HasMoreEvents()     { return m_aUserEvents.size() > 1; }
     inline void EventGuardAcquire() { osl_acquireMutex( hEventGuard_ ); }
     inline void EventGuardRelease() { osl_releaseMutex( hEventGuard_ ); }
-- 
1.7.3.4


Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.