From ab3e5a58c2bde7802ba22cfad6113fe77bc86da4 Mon Sep 17 00:00:00 2001
From: Cyrille Bagard <nocbos@gmail.com>
Date: Sat, 29 Dec 2018 15:52:02 +0100
Subject: Allowed more than one dynamic GType.

---
 plugins/pychrysalide/dt.c | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/plugins/pychrysalide/dt.c b/plugins/pychrysalide/dt.c
index edfc032..0b46b45 100644
--- a/plugins/pychrysalide/dt.c
+++ b/plugins/pychrysalide/dt.c
@@ -97,7 +97,7 @@ static void g_dynamic_types_unuse(GDynamicTypes *);
 static void g_dynamic_types_complete_type(GDynamicTypes *, GType, GTypeInfo *, GTypeValueTable *);
 
 /* Retrouve les informations concernant un type dynamique. */
-static type_dyn_info_t *g_dynamic_types_find(GDynamicTypes *, GType);
+static const type_dyn_info_t *g_dynamic_types_find(const GDynamicTypes *, GType);
 
 /* Fournit un identifiant GLib pour un nouveau type Python. */
 static GType g_dynamic_types_register_type(GDynamicTypes *, GType, const char *, GClassInitFunc);
@@ -296,7 +296,7 @@ static void g_dynamic_types_unuse(GDynamicTypes *types)
 
 static void g_dynamic_types_complete_type(GDynamicTypes *types, GType type, GTypeInfo *info, GTypeValueTable *table)
 {
-    type_dyn_info_t *nfo;                   /* Source d'inspiration        */
+    const type_dyn_info_t *nfo;             /* Source d'inspiration        */
     GType parent;                           /* Type parent du type         */
     GTypeQuery query;                       /* Informations complémentaires*/
 
@@ -331,11 +331,18 @@ static void g_dynamic_types_complete_type(GDynamicTypes *types, GType type, GTyp
 *                                                                             *
 ******************************************************************************/
 
-static type_dyn_info_t *g_dynamic_types_find(GDynamicTypes *types, GType target)
+static const type_dyn_info_t *g_dynamic_types_find(const GDynamicTypes *types, GType target)
 {
+    type_dyn_info_t *result;                /* Informations à retourner    */
+    size_t i;                               /* Boucle de parcours          */
 
-    return types->info[0];
+    result = NULL;
 
+    for (i = 0; i < types->count && result == NULL; i++)
+        if (types->info[i]->type == target)
+            result = types->info[i];
+
+    return result;
 
 }
 
-- 
cgit v0.11.2-87-g4458