[Libreoffice-commits] .: Branch 'libreoffice-3-4-4' - vcl/unx

Noel Power noelp at kemper.freedesktop.org
Mon Nov 14 03:21:01 PST 2011


 vcl/unx/gtk/app/gtkdata.cxx |   44 +++++++++++++++++++++++++++++---------------
 1 file changed, 29 insertions(+), 15 deletions(-)

New commits:
commit cdb2e8c531efd22420d8e5df91841bf881f28a7f
Author: Noel Power <noel.power at novell.com>
Date:   Mon Nov 14 11:17:07 2011 +0000

    fix crash at exit ( access of deleted GtkSalDisplay instance ) bnc#728603
    
    Signed-off-by: Michael Meeks <michael.meeks at suse.com>

diff --git a/vcl/unx/gtk/app/gtkdata.cxx b/vcl/unx/gtk/app/gtkdata.cxx
index 6a61098..a1c8b2f 100644
--- a/vcl/unx/gtk/app/gtkdata.cxx
+++ b/vcl/unx/gtk/app/gtkdata.cxx
@@ -576,6 +576,14 @@ GtkXLib::~GtkXLib()
 #endif
     Yield( true, true );
     StopTimer();
+
+    if (m_pUserEvent)
+    {
+        g_source_destroy (m_pUserEvent);
+        g_source_unref (m_pUserEvent);
+        m_pUserEvent = NULL;
+    }
+
      // sanity check: at this point nobody should be yielding, but wake them
      // up anyway before the condition they're waiting on gets destroyed.
     osl_setCondition( m_aDispatchCondition );
@@ -792,30 +800,36 @@ extern "C"
 
 gboolean GtkXLib::userEventFn(gpointer data)
 {
-    gboolean bContinue;
+
+    gboolean bContinue = FALSE;
     GtkXLib *pThis = (GtkXLib *) data;
-    SalData *pSalData = GetSalData();
 
-    pSalData->m_pInstance->GetYieldMutex()->acquire();
-    pThis->m_pGtkSalDisplay->EventGuardAcquire();
+    GtkData *pGtkData = static_cast<GtkData*>(GetSalData());
+
+    pGtkData->m_pInstance->GetYieldMutex()->acquire();
 
-    if( !pThis->m_pGtkSalDisplay->HasMoreEvents() )
+    if ( pGtkData->GetDisplay() )
     {
-        if( pThis->m_pUserEvent )
+        pThis->m_pGtkSalDisplay->EventGuardAcquire();
+
+        if( !pThis->m_pGtkSalDisplay->HasMoreEvents() )
         {
-            g_source_unref (pThis->m_pUserEvent);
-            pThis->m_pUserEvent = NULL;
+            if( pThis->m_pUserEvent )
+            {
+                g_source_unref (pThis->m_pUserEvent);
+                pThis->m_pUserEvent = NULL;
+            }
+            bContinue = FALSE;
         }
-        bContinue = FALSE;
-    }
-    else
-        bContinue = TRUE;
+        else
+            bContinue = TRUE;
 
-    pThis->m_pGtkSalDisplay->EventGuardRelease();
+        pThis->m_pGtkSalDisplay->EventGuardRelease();
 
-    pThis->m_pGtkSalDisplay->DispatchInternalEvent();
+        pThis->m_pGtkSalDisplay->DispatchInternalEvent();
 
-    pSalData->m_pInstance->GetYieldMutex()->release();
+        pGtkData->m_pInstance->GetYieldMutex()->release();
+    }
 
     return bContinue;
 }


More information about the Libreoffice-commits mailing list