S
sbrothy
Guest
I´ve come so far now that everything works except BSTRs. No surprise.
In my program I change the value of the CComVariant m_strBorder like this:
CComVariant *CSettings::GetSetCaption(CComVariant *v)
{
if (v)
{
m_strCaption = v->bstrVal;
}
return &m_strCaption;
}
I have a suspicion that this inadvertently copies the object so the system thinks it has to deallocate it twice, which of course crashes.
I can Serialize a CComVariant object like this:
void CSettings::Serialize(CArchive& archive)
{
CObject::Serialize(archive);
if (archive.IsStoring())
{
archive.Write(&m_b3DLook, sizeof(m_b3DLook));
archive.Write(&m_strCaption, sizeof(m_strCaption));
}
else
{
archive.Read(&m_b3DLook, sizeof(m_b3DLook));
archive.Read(&m_strCaption, sizeof(m_strCaption));
[...]
The problem is the CComVariant m_strCaption which is intialized in the constructor member initialization list as
CSettings::CSettings()
: m_strCaption(_T("Caption"))
[...]
{
[...]
}
Do I have to VariantClear the object before resetting it to it´s new value, or something similar?
Regards,
Søren
Continue reading...
In my program I change the value of the CComVariant m_strBorder like this:
CComVariant *CSettings::GetSetCaption(CComVariant *v)
{
if (v)
{
m_strCaption = v->bstrVal;
}
return &m_strCaption;
}
I have a suspicion that this inadvertently copies the object so the system thinks it has to deallocate it twice, which of course crashes.
I can Serialize a CComVariant object like this:
void CSettings::Serialize(CArchive& archive)
{
CObject::Serialize(archive);
if (archive.IsStoring())
{
archive.Write(&m_b3DLook, sizeof(m_b3DLook));
archive.Write(&m_strCaption, sizeof(m_strCaption));
}
else
{
archive.Read(&m_b3DLook, sizeof(m_b3DLook));
archive.Read(&m_strCaption, sizeof(m_strCaption));
[...]
The problem is the CComVariant m_strCaption which is intialized in the constructor member initialization list as
CSettings::CSettings()
: m_strCaption(_T("Caption"))
[...]
{
[...]
}
Do I have to VariantClear the object before resetting it to it´s new value, or something similar?
Regards,
Søren
Continue reading...