From d099c754b5a86e0ef905d5d75a91ad32ce285701 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 25 Jan 2009 13:19:44 +0000 Subject: [PATCH] return NULL from GetVoidPtr() for NULL variants instead of asserting (closes #9873) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@58392 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- interface/wx/variant.h | 3 +++ src/common/variant.cpp | 6 +++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/interface/wx/variant.h b/interface/wx/variant.h index 45882e6f29..84e67c2556 100644 --- a/interface/wx/variant.h +++ b/interface/wx/variant.h @@ -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; diff --git a/src/common/variant.cpp b/src/common/variant.cpp index 6d67625a5f..627edfbef6 100644 --- a/src/common/variant.cpp +++ b/src/common/variant.cpp @@ -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(); } -- 2.45.2