From 3d8a9ffad9f8e347a394ae160adc74edc667090f Mon Sep 17 00:00:00 2001 From: "james.k.crook@gmail.com" Date: Thu, 13 Nov 2014 20:56:13 +0000 Subject: [PATCH] Fix crash with wxWidgets 3.0: Opening the logger dialog caused a segmentation fault due to an incorrect cast (superseding r13426). [Patch 0020] From martin@steghoefer.eu The casting macros wxStaticCast and wxDynamicCast from wxWidgets only work within the hierarchy registered to the wxWidgets class runtime information. But neither the base class wxLog nor the derived class AudacityLogger involved in the cast qualify for this. This error wasn't visible with wxWidgets 2.8 because asserts weren't activated there by default, which prevented the code that causes the invalid memory access from being executed. Note: After original creation of this fix, the line causing the crash has been changed in r13426 from using wxStaticCast to wxDynamicCast, which avoids the crash for now thanks to a lucky coincidence. It's still not the desired behaviour (before this fix the runtime type check only checked for wxEvtHandler instead of AudacityLogger) and could start to crash again, depending on implementation details of wxDynamicCast. Hence this fix was still needed, and it was adjusted accordingly. --- src/AudacityApp.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/AudacityApp.cpp b/src/AudacityApp.cpp index 84bdbf71e..7c12dca00 100644 --- a/src/AudacityApp.cpp +++ b/src/AudacityApp.cpp @@ -924,7 +924,7 @@ bool AudacityApp::ShouldShowMissingAliasedFileWarning() AudacityLogger *AudacityApp::GetLogger() { - return wxDynamicCast(wxLog::GetActiveTarget(), AudacityLogger); + return static_cast(wxLog::GetActiveTarget()); } void AudacityApp::InitLang( const wxString & lang )