From 7e3aedda823e53a9562a8bf3c7bae28d76c907e8 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Sat, 20 Aug 2016 19:51:33 +0200 Subject: [PATCH] Slightly modify the way DIALOG_SIM_SETTINGS m_settingsDlg is created in SIM_PLOT_FRAME frame: for an obscure reason, if it is created in ctor SIM_PLOT_FRAME, m_settingsDlg has an annoying issue on Windows: when shown, the parent SIM_PLOT_FRAME is sent to the background. When created outside the ctor, this issue is gone. --- eeschema/sim/sim_plot_frame.cpp | 27 +++++++++++++++++++++------ eeschema/sim/sim_plot_frame.h | 7 +++++-- 2 files changed, 26 insertions(+), 8 deletions(-) diff --git a/eeschema/sim/sim_plot_frame.cpp b/eeschema/sim/sim_plot_frame.cpp index 719e7e4bec..db994b946b 100644 --- a/eeschema/sim/sim_plot_frame.cpp +++ b/eeschema/sim/sim_plot_frame.cpp @@ -100,7 +100,7 @@ TRACE_DESC::TRACE_DESC( const NETLIST_EXPORTER_PSPICE_SIM& aExporter, const wxSt SIM_PLOT_FRAME::SIM_PLOT_FRAME( KIWAY* aKiway, wxWindow* aParent ) - : SIM_PLOT_FRAME_BASE( aParent ), m_settingsDlg( this ), m_lastSimPlot( nullptr ) + : SIM_PLOT_FRAME_BASE( aParent ), m_lastSimPlot( nullptr ) { SetKiway( this, aKiway ); @@ -158,6 +158,12 @@ SIM_PLOT_FRAME::SIM_PLOT_FRAME( KIWAY* aKiway, wxWindow* aParent ) m_toolBar->Realize(); m_plotNotebook->SetPageText( 0, _( "Welcome!" ) ); + + // the settings dialog will be created later, on demand. + // if created in the ctor, for some obscure reason, there is an issue + // on Windows: when open it, the simulator frame is sent to the background. + // instead of beeing behind the dialog frame (as it does) + m_settingsDlg = NULL; } @@ -165,6 +171,9 @@ SIM_PLOT_FRAME::~SIM_PLOT_FRAME() { m_simulator->SetReporter( nullptr ); delete m_reporter; + + if( m_settingsDlg ) + m_settingsDlg->Destroy(); } @@ -173,13 +182,16 @@ void SIM_PLOT_FRAME::StartSimulation() STRING_FORMATTER formatter; SIM_PLOT_PANEL* plotPanel = CurrentPlot(); + if( !m_settingsDlg ) + m_settingsDlg = new DIALOG_SIM_SETTINGS( this ); + m_simConsole->Clear(); updateNetlistExporter(); if( plotPanel ) m_exporter->SetSimCommand( m_plots[plotPanel].m_simCommand ); - if( !m_exporter->Format( &formatter, m_settingsDlg.GetNetlistOptions() ) ) + if( !m_exporter->Format( &formatter, m_settingsDlg->GetNetlistOptions() ) ) { DisplayError( this, _( "There were errors during netlist export, aborted." ) ); return; @@ -853,14 +865,17 @@ void SIM_PLOT_FRAME::onSettings( wxCommandEvent& event ) return; } + if( !m_settingsDlg ) + m_settingsDlg = new DIALOG_SIM_SETTINGS( this ); + if( plotPanel ) - m_settingsDlg.SetSimCommand( m_plots[plotPanel].m_simCommand ); + m_settingsDlg->SetSimCommand( m_plots[plotPanel].m_simCommand ); - m_settingsDlg.SetNetlistExporter( m_exporter.get() ); + m_settingsDlg->SetNetlistExporter( m_exporter.get() ); - if( m_settingsDlg.ShowModal() == wxID_OK ) + if( m_settingsDlg->ShowModal() == wxID_OK ) { - wxString newCommand = m_settingsDlg.GetSimCommand(); + wxString newCommand = m_settingsDlg->GetSimCommand(); SIM_TYPE newSimType = NETLIST_EXPORTER_PSPICE_SIM::CommandToSimType( newCommand ); // If it is a new simulation type, open a new plot diff --git a/eeschema/sim/sim_plot_frame.h b/eeschema/sim/sim_plot_frame.h index 563483643a..e7c57aceb7 100644 --- a/eeschema/sim/sim_plot_frame.h +++ b/eeschema/sim/sim_plot_frame.h @@ -292,8 +292,11 @@ private: ///> List of currently displayed tuners std::list m_tuners; - // Trick to preserve settings between runs - DIALOG_SIM_SETTINGS m_settingsDlg; + // Trick to preserve settings between runs: + // the DIALOG_SIM_SETTINGS is not destroyed after closing the dialog. + // Once created it will be not shown (shown only on request) during a session + // and will be destroyed only when closing the simulator frame. + DIALOG_SIM_SETTINGS* m_settingsDlg; // Right click context menu for signals in the listbox class SIGNAL_CONTEXT_MENU : public wxMenu