glibmm r540 - in trunk: . gio/src tools/m4



Author: murrayc
Date: Fri Jan 25 20:29:42 2008
New Revision: 540
URL: http://svn.gnome.org/viewvc/glibmm?rev=540&view=rev

Log:
2008-01-25  Murray Cumming  <murrayc murrayc com>

* tools/m4/class_shared.m4: Added _DO_NOT_DERIVE_GTYPE for use in .hg 
files when we do not want to derive a new GType, meaning of course that 
we cannot have default signal handlers or vfuncs.
* gio/src/volumemonitor.hg: Use _DO_NOT_DERIVE_GTYPE, because 
gio tries to call every type that derives from G_TYPE_VOLUME_MONITOR, 
which seems unwise to me - bug #511814.
This makes gtkmm-documentation/examples/book/volumes not crash.

Modified:
   trunk/ChangeLog
   trunk/gio/src/volumemonitor.hg
   trunk/tools/m4/class_shared.m4

Modified: trunk/gio/src/volumemonitor.hg
==============================================================================
--- trunk/gio/src/volumemonitor.hg	(original)
+++ trunk/gio/src/volumemonitor.hg	Fri Jan 25 20:29:42 2008
@@ -36,6 +36,7 @@
 class VolumeMonitor : public Glib::Object
 {
   _CLASS_GOBJECT(VolumeMonitor, GVolumeMonitor, G_VOLUME_MONITOR, Glib::Object, GObject)
+  _DO_NOT_DERIVE_GTYPE
 protected:
 
 public:

Modified: trunk/tools/m4/class_shared.m4
==============================================================================
--- trunk/tools/m4/class_shared.m4	(original)
+++ trunk/tools/m4/class_shared.m4	Fri Jan 25 20:29:42 2008
@@ -42,7 +42,13 @@
 _POP()
 ')
 
-
+dnl GVolumeMonitor can be broken/impeded by defining a sub-type.
+define(`_DO_NOT_DERIVE_GTYPE',`dnl
+_PUSH()
+dnl Define this macro to be tested for later.
+define(`__BOOL_DO_NOT_DERIVE_GTYPE__',`$1')
+_POP()
+')
 
 dnl
 dnl
@@ -54,7 +60,8 @@
 #ifndef DOXYGEN_SHOULD_SKIP_THIS
   typedef __CPPNAME__ CppObjectType;
   typedef __REAL_CNAME__ BaseObjectType;
-ifdef(`__BOOL_NO_DERIVED_CLASS__',`dnl
+ifdef(`__BOOL_DO_NOT_DERIVE_GTYPE__',`dnl
+  typedef __CPPPARENT__`'_Class CppClassParent;
 ',`dnl
   typedef __REAL_CNAME__`'Class BaseClassType;
   typedef __CPPPARENT__`'_Class CppClassParent;
@@ -66,7 +73,7 @@
 
   const Glib::Class& init();
 
-ifdef(`__BOOL_NO_DERIVED_CLASS__',`dnl
+ifdef(`__BOOL_DO_NOT_DERIVE_GTYPE__',`dnl
 ',`dnl
   static void class_init_function(void* g_class, void* class_data);
 ')dnl
@@ -98,6 +105,10 @@
 {
   if(!gtype_) // create the GType if necessary
   {
+ifdef(`__BOOL_DO_NOT_DERIVE_GTYPE__',`dnl
+    // Do not derive a GType, or use a derived klass:
+    gtype_ = CppClassParent::CppObjectType::get_type();
+',`dnl
     // Glib::Class has to know the class init function to clone custom types.
     class_init_func_ = &__CPPNAME__`'_Class::class_init_function;
 
@@ -110,11 +121,12 @@
 
     // Add derived versions of interfaces, if the C type implements any interfaces:
 _IMPORT(SECTION_CC_IMPLEMENTS_INTERFACES)
+')
   }
 
   return *this;
 }
-ifdef(`__BOOL_NO_DERIVED_CLASS__',`dnl
+ifdef(`__BOOL_DO_NOT_DERIVE_GTYPE__',`dnl
 ',`dnl
 
 void __CPPNAME__`'_Class::class_init_function(void* g_class, void* class_data)



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]