[gnome-panel] libpanel-applet: Make sure people cannot misuse PanelApplet
- From: Vincent Untz <vuntz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-panel] libpanel-applet: Make sure people cannot misuse PanelApplet
- Date: Thu, 24 Feb 2011 10:58:30 +0000 (UTC)
commit 79d40f1be753bdfc40773a053a92bfbf7a4df62a
Author: Vincent Untz <vuntz gnome org>
Date: Thu Feb 24 11:39:50 2011 +0100
libpanel-applet: Make sure people cannot misuse PanelApplet
If people just create a PanelApplet object and hope it works, then it
will just fail. People should use panel_applet_factory_main().
https://bugzilla.gnome.org/show_bug.cgi?id=640968
libpanel-applet/panel-applet.c | 15 ++++++++++++---
1 files changed, 12 insertions(+), 3 deletions(-)
---
diff --git a/libpanel-applet/panel-applet.c b/libpanel-applet/panel-applet.c
index 521c1bc..63223de 100644
--- a/libpanel-applet/panel-applet.c
+++ b/libpanel-applet/panel-applet.c
@@ -1759,8 +1759,12 @@ panel_applet_set_property (GObject *object,
break;
case PROP_CLOSURE:
applet->priv->closure = g_value_get_pointer (value);
- g_closure_set_marshal (applet->priv->closure,
- panel_applet_marshal_BOOLEAN__STRING);
+ /* We know closure should not be NULL, but we'll fail in
+ * panel_applet_constructed() with a proper message if this is
+ * the case. */
+ if (applet->priv->closure)
+ g_closure_set_marshal (applet->priv->closure,
+ panel_applet_marshal_BOOLEAN__STRING);
break;
case PROP_CONNECTION:
applet->priv->connection = g_value_dup_object (value);
@@ -1906,7 +1910,12 @@ panel_applet_constructed (GObject *object)
{
PanelApplet *applet = PANEL_APPLET (object);
- panel_applet_register_object (applet);
+ if (!applet->priv->connection || !applet->priv->closure || !applet->priv->id) {
+ g_printerr ("Bad use of PanelApplet API: you should not create a PanelApplet object yourself. Please use panel_applet_factory_main() instead.\n");
+ g_assert_not_reached ();
+ }
+
+ return panel_applet_register_object (applet);
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]