error handling in constructor



Hi,

I have the following code to set up a constructor with a filepath
parameter. As you can see, the construction property filepath, calls a
function names bitmap_list_load which can return an GError. But how can
I handle this error inside a constructor? What's your solution for this
problem. 

Thanks.

static void bitmap_list_set_property(GObject *gobject, guint
property_id, const GValue *value,
				     GParamSpec *pspec)
{
  GError     * error = NULL;
  BitmapList * self;

  self = BITMAP_LIST(gobject);

  switch(property_id)
    {
    case PROP_FILEPATH:
      
      bitmap_list_load(self, g_value_get_string(value), &error);
      break;

    default:

      G_OBJECT_WARN_INVALID_PROPERTY_ID(gobject, property_id, pspec);
    };

}


static void bitmap_list_class_init(BitmapListClass *klass)
{
  GObjectClass * gobject_class = G_OBJECT_CLASS(klass);
  GParamSpec   * pspec;

  gobject_class->finalize = bitmap_list_finalize;
  gobject_class->set_property = bitmap_list_set_property;

  pspec = g_param_spec_string("bitmap-list-filepath", "Bitmap list
construction property",
			      "Set bitmap list source file", NULL,
			      G_PARAM_CONSTRUCT_ONLY | G_PARAM_WRITABLE);

  g_object_class_install_property(gobject_class, PROP_FILEPATH, pspec);

  g_type_class_add_private(klass, sizeof(BitmapListPrivate));
}



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]