Welcome to the new platform of Programmers Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use it's exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.
Serialization produces memory fault -- even in this TINY class!
[b][red]This message was edited by __c4.ep at 2003-5-20 7:37:21[/red][/b][hr]
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:
void Serialize( CArchive& ar )
m_list.Serialize( ar );
Then I instantiate CData in CSerializationDoc and add an object of COther to the list in CSerializationDoc's ctor:
// TODO: add one-time construction code here
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?