summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorvjinoch <elianoss@gmail.com>2013-04-12 01:18:41 +0200
committerMichael Meeks <michael.meeks@suse.com>2013-04-12 13:41:12 +0100
commitbdc04c2e024a840a77fecadfbc7b09b8637a1d89 (patch)
treed46675ef2c7dbc3631b51701af98441192ab3ce6
parentRemove code marked by HORRIBLE_OBSOLETE_YIELDMUTEX_IMPL tag. (diff)
downloadcore-bdc04c2e024a840a77fecadfbc7b09b8637a1d89.tar.gz
core-bdc04c2e024a840a77fecadfbc7b09b8637a1d89.zip
Remove GtkHookedYieldMutex and some small changes.
Change-Id: Id84a5eaa4cea4c7cce9aa873c1a7c286e5d5cc92 Reviewed-on: https://gerrit.libreoffice.org/3349 Reviewed-by: Michael Meeks <michael.meeks@suse.com> Tested-by: Michael Meeks <michael.meeks@suse.com>
-rw-r--r--vcl/inc/unx/gtk/gtkinst.hxx32
-rw-r--r--vcl/unx/gtk/app/gtkinst.cxx108
2 files changed, 50 insertions, 90 deletions
diff --git a/vcl/inc/unx/gtk/gtkinst.hxx b/vcl/inc/unx/gtk/gtkinst.hxx
index 83ea84fc5f61..b8f530c498a0 100644
--- a/vcl/inc/unx/gtk/gtkinst.hxx
+++ b/vcl/inc/unx/gtk/gtkinst.hxx
@@ -39,13 +39,18 @@ class GenPspGraphics;
class GtkYieldMutex : public SalYieldMutex
{
public:
- GtkYieldMutex();
- virtual void acquire();
- virtual void release();
- virtual sal_Bool tryToAcquire();
+ GtkYieldMutex();
+ virtual void acquire();
+ virtual void release();
+ virtual sal_Bool tryToAcquire() { return SalYieldMutex::tryToAcquire(); }
- virtual int Grab();
- virtual void Ungrab( int );
+ virtual int Grab() { return 0; };
+ virtual void Ungrab(int ) {};
+
+ std::list<sal_uLong> aYieldStack;
+
+ void ThreadsEnter();
+ void ThreadsLeave();
class GtkYieldGuard
{
@@ -64,21 +69,6 @@ public:
};
};
-class GtkHookedYieldMutex : public GtkYieldMutex
-{
- virtual int Grab() { return 0; };
- virtual void Ungrab(int ) {};
- std::list<sal_uLong> aYieldStack;
-public:
- GtkHookedYieldMutex();
- virtual void acquire();
- virtual void release();
- virtual sal_Bool tryToAcquire() { return SalYieldMutex::tryToAcquire(); }
- void ThreadsEnter();
- void ThreadsLeave();
-};
-
-
#define GTK_YIELD_GRAB() GtkYieldMutex::GtkYieldGuard aLocalGtkYieldGuard( static_cast<GtkYieldMutex*>(GetSalData()->m_pInstance->GetYieldMutex()) )
class GtkSalTimer;
diff --git a/vcl/unx/gtk/app/gtkinst.cxx b/vcl/unx/gtk/app/gtkinst.cxx
index c920fda6e5a7..3bc4379a5caa 100644
--- a/vcl/unx/gtk/app/gtkinst.cxx
+++ b/vcl/unx/gtk/app/gtkinst.cxx
@@ -48,78 +48,29 @@
#include "gtkprintwrapper.hxx"
-GtkHookedYieldMutex::GtkHookedYieldMutex()
-{
-}
-
-/*
- * These methods always occur in pairs
- * A ThreadsEnter is followed by a ThreadsLeave
- * We need to queue up the recursive lock count
- * for each pair, so we can accurately restore
- * it later.
- */
-void GtkHookedYieldMutex::ThreadsEnter()
-{
- acquire();
- if( !aYieldStack.empty() )
- { /* Previously called ThreadsLeave() */
- sal_uLong nCount = aYieldStack.front();
- aYieldStack.pop_front();
- while( nCount-- > 1 )
- acquire();
- }
-}
-
-void GtkHookedYieldMutex::ThreadsLeave()
-{
- aYieldStack.push_front( mnCount );
-
-#if OSL_DEBUG_LEVEL > 1
- if( mnThreadId &&
- mnThreadId != osl::Thread::getCurrentIdentifier())
- fprintf( stderr, "\n\n--- A different thread owns the mutex ...---\n\n\n");
-#endif
-
- while( mnCount > 1 )
- release();
- release();
-}
-
-void GtkHookedYieldMutex::acquire()
-{
- SalYieldMutex::acquire();
-}
-
-void GtkHookedYieldMutex::release()
-{
- SalYieldMutex::release();
-}
-
extern "C"
{
- #define GET_YIELD_MUTEX() static_cast<GtkHookedYieldMutex*>(GetSalData()->m_pInstance->GetYieldMutex())
+ #define GET_YIELD_MUTEX() static_cast<GtkYieldMutex*>(GetSalData()->m_pInstance->GetYieldMutex())
static void GdkThreadsEnter( void )
{
- GtkHookedYieldMutex *pYieldMutex = GET_YIELD_MUTEX();
+ GtkYieldMutex *pYieldMutex = GET_YIELD_MUTEX();
pYieldMutex->ThreadsEnter();
}
static void GdkThreadsLeave( void )
{
- GtkHookedYieldMutex *pYieldMutex = GET_YIELD_MUTEX();
+ GtkYieldMutex *pYieldMutex = GET_YIELD_MUTEX();
pYieldMutex->ThreadsLeave();
}
- static bool hookLocks( oslModule pModule )
+ static bool hookLocks( void )
{
#if !GTK_CHECK_VERSION(2,4,0)
- g_error("no lock hooking!");
+#error No lock hooking!
#endif
gdk_threads_set_lock_functions (GdkThreadsEnter, GdkThreadsLeave);
#if OSL_DEBUG_LEVEL > 1
fprintf( stderr, "Hooked gdk threads locks\n" );
#endif
- (void)pModule;
return true;
}
@@ -130,6 +81,9 @@ extern "C"
(int) gtk_major_version, (int) gtk_minor_version,
(int) gtk_micro_version );
#endif
+ if( (int) gtk_major_version < 2 || ((int) gtk_major_version == 2 && (int) gtk_minor_version < 4))
+ g_warning("require a newer gtk than %d.%d for gdk_threads_set_lock_functions", (int) gtk_major_version, gtk_minor_version);
+ return NULL;
/* #i92121# workaround deadlocks in the X11 implementation
*/
static const char* pNoXInitThreads = getenv( "SAL_NO_XINITTHREADS" );
@@ -159,8 +113,8 @@ extern "C"
if ( !g_thread_supported() )
g_thread_init( NULL );
- if ( hookLocks( pModule ) )
- pYieldMutex = new GtkHookedYieldMutex();
+ if ( hookLocks() )
+ pYieldMutex = new GtkYieldMutex();
gdk_threads_init();
@@ -341,30 +295,46 @@ GtkYieldMutex::GtkYieldMutex()
void GtkYieldMutex::acquire()
{
- g_error ("never called");
+ SalYieldMutex::acquire();
}
void GtkYieldMutex::release()
{
- g_error ("never called");
+ SalYieldMutex::release();
}
-sal_Bool GtkYieldMutex::tryToAcquire()
+/*
+ * These methods always occur in pairs
+ * A ThreadsEnter is followed by a ThreadsLeave
+ * We need to queue up the recursive lock count
+ * for each pair, so we can accurately restore
+ * it later.
+ */
+void GtkYieldMutex::ThreadsEnter()
{
- g_error ("never called");
- return sal_True;
+ acquire();
+ if( !aYieldStack.empty() )
+ { /* Previously called ThreadsLeave() */
+ sal_uLong nCount = aYieldStack.front();
+ aYieldStack.pop_front();
+ while( nCount-- > 1 )
+ acquire();
+ }
}
-int GtkYieldMutex::Grab()
+void GtkYieldMutex::ThreadsLeave()
{
- g_error ("never called");
- return sal_True;
-}
+ aYieldStack.push_front( mnCount );
-void GtkYieldMutex::Ungrab( int nGrabs )
-{
- (void)nGrabs;
- g_error ("never called");
+#if OSL_DEBUG_LEVEL > 1
+ if( mnThreadId &&
+ mnThreadId != osl::Thread::getCurrentIdentifier())
+ fprintf( stderr, "\n\n--- A different thread owns the mutex ...---\n\n\n");
+#endif
+
+ while( mnCount > 1 )
+ release();
+ release();
}
SalVirtualDevice* GtkInstance::CreateVirtualDevice( SalGraphics *pG,