|
|
95af89d |
From b0759366fc6cdda2db2f2cb4208df36c1b1fe8fc Mon Sep 17 00:00:00 2001
|
|
|
95af89d |
From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= <caolanm@redhat.com>
|
|
|
95af89d |
Date: Wed, 12 Sep 2012 13:44:09 +0100
|
|
|
95af89d |
Subject: [PATCH] Resolves: rhbz#855541 XIOError handler multithread woes
|
|
|
95af89d |
|
|
|
95af89d |
We have two threads using X, on an XIOError both
|
|
|
95af89d |
threads call their XIOError handlers and two
|
|
|
95af89d |
calls to exit trample all over eachother.
|
|
|
95af89d |
|
|
|
95af89d |
Change-Id: I20defc6f84cc6ea2372a0d6c979e8078fe920a88
|
|
|
95af89d |
---
|
|
|
95af89d |
vcl/unx/generic/app/saldata.cxx | 6 ++++++
|
|
|
95af89d |
vcl/unx/gtk/app/gtkdata.cxx | 14 ++++++++++++++
|
|
|
95af89d |
2 files changed, 20 insertions(+)
|
|
|
95af89d |
|
|
|
95af89d |
diff --git a/vcl/unx/generic/app/saldata.cxx b/vcl/unx/generic/app/saldata.cxx
|
|
|
95af89d |
index 1fb6a7a..0596dce 100644
|
|
|
95af89d |
--- a/vcl/unx/generic/app/saldata.cxx
|
|
|
95af89d |
+++ b/vcl/unx/generic/app/saldata.cxx
|
|
|
95af89d |
@@ -322,6 +322,12 @@ int X11SalData::XErrorHdl( Display *pDisplay, XErrorEvent *pEvent )
|
|
|
95af89d |
|
|
|
95af89d |
int X11SalData::XIOErrorHdl( Display * )
|
|
|
95af89d |
{
|
|
|
95af89d |
+ if (::osl::Thread::getCurrentIdentifier() != Application::GetMainThreadIdentifier())
|
|
|
95af89d |
+ {
|
|
|
95af89d |
+ pthread_exit(NULL);
|
|
|
95af89d |
+ return 0;
|
|
|
95af89d |
+ }
|
|
|
95af89d |
+
|
|
|
95af89d |
/* #106197# hack: until a real shutdown procedure exists
|
|
|
95af89d |
* _exit ASAP
|
|
|
95af89d |
*/
|
|
|
95af89d |
diff --git a/vcl/unx/gtk/app/gtkdata.cxx b/vcl/unx/gtk/app/gtkdata.cxx
|
|
|
95af89d |
index 8f3151c..867883f 100644
|
|
|
95af89d |
--- a/vcl/unx/gtk/app/gtkdata.cxx
|
|
|
95af89d |
+++ b/vcl/unx/gtk/app/gtkdata.cxx
|
|
|
95af89d |
@@ -526,6 +526,18 @@ GtkData::GtkData( SalInstance *pInstance )
|
|
|
95af89d |
m_aDispatchCondition = osl_createCondition();
|
|
|
95af89d |
}
|
|
|
95af89d |
|
|
|
95af89d |
+XIOErrorHandler aOrigXIOErrorHandler = NULL;
|
|
|
95af89d |
+
|
|
|
95af89d |
+int XIOErrorHdl(Display *pDisplay)
|
|
|
95af89d |
+{
|
|
|
95af89d |
+ if (::osl::Thread::getCurrentIdentifier() != Application::GetMainThreadIdentifier())
|
|
|
95af89d |
+ {
|
|
|
95af89d |
+ pthread_exit(NULL);
|
|
|
95af89d |
+ return 0;
|
|
|
95af89d |
+ }
|
|
|
95af89d |
+ return aOrigXIOErrorHandler ? aOrigXIOErrorHandler(pDisplay) : 0;
|
|
|
95af89d |
+}
|
|
|
95af89d |
+
|
|
|
95af89d |
GtkData::~GtkData()
|
|
|
95af89d |
{
|
|
|
95af89d |
Yield( true, true );
|
|
|
95af89d |
@@ -545,6 +557,7 @@ GtkData::~GtkData()
|
|
|
95af89d |
osl_destroyCondition( m_aDispatchCondition );
|
|
|
95af89d |
osl_releaseMutex( m_aDispatchMutex );
|
|
|
95af89d |
osl_destroyMutex( m_aDispatchMutex );
|
|
|
95af89d |
+ XSetIOErrorHandler(aOrigXIOErrorHandler);
|
|
|
95af89d |
}
|
|
|
95af89d |
|
|
|
95af89d |
void GtkData::Dispose()
|
|
|
95af89d |
@@ -664,6 +677,7 @@ void GtkData::Init()
|
|
|
95af89d |
// init gtk/gdk
|
|
|
95af89d |
gtk_init_check( &nParams, &pCmdLineAry );
|
|
|
95af89d |
gdk_error_trap_push();
|
|
|
95af89d |
+ aOrigXIOErrorHandler = XSetIOErrorHandler(XIOErrorHdl);
|
|
|
95af89d |
|
|
|
95af89d |
for (i = 0; i < nParams; i++ )
|
|
|
95af89d |
g_free( pCmdLineAry[i] );
|
|
|
95af89d |
--
|
|
|
95af89d |
1.7.11.4
|
|
|
95af89d |
|