sd/Library_sd.mk | 1 sd/inc/slidehack.hxx | 1 sd/source/core/slidehack.cxx | 50 ++++++ sd/source/ui/dlg/GroupSlidesDialog.cxx | 28 ++- sd/source/ui/dlg/GroupSlidesDialog.hxx | 5 sd/uiconfig/simpress/ui/groupslides.ui | 27 +-- vcl/inc/unx/gtk/gtkinst.hxx | 31 +--- vcl/unx/gtk/app/gtkinst.cxx | 245 +++++---------------------------- 8 files changed, 144 insertions(+), 244 deletions(-)
New commits: commit 9f4dd110ee3f519bda1205297df754b94428ca73 Author: Michael Meeks <michael.me...@suse.com> Date: Fri Apr 12 13:40:41 2013 +0100 Impl. more of the group dialog. Change-Id: Iaa0636087c22380c8a29d9c9b73d177cda453ea5 diff --git a/sd/Library_sd.mk b/sd/Library_sd.mk index d1d15b8..d4800bd 100644 --- a/sd/Library_sd.mk +++ b/sd/Library_sd.mk @@ -147,6 +147,7 @@ $(eval $(call gb_Library_add_exception_objects,sd,\ sd/source/core/sdpage2 \ sd/source/core/sdpage_animations \ sd/source/core/shapelist \ + sd/source/core/slidehack \ sd/source/core/stlfamily \ sd/source/core/stlpool \ sd/source/core/stlsheet \ diff --git a/sd/inc/slidehack.hxx b/sd/inc/slidehack.hxx index 70ba47a..ce724ea 100644 --- a/sd/inc/slidehack.hxx +++ b/sd/inc/slidehack.hxx @@ -154,6 +154,7 @@ public: /// check for updated versions etc. virtual GroupPtr lookupGroup( OriginPtr pOrigin ) = 0; virtual GroupPtr createGroup( const OUString &rName, + const OUString &rTitle, const OUString &rKeywords, const std::vector< SdPage * > &rPages ) = 0; diff --git a/sd/source/core/slidehack.cxx b/sd/source/core/slidehack.cxx new file mode 100644 index 0000000..cdf251c --- /dev/null +++ b/sd/source/core/slidehack.cxx @@ -0,0 +1,50 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* +* This file is part of the LibreOffice project. +* +* This Source Code Form is subject to the terms of the Mozilla Public +* License, v. 2.0. If a copy of the MPL was not distributed with this +* file, You can obtain one at http://mozilla.org/MPL/2.0/. +*/ + +#include "slidehack.hxx" + +namespace SlideHack { +namespace { + +class ImplStore : public Store { +public: + ImplStore(); + + virtual sal_uInt32 search( OUString aSearchEntry ) + { + // queue maSearchCompleted at idle ... + return 0; + } + virtual void cancelSearch( sal_uInt32 nHandle ) { (void) nHandle; } + + /// used to create a group handle from a stored slide, so we can + /// check for updated versions etc. + virtual GroupPtr lookupGroup( OriginPtr pOrigin ) + { + return GroupPtr(); + } + virtual GroupPtr createGroup( const OUString &rName, + const OUString &rTitle, + const OUString &rKeywords, + const std::vector< SdPage * > &rPages ) + { + return GroupPtr(); + } +}; + +} // end anonymous namespace + +StorePtr Store::getStore() +{ + return StorePtr( new ImplStore() ); +} + +} // end SlideHack namespace + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sd/source/ui/dlg/GroupSlidesDialog.cxx b/sd/source/ui/dlg/GroupSlidesDialog.cxx index a396913..9117a5c 100644 --- a/sd/source/ui/dlg/GroupSlidesDialog.cxx +++ b/sd/source/ui/dlg/GroupSlidesDialog.cxx @@ -29,9 +29,11 @@ namespace { } } -void SdGroupSlidesDialog::addGroupsToCombo( ComboBox *pBox, SdDrawDocument *pDoc ) +void SdGroupSlidesDialog::addGroupsToCombo( ComboBox /* *pBox, */ SdDrawDocument *pDoc ) { +#if 0 mpGroupCombo->Clear(); +#endif sal_uInt32 nPages = pDoc->GetSdPageCount( PK_STANDARD ); StorePtr pStore = SlideHack::Store::getStore(); @@ -48,7 +50,11 @@ void SdGroupSlidesDialog::addGroupsToCombo( ComboBox *pBox, SdDrawDocument *pDoc if ( std::find( maGroups.begin(), maGroups.end(), pGroup ) != maGroups.end() ) continue; maGroups.push_back( pGroup ); +#if 0 + // FIXME: we want a widget that does something like this - + // an Autocomplete hdl on an Edit ? or ... mpGroupCombo->InsertEntry( pGroup->getMetaData()->getName() ); +#endif } } @@ -60,17 +66,18 @@ SdGroupSlidesDialog::SdGroupSlidesDialog(Window* pWindow, SdDrawDocument* pActDo { get( mpAddBtn, "add_btn" ); get( mpCancelBtn, "cancel_btn" ); - get( mpGroupCombo, "cb_group" ); +// get( mpGroupCombo, "cb_group" ); + get( mpGroupEdit, "ed_group" ); get( mpTitle, "ed_title" ); get( mpKeywords, "ed_keywords" ); mpAddBtn->SetClickHdl( LINK( this, SdGroupSlidesDialog, AddHdl ) ); mpCancelBtn->SetClickHdl( LINK( this, SdGroupSlidesDialog, CancelHdl ) ); - addGroupsToCombo( mpGroupCombo, mpDoc ); - mpGroupCombo->SetSelectHdl( LINK( this, SdGroupSlidesDialog, GroupSelectHdl ) ); - mpGroupCombo->SetDoubleClickHdl( LINK( this, SdGroupSlidesDialog, GroupDoubleClickHdl ) ); - mpGroupCombo->EnableAutocomplete( true ); +// addGroupsToCombo( mpGroupCombo, mpDoc ); +// mpGroupCombo->SetSelectHdl( LINK( this, SdGroupSlidesDialog, GroupSelectHdl ) ); +// mpGroupCombo->SetDoubleClickHdl( LINK( this, SdGroupSlidesDialog, GroupDoubleClickHdl ) ); +// mpGroupCombo->EnableAutocomplete( true ); } SdGroupSlidesDialog::~SdGroupSlidesDialog() @@ -88,6 +95,12 @@ int SdGroupSlidesDialog::endDialog( bool bSuccessSoSave ) { if ( bSuccessSoSave ) { + // FIXME: input validation + SlideHack::Store::getStore()->createGroup( mpGroupEdit->GetText(), + mpTitle->GetText(), + mpKeywords->GetText(), + maPages ); +#if 0 sal_uInt16 nSelected = mpGroupCombo->GetSelectEntryPos(); SAL_DEBUG("complete: " << (int) nSelected ); if ( nSelected < maGroups.size() ) @@ -98,6 +111,7 @@ int SdGroupSlidesDialog::endDialog( bool bSuccessSoSave ) { SAL_DEBUG("new group"); } +#endif } EndDialog(0); @@ -116,6 +130,7 @@ IMPL_LINK_NOARG( SdGroupSlidesDialog, CancelHdl ) return endDialog( false ) ; } +#if 0 IMPL_LINK_NOARG( SdGroupSlidesDialog, GroupSelectHdl ) { sal_uInt16 nSelected = mpGroupCombo->GetSelectEntryPos(); @@ -130,6 +145,7 @@ IMPL_LINK_NOARG( SdGroupSlidesDialog, GroupDoubleClickHdl ) GroupSelectHdl( 0 ); return endDialog( true ) ; } +#endif } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sd/source/ui/dlg/GroupSlidesDialog.hxx b/sd/source/ui/dlg/GroupSlidesDialog.hxx index bf2ce35..3e347a9 100644 --- a/sd/source/ui/dlg/GroupSlidesDialog.hxx +++ b/sd/source/ui/dlg/GroupSlidesDialog.hxx @@ -51,7 +51,8 @@ private: CancelButton *mpCancelBtn; PushButton *mpAddBtn; - ComboBox* mpGroupCombo; +// ComboBox* mpGroupCombo; + Edit *mpGroupEdit; std::vector< SlideHack::GroupPtr > maGroups; void addGroupsToCombo( ComboBox *pBox, SdDrawDocument *pDoc ); @@ -60,8 +61,10 @@ private: DECL_LINK( AddHdl, void* ); DECL_LINK( CancelHdl, void* ); +#if 0 DECL_LINK( GroupSelectHdl, void* ); DECL_LINK( GroupDoubleClickHdl, void* ); +#endif int endDialog( bool bSuccessSoSave ); void populateEdits( SlideHack::GroupPtr pGroup ); diff --git a/sd/uiconfig/simpress/ui/groupslides.ui b/sd/uiconfig/simpress/ui/groupslides.ui index 9b87ab2..b2d4853 100644 --- a/sd/uiconfig/simpress/ui/groupslides.ui +++ b/sd/uiconfig/simpress/ui/groupslides.ui @@ -112,19 +112,6 @@ </packing> </child> <child> - <object class="GtkComboBoxText" id="cb_group"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="hexpand">True</property> - </object> - <packing> - <property name="left_attach">1</property> - <property name="top_attach">0</property> - <property name="width">1</property> - <property name="height">1</property> - </packing> - </child> - <child> <object class="GtkLabel" id="label3"> <property name="visible">True</property> <property name="can_focus">False</property> @@ -175,6 +162,20 @@ <child> <placeholder/> </child> + <child> + <object class="GtkEntry" id="ed_group"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="invisible_char">â</property> + <property name="placeholder_text"><enter a name for your slide group></property> + </object> + <packing> + <property name="left_attach">1</property> + <property name="top_attach">0</property> + <property name="width">1</property> + <property name="height">1</property> + </packing> + </child> </object> </child> </object> commit 52bce36051efc35b1c7e30b7e7fcb136239497a4 Author: Michael Meeks <michael.me...@suse.com> Date: Fri Apr 12 11:06:30 2013 +0100 fdo#60690 - a little more cleanup of gtk+ mutex bits. Change-Id: I020d6f59751aef0bfb06667317ddcaf2965395d1 diff --git a/vcl/inc/unx/gtk/gtkinst.hxx b/vcl/inc/unx/gtk/gtkinst.hxx index b8f530c..eb65318 100644 --- a/vcl/inc/unx/gtk/gtkinst.hxx +++ b/vcl/inc/unx/gtk/gtkinst.hxx @@ -38,6 +38,7 @@ class GtkPrintWrapper; class GenPspGraphics; class GtkYieldMutex : public SalYieldMutex { + std::list<sal_uLong> aYieldStack; public: GtkYieldMutex(); virtual void acquire(); @@ -47,8 +48,6 @@ public: virtual int Grab() { return 0; }; virtual void Ungrab(int ) {}; - std::list<sal_uLong> aYieldStack; - void ThreadsEnter(); void ThreadsLeave(); diff --git a/vcl/unx/gtk/app/gtkinst.cxx b/vcl/unx/gtk/app/gtkinst.cxx index af80678..1bb4bed 100644 --- a/vcl/unx/gtk/app/gtkinst.cxx +++ b/vcl/unx/gtk/app/gtkinst.cxx @@ -61,18 +61,6 @@ extern "C" GtkYieldMutex *pYieldMutex = GET_YIELD_MUTEX(); pYieldMutex->ThreadsLeave(); } - static bool hookLocks( void ) - { -#if !GTK_CHECK_VERSION(2,4,0) -#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 - return true; - } VCLPLUG_GTK_PUBLIC SalInstance* create_SalInstance( oslModule ) { @@ -113,8 +101,16 @@ extern "C" if ( !g_thread_supported() ) g_thread_init( NULL ); - if ( hookLocks() ) - pYieldMutex = new GtkYieldMutex(); +#if !GTK_CHECK_VERSION(2,4,0) +#error "Requires gtk 2.4.0+ for lock hooking" +#endif + gdk_threads_set_lock_functions (GdkThreadsEnter, GdkThreadsLeave); + +#if OSL_DEBUG_LEVEL > 1 + fprintf( stderr, "Hooked gdk threads locks\n" ); +#endif + + pYieldMutex = new GtkYieldMutex(); gdk_threads_init(); commit 73c96cce032b7a55b2f6d724661d811c5e751b65 Author: Stephan Bergmann <sberg...@redhat.com> Date: Fri Apr 12 11:51:08 2013 +0200 -Werror=unused Change-Id: Icab9990a1e4bcbd709f63cb5ef24358441cced8d diff --git a/vcl/unx/gtk/app/gtkinst.cxx b/vcl/unx/gtk/app/gtkinst.cxx index 3bc4379..af80678 100644 --- a/vcl/unx/gtk/app/gtkinst.cxx +++ b/vcl/unx/gtk/app/gtkinst.cxx @@ -74,7 +74,7 @@ extern "C" return true; } - VCLPLUG_GTK_PUBLIC SalInstance* create_SalInstance( oslModule pModule ) + VCLPLUG_GTK_PUBLIC SalInstance* create_SalInstance( oslModule ) { #if OSL_DEBUG_LEVEL > 1 fprintf( stderr, "create vcl plugin instance with gtk version %d %d %d\n", @@ -255,15 +255,6 @@ void GtkInstance::AddToRecentDocumentList(const OUString& rFileUrl, const OUStri #endif } -/* - * Obsolete, non-working, and crufty code from the - * beginning of time. When we update our base platform - * we should kill this with extreme prejudice. - */ -#if !GTK_CHECK_VERSION(3,0,0) -# define HORRIBLE_OBSOLETE_YIELDMUTEX_IMPL -#endif - SalInfoPrinter* GtkInstance::CreateInfoPrinter( SalPrinterQueueInfo* pQueueInfo, ImplJobSetup* pSetupData ) { commit bdc04c2e024a840a77fecadfbc7b09b8637a1d89 Author: vjinoch <elian...@gmail.com> Date: Fri Apr 12 01:18:41 2013 +0200 Remove GtkHookedYieldMutex and some small changes. Change-Id: Id84a5eaa4cea4c7cce9aa873c1a7c286e5d5cc92 Reviewed-on: https://gerrit.libreoffice.org/3349 Reviewed-by: Michael Meeks <michael.me...@suse.com> Tested-by: Michael Meeks <michael.me...@suse.com> diff --git a/vcl/inc/unx/gtk/gtkinst.hxx b/vcl/inc/unx/gtk/gtkinst.hxx index 83ea84f..b8f530c 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 c920fda..3bc4379 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, commit abd519f347312cbe5dc5ab9c50e9d5388f912070 Author: vjinoch <elian...@gmail.com> Date: Tue Apr 9 18:06:36 2013 +0200 Remove code marked by HORRIBLE_OBSOLETE_YIELDMUTEX_IMPL tag. Change-Id: Ib87e3a5155176a6ce0531e04b08a2731a9c956a7 Reviewed-on: https://gerrit.libreoffice.org/3289 Reviewed-by: Michael Meeks <michael.me...@suse.com> Tested-by: Michael Meeks <michael.me...@suse.com> diff --git a/vcl/unx/gtk/app/gtkinst.cxx b/vcl/unx/gtk/app/gtkinst.cxx index 554c26c..c920fda 100644 --- a/vcl/unx/gtk/app/gtkinst.cxx +++ b/vcl/unx/gtk/app/gtkinst.cxx @@ -111,22 +111,15 @@ extern "C" } static bool hookLocks( oslModule pModule ) { - typedef void (*GdkLockFn) (GCallback enter_fn, GCallback leave_fn); - - GdkLockFn gdk_threads_set_lock_functions = - (GdkLockFn) osl_getAsciiFunctionSymbol( pModule, "gdk_threads_set_lock_functions" ); - if ( !gdk_threads_set_lock_functions ) - { -#if OSL_DEBUG_LEVEL > 1 - fprintf( stderr, "Failed to hook gdk threads locks\n" ); +#if !GTK_CHECK_VERSION(2,4,0) + g_error("no lock hooking!"); #endif - return false; - } - gdk_threads_set_lock_functions (GdkThreadsEnter, GdkThreadsLeave); + #if OSL_DEBUG_LEVEL > 1 fprintf( stderr, "Hooked gdk threads locks\n" ); #endif + (void)pModule; return true; } @@ -168,12 +161,6 @@ extern "C" if ( hookLocks( pModule ) ) pYieldMutex = new GtkHookedYieldMutex(); - else -#if GTK_CHECK_VERSION(3,0,0) - g_error ("impossible case for gtk3"); -#else - pYieldMutex = new GtkYieldMutex(); -#endif gdk_threads_init(); @@ -354,135 +341,30 @@ GtkYieldMutex::GtkYieldMutex() void GtkYieldMutex::acquire() { -#ifdef HORRIBLE_OBSOLETE_YIELDMUTEX_IMPL - oslThreadIdentifier aCurrentThread = osl::Thread::getCurrentIdentifier(); - // protect member manipulation - SolarMutexObject::acquire(); - if( mnCount > 0 && mnThreadId == aCurrentThread ) - { - mnCount++; - SolarMutexObject::release(); - return; - } - SolarMutexObject::release(); - - // obtain gdk mutex - gdk_threads_enter(); - - // obtained gdk mutex, now lock count is one by definition - SolarMutexObject::acquire(); - mnCount = 1; - mnThreadId = aCurrentThread; - SolarMutexObject::release(); -#else g_error ("never called"); -#endif } void GtkYieldMutex::release() { -#ifdef HORRIBLE_OBSOLETE_YIELDMUTEX_IMPL - oslThreadIdentifier aCurrentThread = osl::Thread::getCurrentIdentifier(); - // protect member manipulation - SolarMutexObject::acquire(); - // strange things happen, do nothing if we don't own the mutex - if( mnThreadId == aCurrentThread ) - { - mnCount--; - if( mnCount == 0 ) - { - gdk_threads_leave(); - mnThreadId = 0; - } - } - SolarMutexObject::release(); -#else g_error ("never called"); -#endif } sal_Bool GtkYieldMutex::tryToAcquire() { -#ifdef HORRIBLE_OBSOLETE_YIELDMUTEX_IMPL - oslThreadIdentifier aCurrentThread = osl::Thread::getCurrentIdentifier(); - // protect member manipulation - SolarMutexObject::acquire(); - if( mnCount > 0 ) - { - if( mnThreadId == aCurrentThread ) - { - mnCount++; - SolarMutexObject::release(); - return sal_True; - } - else - { - SolarMutexObject::release(); - return sal_False; - } - } - SolarMutexObject::release(); - - // HACK: gdk_threads_mutex is private, we shouldn't use it. - // how to we do a try_lock without having a gdk_threads_try_enter ? - if( ! g_mutex_trylock( gdk_threads_mutex ) ) - return sal_False; - - // obtained gdk mutex, now lock count is one by definition - SolarMutexObject::acquire(); - mnCount = 1; - mnThreadId = aCurrentThread; - SolarMutexObject::release(); - -#else g_error ("never called"); -#endif return sal_True; } int GtkYieldMutex::Grab() { -#ifdef HORRIBLE_OBSOLETE_YIELDMUTEX_IMPL - // this MUST only be called by gdk/gtk callbacks: - // they are entered with gdk mutex locked; the mutex - // was unlocked by GtkYieldMutex befor yielding which - // is now locked again by gtk implicitly - - // obtained gdk mutex, now lock count is one by definition - SolarMutexObject::acquire(); - int nRet = mnCount; - if( mnCount == 0 ) // recursive else - mnThreadId = osl::Thread::getCurrentIdentifier(); -#if OSL_DEBUG_LEVEL > 1 - else if( mnThreadId != osl::Thread::getCurrentIdentifier() ) - { - fprintf( stderr, "Yield mutex grabbed in different thread !\n" ); - abort(); - } -#endif - mnCount = 1; - SolarMutexObject::release(); - return nRet; -#else g_error ("never called"); return sal_True; -#endif } void GtkYieldMutex::Ungrab( int nGrabs ) { -#ifdef HORRIBLE_OBSOLETE_YIELDMUTEX_IMPL - // this MUST only be called when leaving the callback - // that locked the mutex with Grab() - SolarMutexObject::acquire(); - mnCount = nGrabs; - if( mnCount == 0 ) - mnThreadId = 0; - SolarMutexObject::release(); -#else (void)nGrabs; g_error ("never called"); -#endif } SalVirtualDevice* GtkInstance::CreateVirtualDevice( SalGraphics *pG,
_______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits