mirror of
https://gitlab.com/manzerbredes/ochess.git
synced 2025-04-12 00:58:34 +00:00
Improve Game and HalfMoves memory management
This commit is contained in:
parent
a8c59c41bc
commit
4c959fe12e
6 changed files with 19 additions and 3 deletions
|
@ -22,6 +22,12 @@ Game::Game(HalfMove *m, std::string initial_fen): result("*") {
|
|||
board = chessarbiter::FENParser::Parse(initial_fen).board;
|
||||
}
|
||||
|
||||
Game::~Game() {
|
||||
if (moves != NULL) {
|
||||
delete moves;
|
||||
}
|
||||
}
|
||||
|
||||
std::string Game::GetBoard() { return (board); }
|
||||
|
||||
std::string Game::GetTag(std::string tagname) { return (tags[tagname]); }
|
||||
|
|
|
@ -18,7 +18,7 @@ public:
|
|||
Game();
|
||||
Game(std::string fen);
|
||||
Game(HalfMove *m, std::string initial_fen);
|
||||
|
||||
~Game();
|
||||
std::string GetBoard();
|
||||
std::string GetTag(std::string tagname);
|
||||
void SetTag(std::string tagname, std::string value);
|
||||
|
|
|
@ -30,6 +30,10 @@ GameTab::GameTab(wxFrame *parent, Game *game)
|
|||
Bind(GAME_CHANGE, &GameTab::OnGameChange, this, wxID_ANY);
|
||||
}
|
||||
|
||||
GameTab::~GameTab() {
|
||||
delete game;
|
||||
}
|
||||
|
||||
void GameTab::OnGameChange(wxCommandEvent &event) {
|
||||
board_panel->Notify();
|
||||
editor_panel->Notify();
|
||||
|
|
|
@ -17,12 +17,14 @@ class GameTab : public wxPanel, public TabInfos {
|
|||
GameTabRightPanel *editor_panel;
|
||||
GameTabLeftPanel *board_panel;
|
||||
Game *game;
|
||||
|
||||
void RefreshLabel();
|
||||
void OnRefreshTabTitle(wxCommandEvent &event);
|
||||
void OnGameChange(wxCommandEvent &event);
|
||||
|
||||
public:
|
||||
GameTab(wxFrame *parent, Game *game);
|
||||
~GameTab();
|
||||
void ApplyPreferences();
|
||||
void *GetGame() { return (game); }
|
||||
void *GetBase() { return (NULL); };
|
||||
|
|
|
@ -10,6 +10,9 @@ HalfMove::HalfMove(std::string move, std::string fen) : fen(fen), capture(' ') {
|
|||
}
|
||||
|
||||
HalfMove::~HalfMove() {
|
||||
if (mainline != NULL) {
|
||||
delete mainline;
|
||||
}
|
||||
for (HalfMove *m : variations) {
|
||||
delete m;
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#include <wx/filefn.h> // Check file exists etc
|
||||
#include <wx/log.h>
|
||||
#include "gui.h"
|
||||
#include <memory>
|
||||
|
||||
#define MAINWIN ((MainWindow *)wxGetApp().GetTopWindow())
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue