X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/d3b9f782ef3949f583e8ac53795d36787f044fc3..c437b3f4e47b74715a2f2385d4862972babd7802:/src/common/variant.cpp?ds=sidebyside diff --git a/src/common/variant.cpp b/src/common/variant.cpp index 6d67625a5f..661a6190e5 100644 --- a/src/common/variant.cpp +++ b/src/common/variant.cpp @@ -908,13 +908,13 @@ wxVariant::wxVariant(const wxCStrData& val, const wxString& name) m_name = name; } -wxVariant::wxVariant(const wxCharBuffer& val, const wxString& name) +wxVariant::wxVariant(const wxScopedCharBuffer& val, const wxString& name) { m_data = new wxVariantDataString(wxString(val)); m_name = name; } -wxVariant::wxVariant(const wxWCharBuffer& val, const wxString& name) +wxVariant::wxVariant(const wxScopedWCharBuffer& val, const wxString& name) { m_data = new wxVariantDataString(wxString(val)); m_name = name; @@ -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(); } @@ -1267,9 +1271,8 @@ bool wxVariantDataDateTime::Read(wxString& str) return true; } - if(! m_value.ParseDateTime(str.c_str()/*FIXME-UTF8*/)) - return false; - return true; + wxString::const_iterator end; + return m_value.ParseDateTime(str, &end) && end == str.end(); } // wxVariant @@ -1834,12 +1837,25 @@ bool wxVariant::Convert(wxDateTime* value) const *value = ((wxVariantDataDateTime*)GetData())->GetValue(); return true; } + // Fallback to string conversion wxString val; - return Convert(&val) && - (value->ParseDateTime(val.c_str()/*FIXME-UTF8*/) || - value->ParseDate(val.c_str()/*FIXME-UTF8*/) || - value->ParseTime(val.c_str()/*FIXME-UTF8*/)); + if ( !Convert(&val) ) + return false; + + // Try to parse this as either date and time, only date or only time + // checking that the entire string was parsed + wxString::const_iterator end; + if ( value->ParseDateTime(val, &end) && end == val.end() ) + return true; + + if ( value->ParseDate(val, &end) && end == val.end() ) + return true; + + if ( value->ParseTime(val, &end) && end == val.end() ) + return true; + + return false; } #endif // wxUSE_DATETIME