|
Boost Users : |
From: boost_at_[hidden]
Date: 2005-07-05 21:59:11
Thanks. If I changed the order of the members being serialized it worked
fine. Weird.
However, I am running into a problem. I am using reference counted Smart
Pointers. If I serialize the reference counter, then when it is loaded it
will likely contain too large of a reference count because there were more
objects referencing the pointer when it was saved than when it was loaded.
However, it works fine it just doesn't properly delete the objects because
the reference count never reaches 0.
If I don't serialize the reference count then the objects try to delete
themselves while boost is loading them from the file. I'm guessing because
of the order everything happens, the final destination isn't increasing the
reference count until after boost already dereferences it.
Any suggestions?
I thought maybe if there was a way to tell if the operation was saving during
the serialize function I could just set the reference count to one, however
that could be erroneous also if the same object being loaded has more than
one smartpointer to the same object.
I'm stumped...
-
Chris
----- Original Message -----
From: "Robert Ramey" <ramey_at_[hidden]>
To: boost-users_at_[hidden]
Date: Tue, 5 Jul 2005 15:25:27 -0700
Subject: Re: [Boost-users] Serialization and null pointers
> This shouldn't happen.
>
> you might try using an xml_archive so you can better see the output. This
> will also check that the data saved and data loaded are "in sync". That is
> that the same data is being saved and loaded.
>
> If all that fails, you'lll have to boil it down to a small example and send
> it in
>
> Robert Ramey
>
> boost_at_[hidden] wrote:
> > Hello,
> >
> > I have an object graph that is being serialized using a binary
> > archive. It saves to the file fine, however a class member is being
> > serialized is a null pointer.
> >
> > When I go to open the file, I get an access violation in
> > basic_iarchive.cpp on line 393:
> >
> > bpis_ptr->load_object_ptr(ar, t, co.file_version);
> >
> > t is 0x00000000
> >
> > Is there a way around this? Thank you.
>
>
>
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>
>
>
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net