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-core/trunk/configure.ac b/synfig-core/trunk/configure.ac index b972337..392443b 100644 --- a/synfig-core/trunk/configure.ac +++ b/synfig-core/trunk/configure.ac @@ -365,6 +365,10 @@ dnl ]) ]) CONFIG_DEPS="$CONFIG_DEPS sigc++-2.0" +PKG_CHECK_MODULES(GTHREAD, [gthread-2.0],,[ + AC_MSG_ERROR([ ** Required library gthread-2.0 not found. (See package 'libglib2.0-dev'?)]) +]) + dnl PKG_CHECK_MODULES(GLIB, glib-2.0,[GLIB="yes"],[GLIB="no"]) diff --git a/synfig-core/trunk/src/tool/Makefile.am b/synfig-core/trunk/src/tool/Makefile.am index f019d0b..5eec1dc 100644 --- a/synfig-core/trunk/src/tool/Makefile.am +++ b/synfig-core/trunk/src/tool/Makefile.am @@ -8,7 +8,7 @@ INCLUDES=-I$(top_builddir) -I$(top_srcdir)/src bin_PROGRAMS = synfig synfig_SOURCES = main.cpp -synfig_LDADD = ../synfig/libsynfig.la @SYNFIG_LIBS@ @OPENEXR_HALF_LIBS@ +synfig_LDADD = ../synfig/libsynfig.la @SYNFIG_LIBS@ @OPENEXR_HALF_LIBS@ @GTHREAD_LIBS@ synfig_CXXFLAGS = @SYNFIG_CFLAGS@ #synfig_LDFLAGS=-export-dynamic -dlopen self #-dlopen ../modules/example/libexample.la diff --git a/synfig-core/trunk/src/tool/main.cpp b/synfig-core/trunk/src/tool/main.cpp index 77281c8..a5a2c8e 100644 --- a/synfig-core/trunk/src/tool/main.cpp +++ b/synfig-core/trunk/src/tool/main.cpp @@ -881,6 +881,9 @@ int main(int argc, char *argv[]) return SYNFIGTOOL_BADVERSION; } + if (!g_thread_supported()) + Glib::thread_init(); + if(argc==1) { display_help(0); 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)