aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLoic Guegan <manzerbredes@mailbox.org>2023-01-31 14:05:28 +0100
committerLoic Guegan <manzerbredes@mailbox.org>2023-01-31 14:05:28 +0100
commitd0e8abf2c50286733fc7c7d03d3ad752555194a0 (patch)
tree271d992f640f37b3287338752318ff42a67d6fc6 /src
parentaadfef20c89599ad2091811f3c25926fdf175253 (diff)
Versioning configuration file
Diffstat (limited to 'src')
-rw-r--r--src/ochess.cpp13
-rw-r--r--src/ochess.hpp2
2 files changed, 14 insertions, 1 deletions
diff --git a/src/ochess.cpp b/src/ochess.cpp
index 7e212f8..bf3a2ce 100644
--- a/src/ochess.cpp
+++ b/src/ochess.cpp
@@ -5,8 +5,21 @@
bool MyApp::OnInit() {
wxImage::AddHandler(new wxPNGHandler);
+ // Check config version
+ CONFIG_OPEN(conf);
+ wxString version=conf->Read("version",CONFIG_VERSION);
+ conf->Write("version",version); // Setup config file version
+ wxLogDebug("Starting ochess with configuration file version %s",version);
+ CONFIG_CLOSE(conf);
+
+ // Advertise for configuration file version
+ if(version != CONFIG_VERSION)
+ SHOW_DIALOG_INFO("Configuration files version missmatch. Expected "+std::string(CONFIG_VERSION)+" but got "+version+".\nPlease remove the current configuration file as it may crash the application.");
+
+ // Main frame
MainWindow *frame = new MainWindow();
frame->Show(true);
+
return true;
}
diff --git a/src/ochess.hpp b/src/ochess.hpp
index 7fc4280..d5b7c16 100644
--- a/src/ochess.hpp
+++ b/src/ochess.hpp
@@ -35,7 +35,7 @@
#define CONFIG_OPEN(name) wxConfig *name = new wxConfig("ochess")
#define CONFIG_CLOSE(name) delete name
-
+#define CONFIG_VERSION "1.0"
class Game;
class GameBase;