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() {
|
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));
|
miPaste->AddExtraAccel(wxAcceleratorEntry(wxACCEL_NORMAL, WXK_F7));
|
||||||
menuEdit->AppendSeparator();
|
menuEdit->AppendSeparator();
|
||||||
wxMenuItem *miPrefs = menuEdit->Append(wxID_PREFERENCES);
|
wxMenuItem *miPrefs = menuEdit->Append(wxID_PREFERENCES);
|
||||||
miPrefs->SetAccel(new wxAcceleratorEntry(wxACCEL_CTRL, ','));
|
miPrefs->SetAccel(new wxAcceleratorEntry(wxACCEL_CTRL, 44));
|
||||||
|
|
||||||
|
|
||||||
wxMenu *menuMachine = new wxMenu();
|
wxMenu *menuMachine = new wxMenu();
|
||||||
|
@ -121,7 +125,7 @@ void E2wxFrame::InitMenuBar() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void E2wxFrame::InitStatusBar() {
|
void E2wxFrame::InitStatusBar() {
|
||||||
CreateStatusBar();
|
this->statusBar = CreateStatusBar();
|
||||||
SetStatusText("Welcome to "+wxGetApp().GetID());
|
SetStatusText("Welcome to "+wxGetApp().GetID());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
|
|
||||||
#include <wx/frame.h>
|
#include <wx/frame.h>
|
||||||
#include <wx/event.h>
|
#include <wx/event.h>
|
||||||
|
#include <wx/statusbr.h>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
class E2wxFrame : public wxFrame {
|
class E2wxFrame : public wxFrame {
|
||||||
|
@ -52,6 +53,8 @@ private:
|
||||||
void OnToggleBuffered(wxCommandEvent& event);
|
void OnToggleBuffered(wxCommandEvent& event);
|
||||||
|
|
||||||
wxDECLARE_EVENT_TABLE();
|
wxDECLARE_EVENT_TABLE();
|
||||||
|
|
||||||
|
wxStatusBar *statusBar;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* E2WXFRAME_H */
|
#endif /* E2WXFRAME_H */
|
||||||
|
|
|
@ -186,6 +186,7 @@ void E2Command::tryParseLine(const std::string& line, MemoryRandomAccess& ram, M
|
||||||
trim(file);
|
trim(file);
|
||||||
std::ifstream *memfile = new std::ifstream(file.c_str(), std::ios::binary);
|
std::ifstream *memfile = new std::ifstream(file.c_str(), std::ios::binary);
|
||||||
if (!memfile->is_open()) {
|
if (!memfile->is_open()) {
|
||||||
|
delete memfile;
|
||||||
std::filesystem::path f = wxGetApp().GetResDir();
|
std::filesystem::path f = wxGetApp().GetResDir();
|
||||||
f /= file;
|
f /= file;
|
||||||
memfile = new std::ifstream(f, std::ios::binary);
|
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");
|
throw ConfigException("error at \"" + romtype + "\"; expected rom, rom7, or rombank");
|
||||||
}
|
}
|
||||||
memfile->close();
|
memfile->close();
|
||||||
|
delete memfile;
|
||||||
} else if (cmd == "load" || cmd == "save" || cmd == "unload") {
|
} else if (cmd == "load" || cmd == "save" || cmd == "unload") {
|
||||||
std::string slotk;
|
std::string slotk;
|
||||||
tok >> slotk;
|
tok >> slotk;
|
||||||
|
|
|
@ -57,15 +57,19 @@ class ScreenException {
|
||||||
};
|
};
|
||||||
|
|
||||||
ScreenImage::ScreenImage() :
|
ScreenImage::ScreenImage() :
|
||||||
fullscreen(false),
|
fullscreen(false),
|
||||||
buffer(true),
|
buffer(true),
|
||||||
display(AnalogTV::TV_OLD_COLOR),
|
display(AnalogTV::TV_OLD_COLOR),
|
||||||
slotnames(8),
|
slotnames(8),
|
||||||
cassInName(32, ' '),
|
cassInName(32, ' '),
|
||||||
cassOutName(32, ' ') {
|
cassOutName(32, ' ') {
|
||||||
createScreen();
|
createScreen();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ScreenImage::~ScreenImage() {
|
||||||
|
destroyScreen();
|
||||||
|
}
|
||||||
|
|
||||||
void ScreenImage::exitFullScreen() {
|
void ScreenImage::exitFullScreen() {
|
||||||
if (this->fullscreen) {
|
if (this->fullscreen) {
|
||||||
toggleFullScreen();
|
toggleFullScreen();
|
||||||
|
@ -106,6 +110,12 @@ void ScreenImage::createScreen() {
|
||||||
notifyObservers();
|
notifyObservers();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ScreenImage::destroyScreen() {
|
||||||
|
SDL_DestroyTexture(this->texture);
|
||||||
|
SDL_DestroyRenderer(this->renderer);
|
||||||
|
SDL_DestroyWindow(this->window);
|
||||||
|
}
|
||||||
|
|
||||||
void ScreenImage::drawLabels() {
|
void ScreenImage::drawLabels() {
|
||||||
drawText("EPPLE ][", 0, 141);
|
drawText("EPPLE ][", 0, 141);
|
||||||
drawText("ANNUNCIATORS: 0: 1: 2: 3:", 65, 17);
|
drawText("ANNUNCIATORS: 0: 1: 2: 3:", 65, 17);
|
||||||
|
@ -275,9 +285,6 @@ void ScreenImage::drawPower(bool on) {
|
||||||
notifyObservers();
|
notifyObservers();
|
||||||
}
|
}
|
||||||
|
|
||||||
ScreenImage::~ScreenImage() {
|
|
||||||
}
|
|
||||||
|
|
||||||
void ScreenImage::notifyObservers() {
|
void ScreenImage::notifyObservers() {
|
||||||
const int e = SDL_UpdateTexture(this->texture, NULL, this->pixels, SCRW * sizeof (unsigned int));
|
const int e = SDL_UpdateTexture(this->texture, NULL, this->pixels, SCRW * sizeof (unsigned int));
|
||||||
if (e) {
|
if (e) {
|
||||||
|
|
|
@ -39,6 +39,7 @@ private:
|
||||||
bool buffer;
|
bool buffer;
|
||||||
AnalogTV::DisplayType display;
|
AnalogTV::DisplayType display;
|
||||||
void createScreen();
|
void createScreen();
|
||||||
|
void destroyScreen();
|
||||||
std::vector<std::string> slotnames;
|
std::vector<std::string> slotnames;
|
||||||
std::string cassInName;
|
std::string cassInName;
|
||||||
std::string cassOutName;
|
std::string cassOutName;
|
||||||
|
|
|
@ -29,6 +29,9 @@ Slots::Slots(ScreenImage& gui):
|
||||||
|
|
||||||
Slots::~Slots()
|
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)
|
unsigned char Slots::io(const int islot, const int iswch, const unsigned char b, const bool writing)
|
||||||
|
|
Loading…
Reference in New Issue