@@ -85,11 +85,7 @@ MainFrame::MainFrame(wxWindow* parent, wxWindowID id, const wxString& caption, c
85
85
Create ( parent, id, caption, pos, size, style );
86
86
}
87
87
88
- MainFrame::~MainFrame () {
89
- if (controller != nullptr ) {
90
- delete controller;
91
- }
92
- }
88
+ MainFrame::~MainFrame () {}
93
89
94
90
/* !
95
91
* MainFrame creator
@@ -105,7 +101,7 @@ bool MainFrame::Create(wxWindow* parent, wxWindowID id, const wxString& caption,
105
101
SetIcon (GetIconResource (wxT (" res/nwnx4_icon.xpm" )));
106
102
// //@end MainFrame creation
107
103
108
- m_logger = new wxLogTextCtrl (m_log);
104
+ m_logger = new wxLogTextCtrl (m_log);
109
105
wxLog::SetActiveTarget (m_logger);
110
106
111
107
wxLogMessage (wxT (" Running in GUI mode." ));
@@ -114,22 +110,21 @@ bool MainFrame::Create(wxWindow* parent, wxWindowID id, const wxString& caption,
114
110
m_startedAt->AppendText (now.Format ());
115
111
116
112
// open ini file
117
- std::string inifile{" nwnx.ini" };
118
- auto config = SimpleIniConfig{inifile};
113
+ m_config = std::make_unique<SimpleIniConfig>(" nwnx.ini" );
119
114
120
- controller = new NWNXController{&config} ;
115
+ m_controller = std::make_unique< NWNXController>(m_config. get ()) ;
121
116
122
- m_CmdLine->AppendText (controller ->parameters );
123
- m_PWEnabled->SetValue (controller ->processWatchdog );
124
- m_GWEnabled->SetValue (controller ->gamespyWatchdog );
117
+ m_CmdLine->AppendText (m_controller ->parameters );
118
+ m_PWEnabled->SetValue (m_controller ->processWatchdog );
119
+ m_GWEnabled->SetValue (m_controller ->gamespyWatchdog );
125
120
m_PWInterval->AppendText (wxT (" 1" ));
126
- m_GWInterval->AppendText (wxString::Format (wxT (" %d" ), controller ->gamespyInterval ));
127
- m_GWRetries->AppendText (wxString::Format (wxT (" %d" ), controller ->gamespyTolerance ));
121
+ m_GWInterval->AppendText (wxString::Format (wxT (" %d" ), m_controller ->gamespyInterval ));
122
+ m_GWRetries->AppendText (wxString::Format (wxT (" %d" ), m_controller ->gamespyTolerance ));
128
123
129
124
m_BtnStop->Enable (false );
130
125
131
126
// Create worker thread
132
- worker = new NWNXWorker (controller , this );
127
+ worker = std::make_unique< NWNXWorker>(m_controller. get () , this );
133
128
if (worker->Create () != wxTHREAD_NO_ERROR)
134
129
{
135
130
wxLogError (wxT (" Can't create worker thread!" ));
@@ -444,8 +439,8 @@ void MainFrame::OnServerStopped(wxCommandEvent &event)
444
439
445
440
void MainFrame::OnPwEnabledClick ( wxCommandEvent& event )
446
441
{
447
- controller ->processWatchdog = m_PWEnabled->GetValue ();
448
- if (controller ->processWatchdog )
442
+ m_controller ->processWatchdog = m_PWEnabled->GetValue ();
443
+ if (m_controller ->processWatchdog )
449
444
wxLogMessage (wxT (" Process watchdog set to: enabled" ));
450
445
else
451
446
wxLogMessage (wxT (" Process watchdog set to: disabled" ));
@@ -458,8 +453,8 @@ void MainFrame::OnPwEnabledClick( wxCommandEvent& event )
458
453
459
454
void MainFrame::OnGwEnabledClick ( wxCommandEvent& event )
460
455
{
461
- controller ->gamespyWatchdog = m_GWEnabled->GetValue ();
462
- if (controller ->gamespyWatchdog )
456
+ m_controller ->gamespyWatchdog = m_GWEnabled->GetValue ();
457
+ if (m_controller ->gamespyWatchdog )
463
458
wxLogMessage (wxT (" Gamespy watchdog set to: enabled" ));
464
459
else
465
460
wxLogMessage (wxT (" Gamespy watchdog set to: disabled" ));
0 commit comments