mirror of
https://github.com/cookiengineer/audacity
synced 2025-06-28 06:08:40 +02:00
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.
This commit is contained in:
parent
72dfbcc587
commit
3d8a9ffad9
@ -924,7 +924,7 @@ bool AudacityApp::ShouldShowMissingAliasedFileWarning()
|
||||
|
||||
AudacityLogger *AudacityApp::GetLogger()
|
||||
{
|
||||
return wxDynamicCast(wxLog::GetActiveTarget(), AudacityLogger);
|
||||
return static_cast<AudacityLogger *>(wxLog::GetActiveTarget());
|
||||
}
|
||||
|
||||
void AudacityApp::InitLang( const wxString & lang )
|
||||
|
Loading…
x
Reference in New Issue
Block a user