From 0a310fdd5c49c8d0be7e6b473a77b26d4e73b7fd Mon Sep 17 00:00:00 2001 From: Giel van Schijndel Date: Sun, 29 Jul 2007 16:45:40 +0000 Subject: [PATCH] * Use dynamic_cast instead of a C-style (T*) cast (dynamic_cast is safer since it walks the inheritance tree to check whether the pointer is actually of type T) * Also dynamic_cast (which is compiler supported) should not be slower (if not faster) than wxWidgets' own RTTI implementation (t*)->IsKindOf(CLASSINFO(T)) This _does_ require RTTI to be enabled in wxWidgets' compilation; just enabling RTTI (as a compiler option) will only increase binary size, it should not add runtime overhead git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@2264 4a71c877-e1ca-e34f-864e-861f7616d084 --- .../editworld/src/wxDialogs/autoflagdialog.cpp | 18 +++++++++--------- .../src/wxDialogs/savesegmentdialog.cpp | 8 ++++---- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/tools/editworld/src/wxDialogs/autoflagdialog.cpp b/tools/editworld/src/wxDialogs/autoflagdialog.cpp index acc82a702..59cd7b897 100644 --- a/tools/editworld/src/wxDialogs/autoflagdialog.cpp +++ b/tools/editworld/src/wxDialogs/autoflagdialog.cpp @@ -65,15 +65,15 @@ AutoFlagDialog::AutoFlagDialog(wxWindow* parent, { //(*Initialize(AutoFlagDialog) wxXmlResource::Get()->LoadObject(this,parent,_T("AutoFlagDialog"),_T("wxDialog")); - Degree0_RadioButton = (wxRadioButton*)FindWindow(XRCID("ID_RADIO_0DEGREE")); - Degree90_RadioButton = (wxRadioButton*)FindWindow(XRCID("ID_RADIO_90DEGREE")); - Degree180_RadioButton = (wxRadioButton*)FindWindow(XRCID("ID_RADIO_180DEGREE")); - Degree270_RadioButton = (wxRadioButton*)FindWindow(XRCID("ID_RADIO_270DEGREE")); - XFlip_CheckBox = (wxCheckBox*)FindWindow(XRCID("ID_CHK_XFLIP")); - YFlip_CheckBox = (wxCheckBox*)FindWindow(XRCID("ID_CHK_YFLIP")); - RandRotate_CheckBox = (wxCheckBox*)FindWindow(XRCID("ID_CHK_RANDROTATE")); - RandXFlip_CheckBox = (wxCheckBox*)FindWindow(XRCID("ID_CHK_RANDXFLIP")); - RandYFlip_CheckBox = (wxCheckBox*)FindWindow(XRCID("ID_CHK_RANDYFLIP")); + Degree0_RadioButton = dynamic_cast(FindWindow(XRCID("ID_RADIO_0DEGREE"))); + Degree90_RadioButton = dynamic_cast(FindWindow(XRCID("ID_RADIO_90DEGREE"))); + Degree180_RadioButton = dynamic_cast(FindWindow(XRCID("ID_RADIO_180DEGREE"))); + Degree270_RadioButton = dynamic_cast(FindWindow(XRCID("ID_RADIO_270DEGREE"))); + XFlip_CheckBox = dynamic_cast(FindWindow(XRCID("ID_CHK_XFLIP"))); + YFlip_CheckBox = dynamic_cast(FindWindow(XRCID("ID_CHK_YFLIP"))); + RandRotate_CheckBox = dynamic_cast(FindWindow(XRCID("ID_CHK_RANDROTATE"))); + RandXFlip_CheckBox = dynamic_cast(FindWindow(XRCID("ID_CHK_RANDXFLIP"))); + RandYFlip_CheckBox = dynamic_cast(FindWindow(XRCID("ID_CHK_RANDYFLIP"))); Connect(XRCID("ID_RADIO_0DEGREE"),wxEVT_COMMAND_RADIOBUTTON_SELECTED,(wxObjectEventFunction)&AutoFlagDialog::OnRotate); Connect(XRCID("ID_RADIO_90DEGREE"),wxEVT_COMMAND_RADIOBUTTON_SELECTED,(wxObjectEventFunction)&AutoFlagDialog::OnRotate); Connect(XRCID("ID_RADIO_180DEGREE"),wxEVT_COMMAND_RADIOBUTTON_SELECTED,(wxObjectEventFunction)&AutoFlagDialog::OnRotate); diff --git a/tools/editworld/src/wxDialogs/savesegmentdialog.cpp b/tools/editworld/src/wxDialogs/savesegmentdialog.cpp index ee62b703f..2193c1373 100644 --- a/tools/editworld/src/wxDialogs/savesegmentdialog.cpp +++ b/tools/editworld/src/wxDialogs/savesegmentdialog.cpp @@ -61,10 +61,10 @@ SaveSegmentDialog::SaveSegmentDialog(wxWindow* parent, { //(*Initialize(SaveSegmentDialog) wxXmlResource::Get()->LoadObject(this,parent,_T("SaveSegmentDialog"),_T("wxDialog")); - StartX_TextCtrl = (wxTextCtrl*)FindWindow(XRCID("ID_TEXT_STARTX")); - StartY_TextCtrl = (wxTextCtrl*)FindWindow(XRCID("ID_TEXT_STARTY")); - Width_TextCtrl = (wxTextCtrl*)FindWindow(XRCID("ID_TEXT_WIDTH")); - Height_TextCtrl = (wxTextCtrl*)FindWindow(XRCID("ID_TEXT_HEIGHT")); + StartX_TextCtrl = dynamic_cast(FindWindow(XRCID("ID_TEXT_STARTX"))); + StartY_TextCtrl = dynamic_cast(FindWindow(XRCID("ID_TEXT_STARTY"))); + Width_TextCtrl = dynamic_cast(FindWindow(XRCID("ID_TEXT_WIDTH"))); + Height_TextCtrl = dynamic_cast(FindWindow(XRCID("ID_TEXT_HEIGHT"))); //*) // Make sure all characters entered into these text controls