El vie, 28-01-2011 a las 12:26 +0100, Murray Cumming escribió:
> On Fri, 2011-01-28 at 08:18 -0300, Culpian Camilo Martin wrote:
> > El vie, 28-01-2011 a las 10:13 +0100, Murray Cumming escribió:
> > > On Fri, 2011-01-28 at 10:07 +0100, Chris Kühl wrote:
> > > > On Fri, Jan 28, 2011 at 5:37 AM, Culpian Camilo Martin
> > > > <[email protected]> wrote:
> > > > > Hi, I'd like to create my own Gobject in C++, I have to inherit from
> > > > > Glib::ObjectBase or Glib::Object?, where can i find some good
> > > > > documentation?
> > > 
> > > The answer really depends on what you actually want to achieve.
> > > 
> > What i want to do is to crate objects that can use Glib::RefPtr, (not
> > necesary widgets), like
> > 
> > class foo : public (Glib::Object or ObjectBase)
> > {
> >     static Glib::RefPtr<foo> create
> >     (
> >             return Glib::RefPtr<foo>(new foo());
> >     );
> >     foo();
> >     ~foo();
> > }
> 
> That's not a particularly good idea. If you want reference-counting then
> try using a non-intrusive reference-counting shared pointer, for
> instance from boost.
> 
> Or make your own, like I do in Glom:
> http://git.gnome.org/browse/glom/tree/glom/libglom/sharedptr.h
> 
ok, i'll try it, i have had some troubles doing this:

class foo
{
        static ref_ptr<foo> create
        (
                return ref_ptr<foo>(new foo());
        );
        foo();
        ~foo();
        ref_ptr<foo> set_something()
        {
                //set something

                return ref_ptr<foo>(this);
                //for using foo->set_something()->set_something();
                // oviously the ref_ptr delete "this", and cause a segfault
                // any idea how can avoid this?
        }
}

_______________________________________________
gtkmm-list mailing list
[email protected]
http://mail.gnome.org/mailman/listinfo/gtkmm-list

Reply via email to