From 1b20ed98b65a9101162058a54c2d62eea8664b11 Mon Sep 17 00:00:00 2001 From: Noel Power Date: Mon, 14 Nov 2011 11:17:07 +0000 Subject: fix crash at exit ( access of deleted GtkSalDisplay instance ) bnc#728603 Signed-off-by: Michael Meeks --- vcl/unx/gtk/app/gtkdata.cxx | 44 +++++++++++++++++++++++++++++--------------- 1 file changed, 29 insertions(+), 15 deletions(-) diff --git a/vcl/unx/gtk/app/gtkdata.cxx b/vcl/unx/gtk/app/gtkdata.cxx index 6a61098b98..a1c8b2fce1 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(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; } -- cgit v1.2.3