:
This message was edited by __c4.ep at 2003-5-20 7:37:21
: Alright, I've tried everything over the last 5 hours, but I just can't get this code to work.
:
: What I want to do is to serialize a class in an SDI app (created with app wizard), which holds a list of another class holding a CString object. Here's the code:
:
:
: // header
:
: class COther
: {
: public:
: CString m_str;
: };
:
: class CData
: {
: public:
:
: void Serialize( CArchive& ar )
: {
: m_list.Serialize( ar );
: }
:
: CList<COther,COther&> m_list;
: };
:
:
: Then I instantiate CData in CSerializationDoc and add an object of COther to the list in CSerializationDoc's ctor:
:
:
: CSerializationDoc::CSerializationDoc()
: {
: // TODO: add one-time construction code here
: COther obj;
: obj.m_str = "Text";
: m_data.m_list.AddTail( obj );
: }
:
:
: Then I finally have my Serialization func:
:
:
: void CSerializationDoc::Serialize(CArchive& ar)
: {
: m_data.Serialize( ar );
: }
:
:
: Well, if I run this app and load a document, I'm getting memory faults when exiting the app. The errors occur in CStringData::Release().
: Obviously, the app tries to release a CString which already HAS been released, thus trying to delete data where nothing is anymore.
:
: Does anyone know what the heck is going wrong here?
: I have already posted two times on codeguru.com but noone can help me there. Perhaps you can?
:
:
: Hi there, i've had exactly the same problem as you have..i wanted to save a sting by using serialization. I'm nog at home right know, but when i do, i'll send you my solution.. i can remember it had something do to with the CString object that wast created or something.
good luck
Grz,
Bl@ckBl@de <Feedback: void_void@hotmail.com>