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.

This commit is contained in:
jean-pierre charras 2016-08-20 19:51:33 +02:00
parent 2456db3817
commit 7e3aedda82
2 changed files with 26 additions and 8 deletions

View File

@ -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::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 ); SetKiway( this, aKiway );
@ -158,6 +158,12 @@ SIM_PLOT_FRAME::SIM_PLOT_FRAME( KIWAY* aKiway, wxWindow* aParent )
m_toolBar->Realize(); m_toolBar->Realize();
m_plotNotebook->SetPageText( 0, _( "Welcome!" ) ); 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 ); m_simulator->SetReporter( nullptr );
delete m_reporter; delete m_reporter;
if( m_settingsDlg )
m_settingsDlg->Destroy();
} }
@ -173,13 +182,16 @@ void SIM_PLOT_FRAME::StartSimulation()
STRING_FORMATTER formatter; STRING_FORMATTER formatter;
SIM_PLOT_PANEL* plotPanel = CurrentPlot(); SIM_PLOT_PANEL* plotPanel = CurrentPlot();
if( !m_settingsDlg )
m_settingsDlg = new DIALOG_SIM_SETTINGS( this );
m_simConsole->Clear(); m_simConsole->Clear();
updateNetlistExporter(); updateNetlistExporter();
if( plotPanel ) if( plotPanel )
m_exporter->SetSimCommand( m_plots[plotPanel].m_simCommand ); 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." ) ); DisplayError( this, _( "There were errors during netlist export, aborted." ) );
return; return;
@ -853,14 +865,17 @@ void SIM_PLOT_FRAME::onSettings( wxCommandEvent& event )
return; return;
} }
if( !m_settingsDlg )
m_settingsDlg = new DIALOG_SIM_SETTINGS( this );
if( plotPanel ) 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 ); SIM_TYPE newSimType = NETLIST_EXPORTER_PSPICE_SIM::CommandToSimType( newCommand );
// If it is a new simulation type, open a new plot // If it is a new simulation type, open a new plot

View File

@ -292,8 +292,11 @@ private:
///> List of currently displayed tuners ///> List of currently displayed tuners
std::list<TUNER_SLIDER*> m_tuners; std::list<TUNER_SLIDER*> m_tuners;
// Trick to preserve settings between runs // Trick to preserve settings between runs:
DIALOG_SIM_SETTINGS m_settingsDlg; // 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 // Right click context menu for signals in the listbox
class SIGNAL_CONTEXT_MENU : public wxMenu class SIGNAL_CONTEXT_MENU : public wxMenu