From 83169af988293c4577c84782ea71e00c6143598a Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Fri, 14 Apr 2017 13:02:21 +0200 Subject: [PATCH] Code refinement for commit 80371134d726f25da23a28334a5fcba9029f0bfd --- pcbnew/modview_frame.cpp | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/pcbnew/modview_frame.cpp b/pcbnew/modview_frame.cpp index 62290a49e5..d8693c926a 100644 --- a/pcbnew/modview_frame.cpp +++ b/pcbnew/modview_frame.cpp @@ -194,15 +194,20 @@ FOOTPRINT_VIEWER_FRAME::FOOTPRINT_VIEWER_FRAME( KIWAY* aKiway, wxWindow* aParent // See for an existing board editor frame opened // (we need it just to know some settings ) + // TODO: find a better way to retrieve these settings) bool isBordEditorRunning = Kiway().Player( FRAME_PCB, false ) != nullptr; - - PCB_BASE_FRAME* parentFrame = static_cast( Kiway().Player( FRAME_PCB, true ) ); + PCB_BASE_FRAME* pcbEditorFrame = static_cast( Kiway().Player( FRAME_PCB, true ) ); // Create GAL canvas PCB_DRAW_PANEL_GAL* drawPanel = new PCB_DRAW_PANEL_GAL( this, -1, wxPoint( 0, 0 ), m_FrameSize, - parentFrame->GetGalDisplayOptions(), - parentFrame->GetGalCanvas()->GetBackend() ); + pcbEditorFrame->GetGalDisplayOptions(), + pcbEditorFrame->GetGalCanvas()->GetBackend() ); SetGalCanvas( drawPanel ); + bool switchToGalCanvas = pcbEditorFrame->IsGalCanvasActive(); + + // delete pcbEditorFrame if it was not yet in use: + if( !isBordEditorRunning ) + pcbEditorFrame->Destroy(); // Create the manager and dispatcher & route draw panel events to the dispatcher m_toolManager = new TOOL_MANAGER; @@ -295,10 +300,7 @@ FOOTPRINT_VIEWER_FRAME::FOOTPRINT_VIEWER_FRAME( KIWAY* aKiway, wxWindow* aParent Zoom_Automatique( false ); #endif - UseGalCanvas( parentFrame->IsGalCanvasActive() ); - - if( !isBordEditorRunning && IsModal() ) - parentFrame->Destroy(); + UseGalCanvas( switchToGalCanvas ); if( !IsModal() ) // For modal mode, calling ShowModal() will show this frame {