[dia] [warningectomy] implicit declaration of function 'filter_unregister_callback'
- From: Hans Breuer <hans src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [dia] [warningectomy] implicit declaration of function 'filter_unregister_callback'
- Date: Sat, 4 May 2013 19:00:10 +0000 (UTC)
commit ce0b3223b9b4438d72fa4bf589938096a1fbdab2
Author: Hans Breuer <hans breuer org>
Date: Sat May 4 14:44:26 2013 +0200
[warningectomy] implicit declaration of function 'filter_unregister_callback'
The non-win32 build was referencing a function not implemented at all.
It could not be called, due to being protected by plugin_can_unload(),
but that was just coincidence.
Now filter_unregister_callback() is defined and implemented, including
some error handling for callback's being invoked after unloading of
the providing plug-in.
app/menus.c | 6 ++++++
lib/filter.c | 14 ++++++++++++++
lib/filter.h | 1 +
lib/libdia.def | 1 +
plug-ins/cairo/diacairo.c | 4 ++--
5 files changed, 24 insertions(+), 2 deletions(-)
---
diff --git a/app/menus.c b/app/menus.c
index 1de172d..be00f27 100644
--- a/app/menus.c
+++ b/app/menus.c
@@ -1249,6 +1249,11 @@ plugin_callback (GtkWidget *widget, gpointer data)
{
DiaCallbackFilter *cbf = data;
+ /* check if the callback filter is still available */
+ if (!g_list_find (filter_get_callbacks (), cbf)) {
+ message_error (_("The function is not available anymore."));
+ return;
+ }
/* and finally invoke it */
if (cbf->callback) {
DDisplay *ddisp = NULL;
@@ -1280,3 +1285,4 @@ plugin_callback (GtkWidget *widget, gpointer data)
}
}
}
+
diff --git a/lib/filter.c b/lib/filter.c
index 63c84e2..fc6644e 100644
--- a/lib/filter.c
+++ b/lib/filter.c
@@ -304,9 +304,23 @@ filter_register_callback(DiaCallbackFilter *cbfilter)
callback_filters = g_list_append (callback_filters, (gpointer)cbfilter);
}
+void
+filter_unregister_callback(DiaCallbackFilter *cbfilter)
+{
+ /* Unregistering a callback filter should remove it from the menu, too.
+ * But that would involve quite some additional code, maybe some
+ * notification to update menus ...
+ * We take the easy approach to let the caller check if the callback
+ * is still valid, i.e. the filter still exists.
+ */
+ callback_filters = g_list_remove (callback_filters, cbfilter);
+}
+
+
/* return the registered callbacks list, called once to build menus */
GList *
filter_get_callbacks(void)
{
return g_list_first (callback_filters);
}
+
diff --git a/lib/filter.h b/lib/filter.h
index 107c657..1c80c7f 100644
--- a/lib/filter.h
+++ b/lib/filter.h
@@ -125,6 +125,7 @@ DiaImportFilter *filter_guess_import_filter(const gchar *filename);
DiaImportFilter *filter_import_get_by_name(const gchar *name);
void filter_register_callback(DiaCallbackFilter *cbfilter);
+void filter_unregister_callback(DiaCallbackFilter *cbfilter);
/* returns all registered callbacks */
GList *filter_get_callbacks(void);
diff --git a/lib/libdia.def b/lib/libdia.def
index 44be57c..a903c10 100644
--- a/lib/libdia.def
+++ b/lib/libdia.def
@@ -440,6 +440,7 @@ EXPORTS
filter_register_callback
filter_register_export
filter_register_import
+ filter_unregister_callback
filter_unregister_export
filter_unregister_import
diff --git a/plug-ins/cairo/diacairo.c b/plug-ins/cairo/diacairo.c
index 6cb87b5..ef5ac10 100644
--- a/plug-ins/cairo/diacairo.c
+++ b/plug-ins/cairo/diacairo.c
@@ -523,9 +523,9 @@ _plugin_unload (PluginInfo *info)
#if DIA_CAIRO_CAN_EMF
filter_unregister_export(&emf_export_filter);
filter_unregister_export(&wmf_export_filter);
- /* filter_unregister_callback (&cb_clipboard); */
+ filter_unregister_callback (&cb_clipboard);
#endif
- /* filter_unregister_callback (&cb_gtk_print); */
+ filter_unregister_callback (&cb_gtk_print);
}
/* --- dia plug-in interface --- */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]