diff options
-rw-r--r-- | ges/ges-base-xml-formatter.c | 14 | ||||
-rw-r--r-- | ges/ges-formatter.c | 32 | ||||
-rw-r--r-- | ges/ges-formatter.h | 4 | ||||
-rw-r--r-- | ges/ges-pitivi-formatter.c | 2 |
4 files changed, 30 insertions, 22 deletions
diff --git a/ges/ges-base-xml-formatter.c b/ges/ges-base-xml-formatter.c index 85eb9619..23eda59e 100644 --- a/ges/ges-base-xml-formatter.c +++ b/ges/ges-base-xml-formatter.c @@ -182,26 +182,22 @@ failed: ***********************************************/ static gboolean -_can_load_uri (GESFormatterClass * class, const gchar * uri, GError ** error) +_can_load_uri (GESFormatter * dummy_formatter, const gchar * uri, + GError ** error) { - gboolean ret = FALSE; GMarkupParseContext *ctx; + GESBaseXmlFormatter *self = GES_BASE_XML_FORMATTER (dummy_formatter); /* we create a temporary object so we can use it as a context */ - GESBaseXmlFormatter *self = g_object_new (G_OBJECT_CLASS_TYPE (class), NULL); _GET_PRIV (self)->check_only = TRUE; ctx = create_parser_context (self, uri, error); if (!ctx) - goto done; + return FALSE; - ret = TRUE; g_markup_parse_context_free (ctx); - -done: - gst_object_unref (self); - return ret; + return TRUE; } static gboolean diff --git a/ges/ges-formatter.c b/ges/ges-formatter.c index 22c1d349..46c97b86 100644 --- a/ges/ges-formatter.c +++ b/ges/ges-formatter.c @@ -46,9 +46,9 @@ struct _GESFormatterPrivate }; static void ges_formatter_dispose (GObject * object); -static gboolean default_can_load_uri (GESFormatterClass * class, +static gboolean default_can_load_uri (GESFormatter * dummy_instance, const gchar * uri, GError ** error); -static gboolean default_can_save_uri (GESFormatterClass * class, +static gboolean default_can_save_uri (GESFormatter * dummy_instance, const gchar * uri, GError ** error); /* GESExtractable implementation */ @@ -146,20 +146,21 @@ ges_formatter_dispose (GObject * object) } static gboolean -default_can_load_uri (GESFormatterClass * class, const gchar * uri, +default_can_load_uri (GESFormatter * dummy_instance, const gchar * uri, GError ** error) { GST_DEBUG ("%s: no 'can_load_uri' vmethod implementation", - g_type_name (G_OBJECT_CLASS_TYPE (class))); + G_OBJECT_TYPE_NAME (dummy_instance)); + return FALSE; } static gboolean -default_can_save_uri (GESFormatterClass * class, +default_can_save_uri (GESFormatter * dummy_instance, const gchar * uri, GError ** error) { GST_DEBUG ("%s: no 'can_save_uri' vmethod implementation", - g_type_name (G_OBJECT_CLASS_TYPE (class))); + G_OBJECT_TYPE_NAME (dummy_instance)); return FALSE; } @@ -236,6 +237,7 @@ ges_formatter_can_load_uri (const gchar * uri, GError ** error) formatter_assets = ges_list_assets (GES_TYPE_FORMATTER); for (tmp = formatter_assets; tmp; tmp = tmp->next) { GESAsset *asset = GES_ASSET (tmp->data); + GESFormatter *dummy_instance; if (extension && g_strcmp0 (extension, @@ -244,12 +246,16 @@ ges_formatter_can_load_uri (const gchar * uri, GError ** error) continue; class = g_type_class_ref (ges_asset_get_extractable_type (asset)); - if (class->can_load_uri (class, uri, error)) { + dummy_instance = + g_object_new (ges_asset_get_extractable_type (asset), NULL); + if (class->can_load_uri (dummy_instance, uri, error)) { g_type_class_unref (class); + gst_object_unref (dummy_instance); ret = TRUE; break; } g_type_class_unref (class); + gst_object_unref (dummy_instance); } g_list_free (formatter_assets); @@ -303,8 +309,8 @@ ges_formatter_can_save_uri (const gchar * uri, GError ** error) */ gboolean -ges_formatter_load_from_uri (GESFormatter * formatter, GESTimeline * timeline, - const gchar * uri, GError ** error) +ges_formatter_load_from_uri (GESFormatter * formatter, + GESTimeline * timeline, const gchar * uri, GError ** error) { gboolean ret = FALSE; GESFormatterClass *klass = GES_FORMATTER_GET_CLASS (formatter); @@ -464,16 +470,22 @@ _find_formatter_asset_for_uri (const gchar * uri) formatter_assets = ges_list_assets (GES_TYPE_FORMATTER); for (tmp = formatter_assets; tmp; tmp = tmp->next) { + GESFormatter *dummy_instance; + asset = GES_ASSET (tmp->data); class = g_type_class_ref (ges_asset_get_extractable_type (asset)); - if (class->can_load_uri (class, uri, NULL)) { + dummy_instance = + g_object_new (ges_asset_get_extractable_type (asset), NULL); + if (class->can_load_uri (dummy_instance, uri, NULL)) { g_type_class_unref (class); asset = gst_object_ref (asset); + gst_object_unref (dummy_instance); break; } asset = NULL; g_type_class_unref (class); + gst_object_unref (dummy_instance); } g_list_free (formatter_assets); diff --git a/ges/ges-formatter.h b/ges/ges-formatter.h index 6c057727..d6eabf10 100644 --- a/ges/ges-formatter.h +++ b/ges/ges-formatter.h @@ -63,8 +63,8 @@ struct _GESFormatter { gpointer _ges_reserved[GES_PADDING]; }; -typedef gboolean (*GESFormatterCanLoadURIMethod) (GESFormatterClass *class, const gchar * uri, GError **error); -typedef gboolean (*GESFormatterCanSaveURIMethod) (GESFormatterClass *class, const gchar * uri, GError **error); +typedef gboolean (*GESFormatterCanLoadURIMethod) (GESFormatter *dummy_instance, const gchar * uri, GError **error); +typedef gboolean (*GESFormatterCanSaveURIMethod) (GESFormatter *dummy_instance, const gchar * uri, GError **error); /** * GESFormatterLoadFromURIMethod: diff --git a/ges/ges-pitivi-formatter.c b/ges/ges-pitivi-formatter.c index ccb9fc38..84331d64 100644 --- a/ges/ges-pitivi-formatter.c +++ b/ges/ges-pitivi-formatter.c @@ -99,7 +99,7 @@ list_table_destroyer (gpointer key, gpointer value, void *unused) } static gboolean -pitivi_can_load_uri (GESFormatterClass * class, const gchar * uri, +pitivi_can_load_uri (GESFormatter * dummy_instance, const gchar * uri, GError ** error) { xmlDocPtr doc; |