fix some memory leaks (valgrind)
This commit is contained in:
parent
e0f4ad5ccc
commit
01bc7fa02f
|
@ -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());
|
||||
}
|
||||
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
|
||||
#include <wx/frame.h>
|
||||
#include <wx/event.h>
|
||||
#include <wx/statusbr.h>
|
||||
#include <string>
|
||||
|
||||
class E2wxFrame : public wxFrame {
|
||||
|
@ -52,6 +53,8 @@ private:
|
|||
void OnToggleBuffered(wxCommandEvent& event);
|
||||
|
||||
wxDECLARE_EVENT_TABLE();
|
||||
|
||||
wxStatusBar *statusBar;
|
||||
};
|
||||
|
||||
#endif /* E2WXFRAME_H */
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -39,6 +39,7 @@ private:
|
|||
bool buffer;
|
||||
AnalogTV::DisplayType display;
|
||||
void createScreen();
|
||||
void destroyScreen();
|
||||
std::vector<std::string> slotnames;
|
||||
std::string cassInName;
|
||||
std::string cassOutName;
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue