[SCM] calf/master: + LV2: anti-GUI-crash fix (thanks to: nedko, drobilla, timj and others); doesn't work for PHAT

js at users.alioth.debian.org js at users.alioth.debian.org
Tue May 7 15:37:00 UTC 2013


The following commit has been merged in the master branch:
commit 4e20982e93e98ed8d14f946d50521bc972d5bfac
Author: kfoltman <kfoltman at 78b06b96-2940-0410-b7fc-879d825d01d8>
Date:   Wed Jan 16 22:43:12 2008 +0000

    + LV2: anti-GUI-crash fix (thanks to: nedko, drobilla, timj and others); doesn't work for PHAT
    
    
    
    git-svn-id: https://calf.svn.sourceforge.net/svnroot/calf/trunk@109 78b06b96-2940-0410-b7fc-879d825d01d8

diff --git a/src/custom_ctl.cpp b/src/custom_ctl.cpp
index 29b529b..b9afe9c 100644
--- a/src/custom_ctl.cpp
+++ b/src/custom_ctl.cpp
@@ -21,6 +21,27 @@
 #include <cairo/cairo.h>
 #include <math.h>
 
+/*
+I don't really know how to do it, or if it can be done this way.
+struct calf_ui_type_module
+{
+    GTypeModule *module;
+    
+    calf_ui_type_module()
+    {
+        module = g_type_module_new();
+        g_type_module_set_name(module, "calf_custom_ctl");
+        g_type_module_use(module);
+    }
+    ~calf_ui_type_module()
+    {
+        g_type_module_unuse(module);
+    }
+};
+
+static calf_ui_type_module type_module;
+*/
+
 static gboolean
 calf_line_graph_expose (GtkWidget *widget, GdkEventExpose *event)
 {
@@ -116,26 +137,37 @@ calf_line_graph_new()
 GType
 calf_line_graph_get_type (void)
 {
-  static GType type = 0;
-  if (!type) {
-    static const GTypeInfo type_info = {
-      sizeof(CalfLineGraphClass),
-      NULL, /* base_init */
-      NULL, /* base_finalize */
-      (GClassInitFunc)calf_line_graph_class_init,
-      NULL, /* class_finalize */
-      NULL, /* class_data */
-      sizeof(CalfLineGraph),
-      0,    /* n_preallocs */
-      (GInstanceInitFunc)calf_line_graph_init
-    };
-    
-    type = g_type_register_static(GTK_TYPE_WIDGET,
-                                  "CalfLineGraph",
-                                  &type_info,
-                                  (GTypeFlags)0);
-  }
-  return type;
+    static GType type = 0;
+    if (!type) {
+        static const GTypeInfo type_info = {
+            sizeof(CalfLineGraphClass),
+            NULL, /* base_init */
+            NULL, /* base_finalize */
+            (GClassInitFunc)calf_line_graph_class_init,
+            NULL, /* class_finalize */
+            NULL, /* class_data */
+            sizeof(CalfLineGraph),
+            0,    /* n_preallocs */
+            (GInstanceInitFunc)calf_line_graph_init
+        };
+
+        GTypeInfo *type_info_copy = new GTypeInfo(type_info);
+
+        for (int i = 0; ; i++) {
+            char *name = g_strdup_printf("CalfLineGraph%d", i);
+            if (g_type_from_name(name)) {
+                free(name);
+                continue;
+            }
+            type = g_type_register_static( GTK_TYPE_WIDGET,
+                                           name,
+                                           type_info_copy,
+                                           (GTypeFlags)0);
+            free(name);
+            break;
+        }
+    }
+    return type;
 }
 
 ///////////////////////////////////////// knob ///////////////////////////////////////////////
@@ -295,25 +327,35 @@ GtkWidget *calf_knob_new_with_adjustment(GtkAdjustment *_adjustment)
 GType
 calf_knob_get_type (void)
 {
-  static GType type = 0;
-  if (!type) {
-    static const GTypeInfo type_info = {
-      sizeof(CalfKnobClass),
-      NULL, /* base_init */
-      NULL, /* base_finalize */
-      (GClassInitFunc)calf_knob_class_init,
-      NULL, /* class_finalize */
-      NULL, /* class_data */
-      sizeof(CalfKnob),
-      0,    /* n_preallocs */
-      (GInstanceInitFunc)calf_knob_init
-    };
-    
-    type = g_type_register_static(GTK_TYPE_RANGE,
-                                  "CalfKnob",
-                                  &type_info,
-                                  (GTypeFlags)0);
-  }
-  return type;
+    static GType type = 0;
+    if (!type) {
+        
+        static const GTypeInfo type_info = {
+            sizeof(CalfKnobClass),
+            NULL, /* base_init */
+            NULL, /* base_finalize */
+            (GClassInitFunc)calf_knob_class_init,
+            NULL, /* class_finalize */
+            NULL, /* class_data */
+            sizeof(CalfKnob),
+            0,    /* n_preallocs */
+            (GInstanceInitFunc)calf_knob_init
+        };
+        
+        for (int i = 0; ; i++) {
+            char *name = g_strdup_printf("CalfKnob%d", i);
+            if (g_type_from_name(name)) {
+                free(name);
+                continue;
+            }
+            type = g_type_register_static(GTK_TYPE_RANGE,
+                                          name,
+                                          &type_info,
+                                          (GTypeFlags)0);
+            free(name);
+            break;
+        }
+    }
+    return type;
 }
 

-- 
calf audio plugins packaging



More information about the pkg-multimedia-commits mailing list