Hi,
I have submitted a patch for review:
https://gerrit.libreoffice.org/3349
To pull it, you can do:
git pull ssh://gerrit.libreoffice.org:29418/core refs/changes/49/3349/1
Remove GtkHookedYieldMutex and some small changes.
Change-Id: Id84a5eaa4cea4c7cce9aa873c1a7c286e5d5cc92
---
M vcl/inc/unx/gtk/gtkinst.hxx
M vcl/unx/gtk/app/gtkinst.cxx
2 files changed, 50 insertions(+), 90 deletions(-)
diff --git a/vcl/inc/unx/gtk/gtkinst.hxx b/vcl/inc/unx/gtk/gtkinst.hxx
index 4ad13a6..a163633 100644
--- a/vcl/inc/unx/gtk/gtkinst.hxx
+++ b/vcl/inc/unx/gtk/gtkinst.hxx
@@ -39,13 +39,18 @@
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
{
@@ -63,21 +68,6 @@
}
};
};
-
-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()) )
diff --git a/vcl/unx/gtk/app/gtkinst.cxx b/vcl/unx/gtk/app/gtkinst.cxx
index 678c8ed..b221202 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 @@
(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 @@
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 @@
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,
--
To view, visit https://gerrit.libreoffice.org/3349
To unsubscribe, visit https://gerrit.libreoffice.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Id84a5eaa4cea4c7cce9aa873c1a7c286e5d5cc92
Gerrit-PatchSet: 1
Gerrit-Project: core
Gerrit-Branch: master
Gerrit-Owner: Vlastimil Jinoch <elianoss@gmail.com>
Context
- [PATCH] Remove GtkHookedYieldMutex and some small changes. · Vlastimil Jinoch (via Code Review)
Privacy Policy |
Impressum (Legal Info) |
Copyright information: Unless otherwise specified, all text and images
on this website are licensed under the
Creative Commons Attribution-Share Alike 3.0 License.
This does not include the source code of LibreOffice, which is
licensed under the Mozilla Public License (
MPLv2).
"LibreOffice" and "The Document Foundation" are
registered trademarks of their corresponding registered owners or are
in actual use as trademarks in one or more countries. Their respective
logos and icons are also subject to international copyright laws. Use
thereof is explained in our
trademark policy.