mirror of
https://gitlab.com/manzerbredes/ochess.git
synced 2025-07-15 08:07:40 +00:00
Fix majors memory leaks (TODO: shared_ptr for Game objects and implement ~Game())
This commit is contained in:
parent
8f1e8fa106
commit
a8c59c41bc
12 changed files with 40 additions and 4 deletions
|
@ -17,8 +17,11 @@ AppendGameDialog::AppendGameDialog(wxWindow *parent, GameBase *base)
|
|||
ID_DIALOG_CANCEL_BUTTON);
|
||||
Bind(wxEVT_BUTTON, &AppendGameDialog::OnImport, this,
|
||||
ID_DIALOG_IMPORT_BUTTON);
|
||||
Bind(wxEVT_CLOSE_WINDOW, &AppendGameDialog::OnClose, this);
|
||||
}
|
||||
|
||||
void AppendGameDialog::OnClose(wxCloseEvent &e) { Destroy(); }
|
||||
|
||||
void AppendGameDialog::OnCancel(wxCommandEvent &event) { this->Close(); }
|
||||
|
||||
void AppendGameDialog::OnImport(wxCommandEvent &event) {
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
#include "gamebase/GameBase.hpp"
|
||||
|
||||
class AppendGameDialog : public DialogAppendGame {
|
||||
GameBase *base;
|
||||
GameBase *base; // Should not be destroy
|
||||
std::vector<TabInfos *> tinfos;
|
||||
|
||||
public:
|
||||
AppendGameDialog(wxWindow *parent, GameBase *base);
|
||||
void OnCancel(wxCommandEvent &event);
|
||||
void OnImport(wxCommandEvent &event);
|
||||
void OnClose(wxCloseEvent &e);
|
||||
};
|
|
@ -24,6 +24,10 @@ BaseTab::BaseTab(wxFrame *parent, std::string base_file)
|
|||
LoadFile();
|
||||
}
|
||||
|
||||
BaseTab::~BaseTab() {
|
||||
delete base;
|
||||
}
|
||||
|
||||
void BaseTab::OnImport(wxCommandEvent &event) {
|
||||
AppendGameDialog *dia = new AppendGameDialog(this, base);
|
||||
dia->ShowModal();
|
||||
|
|
|
@ -15,6 +15,7 @@ class BaseTab : public TabBase, public TabInfos {
|
|||
|
||||
public:
|
||||
BaseTab(wxFrame *parent, std::string base_file);
|
||||
~BaseTab();
|
||||
void ApplyPreferences();
|
||||
void LoadFile();
|
||||
void OnDelete(wxCommandEvent &event);
|
||||
|
|
|
@ -6,6 +6,10 @@ PGNGameBase::PGNGameBase(std::string pgn_file) : pgn(new pgnp::PGN()) {
|
|||
pgn->FromFile(pgn_file);
|
||||
}
|
||||
|
||||
PGNGameBase::~PGNGameBase() {
|
||||
delete pgn; // Should never fail since pgn is never NULL
|
||||
}
|
||||
|
||||
bool PGNGameBase::NextGame() {
|
||||
bool game_found = false;
|
||||
try {
|
||||
|
|
|
@ -8,6 +8,7 @@ class PGNGameBase : public GameBase {
|
|||
|
||||
public:
|
||||
PGNGameBase(std::string pgn_file);
|
||||
~PGNGameBase();
|
||||
Game *GetGame(std::uint32_t id);
|
||||
bool NextGame();
|
||||
Game *GetCurrentGame();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue