Code refinement for commit 80371134d7

This commit is contained in:
jean-pierre charras 2017-04-14 13:02:21 +02:00
parent a208ba6566
commit 83169af988
1 changed files with 10 additions and 8 deletions

View File

@ -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<PCB_BASE_FRAME*>( Kiway().Player( FRAME_PCB, true ) );
PCB_BASE_FRAME* pcbEditorFrame = static_cast<PCB_BASE_FRAME*>( 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
{