From 04b5ccbdb2ef858fbbde8d4f1de8cce3f8b5b0e9 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Sat, 7 Dec 2024 19:32:43 +0000 Subject: [PATCH] Reduce dependency on dynamic_cast. --- common/widgets/footprint_preview_widget.cpp | 13 ++++--------- pcbnew/project_pcb.cpp | 4 ++-- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/common/widgets/footprint_preview_widget.cpp b/common/widgets/footprint_preview_widget.cpp index 2b0f882501..c736f31718 100644 --- a/common/widgets/footprint_preview_widget.cpp +++ b/common/widgets/footprint_preview_widget.cpp @@ -135,21 +135,16 @@ void FOOTPRINT_PREVIEW_WIDGET::RefreshAll() FOOTPRINT_PREVIEW_PANEL_BASE* FOOTPRINT_PREVIEW_PANEL_BASE::Create( wxWindow* aParent, KIWAY& aKiway ) { - FOOTPRINT_PREVIEW_PANEL_BASE* panel = nullptr; + wxWindow* panel = nullptr; try { - KIFACE* kiface = aKiway.KiFACE( KIWAY::FACE_PCB ); - wxWindow* window = kiface->CreateKiWindow( aParent, FRAME_FOOTPRINT_PREVIEW, &aKiway ); - - panel = dynamic_cast( window ); - - if( window && !panel ) - delete window; + if( KIFACE* kiface = aKiway.KiFACE( KIWAY::FACE_PCB ) ) + panel = kiface->CreateKiWindow( aParent, FRAME_FOOTPRINT_PREVIEW, &aKiway ); } catch( ... ) { } - return panel; + return (FOOTPRINT_PREVIEW_PANEL_BASE*) panel; } diff --git a/pcbnew/project_pcb.cpp b/pcbnew/project_pcb.cpp index 78a5885601..3d3ec74e96 100644 --- a/pcbnew/project_pcb.cpp +++ b/pcbnew/project_pcb.cpp @@ -79,7 +79,7 @@ S3D_CACHE* PROJECT_PCB::Get3DCacheManager( PROJECT* aProject, bool aUpdateProjDi std::lock_guard lock( mutex3D_cacheManager ); // Get the existing cache from the project - S3D_CACHE* cache = dynamic_cast( aProject->GetElem( PROJECT::ELEM::S3DCACHE ) ); + S3D_CACHE* cache = static_cast( aProject->GetElem( PROJECT::ELEM::S3DCACHE ) ); if( !cache ) { @@ -115,7 +115,7 @@ void PROJECT_PCB::Cleanup3DCache( PROJECT* aProject ) std::lock_guard lock( mutex3D_cacheManager ); // Get the existing cache from the project - S3D_CACHE* cache = dynamic_cast( aProject->GetElem( PROJECT::ELEM::S3DCACHE ) ); + S3D_CACHE* cache = static_cast( aProject->GetElem( PROJECT::ELEM::S3DCACHE ) ); if( cache ) {