diff --git a/ETL/trunk/ETL/_handle.h b/ETL/trunk/ETL/_handle.h index 3f07503..ae534d5 100644 --- a/ETL/trunk/ETL/_handle.h +++ b/ETL/trunk/ETL/_handle.h @@ -32,7 +32,13 @@ /* === H E A D E R S ======================================================= */ +// include the next line in an attempt to increase stability +#define ETL_LOCK_REFCOUNTS + #include +#ifdef ETL_LOCK_REFCOUNTS +#include +#endif /* === M A C R O S ========================================================= */ @@ -67,6 +73,9 @@ class shared_object { private: mutable int refcount; +#ifdef ETL_LOCK_REFCOUNTS + mutable Glib::Mutex mutex; +#endif protected: shared_object():refcount(0) { } @@ -79,11 +88,19 @@ protected: public: void ref()const - { assert(refcount>=0); refcount++; } + { +#ifdef ETL_LOCK_REFCOUNTS + Glib::Mutex::Lock lock(mutex); +#endif + assert(refcount>=0); refcount++; + } //! Returns \c false if object needs to be deleted bool unref()const { +#ifdef ETL_LOCK_REFCOUNTS + Glib::Mutex::Lock lock(mutex); +#endif assert(refcount>0); refcount--; @@ -91,6 +108,9 @@ public: if(refcount==0) { #ifdef ETL_SELF_DELETING_SHARED_OBJECT refcount=-666; +#ifdef ETL_LOCK_REFCOUNTS + lock.release(); +#endif delete this; #endif return false; @@ -100,7 +120,12 @@ public: } int count()const - { return refcount; } + { +#ifdef ETL_LOCK_REFCOUNTS + Glib::Mutex::Lock lock(mutex); +#endif + return refcount; + } }; // END of class shared_object // ======================================================================== diff --git a/synfig-studio/trunk/src/gtkmm/app.cpp b/synfig-studio/trunk/src/gtkmm/app.cpp index 1da982b..b5d4101 100644 --- a/synfig-studio/trunk/src/gtkmm/app.cpp +++ b/synfig-studio/trunk/src/gtkmm/app.cpp @@ -1016,16 +1016,16 @@ App::App(int *argc, char ***argv): { app_base_path_=etl::dirname(etl::dirname((*argv)[0])); - - ui_interface_=new GlobalUIInterface(); - - gdk_rgb_init(); - // don't call thread_init() if threads are already initialized // on some machines bonobo_init() initialized threads before we get here if (!g_thread_supported()) Glib::thread_init(); + // class UIInterface inherits from etl::shared_object, so we need the thread stuff initialised already + ui_interface_=new GlobalUIInterface(); + + gdk_rgb_init(); + distance_system=Distance::SYSTEM_UNITS; if(mkdir(get_user_app_directory().c_str(),ACCESSPERMS)<0)