diff options
author | Caolán McNamara <caolanm@redhat.com> | 2012-09-12 13:44:09 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2012-09-12 14:01:24 +0100 |
commit | b0759366fc6cdda2db2f2cb4208df36c1b1fe8fc (patch) | |
tree | 3319da90d373f3228fdc7829267517c456dea137 /vcl/unx | |
parent | 4597483e00bffcc4e30d379dcf6fad42bc565e56 (diff) |
Resolves: rhbz#855541 XIOError handler multithread woes
We have two threads using X, on an XIOError both
threads call their XIOError handlers and two
calls to exit trample all over eachother.
Change-Id: I20defc6f84cc6ea2372a0d6c979e8078fe920a88
Diffstat (limited to 'vcl/unx')
-rw-r--r-- | vcl/unx/generic/app/saldata.cxx | 6 | ||||
-rw-r--r-- | vcl/unx/gtk/app/gtkdata.cxx | 14 |
2 files changed, 20 insertions, 0 deletions
diff --git a/vcl/unx/generic/app/saldata.cxx b/vcl/unx/generic/app/saldata.cxx index 1fb6a7a8f980..0596dce454d7 100644 --- a/vcl/unx/generic/app/saldata.cxx +++ b/vcl/unx/generic/app/saldata.cxx @@ -322,6 +322,12 @@ int X11SalData::XErrorHdl( Display *pDisplay, XErrorEvent *pEvent ) int X11SalData::XIOErrorHdl( Display * ) { + if (::osl::Thread::getCurrentIdentifier() != Application::GetMainThreadIdentifier()) + { + pthread_exit(NULL); + return 0; + } + /* #106197# hack: until a real shutdown procedure exists * _exit ASAP */ diff --git a/vcl/unx/gtk/app/gtkdata.cxx b/vcl/unx/gtk/app/gtkdata.cxx index 8f3151cef2c6..867883f410ea 100644 --- a/vcl/unx/gtk/app/gtkdata.cxx +++ b/vcl/unx/gtk/app/gtkdata.cxx @@ -526,6 +526,18 @@ GtkData::GtkData( SalInstance *pInstance ) m_aDispatchCondition = osl_createCondition(); } +XIOErrorHandler aOrigXIOErrorHandler = NULL; + +int XIOErrorHdl(Display *pDisplay) +{ + if (::osl::Thread::getCurrentIdentifier() != Application::GetMainThreadIdentifier()) + { + pthread_exit(NULL); + return 0; + } + return aOrigXIOErrorHandler ? aOrigXIOErrorHandler(pDisplay) : 0; +} + GtkData::~GtkData() { Yield( true, true ); @@ -545,6 +557,7 @@ GtkData::~GtkData() osl_destroyCondition( m_aDispatchCondition ); osl_releaseMutex( m_aDispatchMutex ); osl_destroyMutex( m_aDispatchMutex ); + XSetIOErrorHandler(aOrigXIOErrorHandler); } void GtkData::Dispose() @@ -664,6 +677,7 @@ void GtkData::Init() // init gtk/gdk gtk_init_check( &nParams, &pCmdLineAry ); gdk_error_trap_push(); + aOrigXIOErrorHandler = XSetIOErrorHandler(XIOErrorHdl); for (i = 0; i < nParams; i++ ) g_free( pCmdLineAry[i] ); |