RE: [gtkmm] 2 Glib::RefPrt<>s from one instance.
- From: Murray Cumming Comneon com
- To: dwiles Buffalo Veridian Com, gtkmm-list gnome org
- Subject: RE: [gtkmm] 2 Glib::RefPrt<>s from one instance.
- Date: Tue, 1 Apr 2003 08:51:02 +0200
> -----Original Message-----
> From: Dale Wiles [mailto:dwiles Buffalo Veridian Com]
> This isn't so much a bug as an undocumented design quirk.
>
> Given a decendent memory model, Glib::RefPtr<>s work fine:
>
> foo *orig = new foo; Glib::RefPrt<foo> a(orig); b = a; c = b;
>
> "orig" won't be deleted until a, b and c are all out of scope.
> This is a good thing.
>
> If, however, you construct 2 RefPtr<>s from the same
> instance then that
> instance's destructor gets called twice.
So don't do it. RefPtr<>s should come from a create() method. RefPtr<> is
not a generic smartpointer. It is clearly closed tied to Glib::Object.
> Sorry to be so long winded, but I'm working on a project
> that needs a
> smart pointer, and I'd rather not reinvent the wheel.
Boost would be more suitable.
Murray Cumming
murrayc usa net
www.murrayc.com
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]