diff --git a/src/E2wxFrame.cpp b/src/E2wxFrame.cpp index 9f40779..b0a487d 100644 --- a/src/E2wxFrame.cpp +++ b/src/E2wxFrame.cpp @@ -56,10 +56,14 @@ wxEND_EVENT_TABLE() -E2wxFrame::E2wxFrame() : wxFrame(nullptr, wxID_ANY, "epple2") { +E2wxFrame::E2wxFrame() : wxFrame(nullptr, wxID_ANY, "epple2"), statusBar(nullptr) { } E2wxFrame::~E2wxFrame() { + if (this->statusBar) { + delete this->statusBar; + this->statusBar = nullptr; + } } @@ -89,7 +93,7 @@ void E2wxFrame::InitMenuBar() { miPaste->AddExtraAccel(wxAcceleratorEntry(wxACCEL_NORMAL, WXK_F7)); menuEdit->AppendSeparator(); wxMenuItem *miPrefs = menuEdit->Append(wxID_PREFERENCES); - miPrefs->SetAccel(new wxAcceleratorEntry(wxACCEL_CTRL, ',')); + miPrefs->SetAccel(new wxAcceleratorEntry(wxACCEL_CTRL, 44)); wxMenu *menuMachine = new wxMenu(); @@ -121,7 +125,7 @@ void E2wxFrame::InitMenuBar() { } void E2wxFrame::InitStatusBar() { - CreateStatusBar(); + this->statusBar = CreateStatusBar(); SetStatusText("Welcome to "+wxGetApp().GetID()); } diff --git a/src/E2wxFrame.h b/src/E2wxFrame.h index 62a1624..3994004 100644 --- a/src/E2wxFrame.h +++ b/src/E2wxFrame.h @@ -23,6 +23,7 @@ #include #include +#include #include class E2wxFrame : public wxFrame { @@ -52,6 +53,8 @@ private: void OnToggleBuffered(wxCommandEvent& event); wxDECLARE_EVENT_TABLE(); + + wxStatusBar *statusBar; }; #endif /* E2WXFRAME_H */ diff --git a/src/e2command.cpp b/src/e2command.cpp index a41d2ad..ebb9eb9 100644 --- a/src/e2command.cpp +++ b/src/e2command.cpp @@ -186,6 +186,7 @@ void E2Command::tryParseLine(const std::string& line, MemoryRandomAccess& ram, M trim(file); std::ifstream *memfile = new std::ifstream(file.c_str(), std::ios::binary); if (!memfile->is_open()) { + delete memfile; std::filesystem::path f = wxGetApp().GetResDir(); f /= file; memfile = new std::ifstream(f, std::ios::binary); @@ -216,6 +217,7 @@ void E2Command::tryParseLine(const std::string& line, MemoryRandomAccess& ram, M throw ConfigException("error at \"" + romtype + "\"; expected rom, rom7, or rombank"); } memfile->close(); + delete memfile; } else if (cmd == "load" || cmd == "save" || cmd == "unload") { std::string slotk; tok >> slotk; diff --git a/src/screenimage.cpp b/src/screenimage.cpp index 668feec..331b803 100644 --- a/src/screenimage.cpp +++ b/src/screenimage.cpp @@ -57,15 +57,19 @@ class ScreenException { }; ScreenImage::ScreenImage() : -fullscreen(false), -buffer(true), -display(AnalogTV::TV_OLD_COLOR), -slotnames(8), -cassInName(32, ' '), -cassOutName(32, ' ') { + fullscreen(false), + buffer(true), + display(AnalogTV::TV_OLD_COLOR), + slotnames(8), + cassInName(32, ' '), + cassOutName(32, ' ') { createScreen(); } +ScreenImage::~ScreenImage() { + destroyScreen(); +} + void ScreenImage::exitFullScreen() { if (this->fullscreen) { toggleFullScreen(); @@ -106,6 +110,12 @@ void ScreenImage::createScreen() { notifyObservers(); } +void ScreenImage::destroyScreen() { + SDL_DestroyTexture(this->texture); + SDL_DestroyRenderer(this->renderer); + SDL_DestroyWindow(this->window); +} + void ScreenImage::drawLabels() { drawText("EPPLE ][", 0, 141); drawText("ANNUNCIATORS: 0: 1: 2: 3:", 65, 17); @@ -275,9 +285,6 @@ void ScreenImage::drawPower(bool on) { notifyObservers(); } -ScreenImage::~ScreenImage() { -} - void ScreenImage::notifyObservers() { const int e = SDL_UpdateTexture(this->texture, NULL, this->pixels, SCRW * sizeof (unsigned int)); if (e) { diff --git a/src/screenimage.h b/src/screenimage.h index ad0432f..8fd969a 100644 --- a/src/screenimage.h +++ b/src/screenimage.h @@ -39,6 +39,7 @@ private: bool buffer; AnalogTV::DisplayType display; void createScreen(); + void destroyScreen(); std::vector slotnames; std::string cassInName; std::string cassOutName; diff --git a/src/slots.cpp b/src/slots.cpp index 2a8068d..118e213 100644 --- a/src/slots.cpp +++ b/src/slots.cpp @@ -29,6 +29,9 @@ Slots::Slots(ScreenImage& gui): Slots::~Slots() { + for (Card *card : this->cards) { + delete card; + } } unsigned char Slots::io(const int islot, const int iswch, const unsigned char b, const bool writing)