Re: [gtkmm] how to use Glib::Object
- From: Daniel Elstner <daniel elstner gmx net>
- To: triendl klaus <triendl kj aon at>
- Cc: gtkmm-list <gtkmm-list gnome org>
- Subject: Re: [gtkmm] how to use Glib::Object
- Date: 20 Dec 2002 23:26:14 +0100
On Fre, 2002-12-20 at 22:52, triendl klaus wrote:
> hi,
>
> i have a class derived from Glib::Object to enable reference counting in order to use it with Glib::RefPtr.
>
> the following warning appears everytime i create a Glib::RefPtr<MyObject>:
> glibmm-WARNING **: Object::Object(): Did you really mean to call this?
>
> is it bad practice to use the standard ctor and how to use the other ctors?
You are not supposed to derive from Glib::Object at all, unless you want
to implement a wrapper for a C interface based on GObject.
There are plenty of smart pointer implementations around you could use,
for instance boost::shared_ptr<>. If you fear the idea of adding yet
another dependency to your application then implement one yourself (it's
quite simple actually) or just copy'n'paste existing code.
You could have a look at Util::SharedPtr<> in my app regexxer if you
like. It's an intrusive implementation that requires the managed types
to be derived from Util::SharedObject<>, but on the other hand it's
pretty simple and efficient. If you want something more flexible use
boost::shared_ptr<>.
--Daniel
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]