From 5232d996cd3f27d49ea49708f0983445428cf6ce Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Fri, 16 Apr 2004 10:57:06 +0000 Subject: [PATCH] use wx_static_cast() inside wxDynamicCast to catch impossible casts at compile-time instead of run-time git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@26832 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- docs/changes.txt | 3 +++ include/wx/object.h | 5 ++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/docs/changes.txt b/docs/changes.txt index 7889803262..5739b63611 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -92,6 +92,9 @@ OTHER CHANGES All: - Hindi translations added (Dhananjaya Sharma) +- wxDynamicCast() now uses static_cast internally and so using it + with anything not deriving from wxObject will fail at compile time (instead + of run-time) now All (GUI): diff --git a/include/wx/object.h b/include/wx/object.h index f42eaa5eb3..be84989431 100644 --- a/include/wx/object.h +++ b/include/wx/object.h @@ -333,7 +333,10 @@ name##PluginSentinel m_pluginsentinel; // to be replaced by dynamic_cast<> in the future #define wxDynamicCast(obj, className) \ - ((className *) wxCheckDynamicCast((wxObject*)(obj), &className::ms_classInfo)) + ((className *) wxCheckDynamicCast( \ + wx_const_cast(wxObject *, wx_static_cast(const wxObject *, \ + wx_const_cast(className *, wx_static_cast(const className *, obj)))), \ + &className::ms_classInfo)) // The 'this' pointer is always true, so use this version // to cast the this pointer and avoid compiler warnings. -- 2.45.2