X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/4c1d5d5ae212f255662264677d21c7139f4c939d..acd32ffcdb319f162633c20e0202db3f8542998a:/src/common/variant.cpp diff --git a/src/common/variant.cpp b/src/common/variant.cpp index 6d3996af82..627edfbef6 100644 --- a/src/common/variant.cpp +++ b/src/common/variant.cpp @@ -63,12 +63,12 @@ IMPLEMENT_DYNAMIC_CLASS(wxVariant, wxObject) wxVariant::wxVariant() { - m_data = (wxVariantData*) NULL; + m_data = NULL; } bool wxVariant::IsNull() const { - return (m_data == (wxVariantData*) NULL); + return (m_data == NULL); } void wxVariant::MakeNull() @@ -84,7 +84,7 @@ void wxVariant::Clear() wxVariant::wxVariant(const wxVariant& variant) : wxObject() { - m_data = (wxVariantData*) NULL; + m_data = NULL; if (!variant.IsNull()) Ref(variant); @@ -1034,7 +1034,7 @@ bool wxVariantDataWxObjectPtr::Write(wxSTD ostream& str) const bool wxVariantDataWxObjectPtr::Write(wxString& str) const { - str.Printf(wxT("%s(%p)"), GetType().c_str(), wx_static_cast(void*, m_value)); + str.Printf(wxT("%s(%p)"), GetType().c_str(), static_cast(m_value)); return true; } @@ -1182,7 +1182,11 @@ void wxVariant::operator= (void* value) void* wxVariant::GetVoidPtr() const { - wxASSERT( (GetType() == wxT("void*")) ); + // handling this specially is convenient when working with COM, see #9873 + if ( IsNull() ) + return NULL; + + wxASSERT( GetType() == wxT("void*") ); return (void*) ((wxVariantDataVoidPtr*) m_data)->GetValue(); } @@ -1242,7 +1246,10 @@ bool wxVariantDataDateTime::Write(wxSTD ostream& str) const bool wxVariantDataDateTime::Write(wxString& str) const { - str = m_value.Format(); + if ( m_value.IsValid() ) + str = m_value.Format(); + else + str = wxS("Invalid"); return true; } @@ -1258,6 +1265,12 @@ bool wxVariantDataDateTime::Read(wxSTD istream& WXUNUSED(str)) bool wxVariantDataDateTime::Read(wxString& str) { + if ( str == wxS("Invalid") ) + { + m_value = wxInvalidDateTime; + return true; + } + if(! m_value.ParseDateTime(str.c_str()/*FIXME-UTF8*/)) return false; return true;