]> git.saurik.com Git - wxWidgets.git/commitdiff
return NULL from GetVoidPtr() for NULL variants instead of asserting (closes #9873)
authorVadim Zeitlin <vadim@wxwidgets.org>
Sun, 25 Jan 2009 13:19:44 +0000 (13:19 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Sun, 25 Jan 2009 13:19:44 +0000 (13:19 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@58392 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

interface/wx/variant.h
src/common/variant.cpp

index 45882e6f29be7c3c15b46e5ca7fe2fb3324b8543..84e67c255653bb2dcd2a33c32c0c3f8b57734423 100644 (file)
@@ -321,6 +321,9 @@ public:
 
     /**
         Gets the void pointer value.
+
+        Notice that this method can be used for null objects (i.e. those for
+        which IsNull() returns @true) and will return @NULL for them.
     */
     void* GetVoidPtr() const;
 
index 6d67625a5f8a5a0d36d819fe8079d6af7e487f93..627edfbef604c42ad8cfd7bbae749eebaf28189c 100644 (file)
@@ -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();
 }