From 57caccea67c62a5064f963430842cd81af5cf7bd Mon Sep 17 00:00:00 2001 From: Jaakko Keränen Date: Wed, 27 Oct 2021 16:59:55 +0300 Subject: App: Upgrading to version 1.8.0 Removal of the embedded font library means that the UI strings may not have the right fonts available. The app version is now recorded in prefs.cfg. --- src/app.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/app.c b/src/app.c index 4d125ed8..f4d9f30b 100644 --- a/src/app.c +++ b/src/app.c @@ -55,6 +55,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include #include #include +#include #include #include @@ -176,6 +177,7 @@ const iString *dateStr_(const iDate *date) { static iString *serializePrefs_App_(const iApp *d) { iString *str = new_String(); + appendCStr_String(str, "version app:" LAGRANGE_APP_VERSION "\n"); #if defined (LAGRANGE_ENABLE_CUSTOM_FRAME) appendFormat_String(str, "customframe arg:%d\n", d->prefs.customFrame); #endif @@ -336,6 +338,7 @@ static void loadPrefs_App_(iApp *d) { iUnused(d); iBool haveCA = iFalse; d->isLoadingPrefs = iTrue; /* affects which notifications get posted */ + iVersion upgradedFromAppVersion = { 0 }; /* Create the data dir if it doesn't exist yet. */ makeDirs_Path(collectNewCStr_String(dataDir_App_())); iFile *f = new_File(prefsFileName_()); @@ -379,6 +382,11 @@ static void loadPrefs_App_(iApp *d) { continue; /* can't change downloads directory */ } #endif + else if (equal_Command(cmd, "version")) { + /* This is a special command that lets us know which version we're upgrading from. + It was added in v1.8.0. */ + init_Version(&upgradedFromAppVersion, range_Command(cmd, "app")); + } else { postCommandString_Root(NULL, &cmdStr); } @@ -391,10 +399,17 @@ static void loadPrefs_App_(iApp *d) { setCACertificates_TlsRequest(&d->prefs.strings[caFile_PrefsString], &d->prefs.strings[caPath_PrefsString]); } + iRelease(f); + /* Upgrade checks. */ + if (cmp_Version(&upgradedFromAppVersion, &(iVersion){ 1, 8, 0 }) < 0) { + /* When upgrading to v1.8.0, the old hardcoded font library is gone and that means + UI strings may not have the right fonts available for the UI to remain + usable. */ + postCommandf_App("uilang id:en"); + } #if !defined (LAGRANGE_ENABLE_CUSTOM_FRAME) d->prefs.customFrame = iFalse; #endif - iRelease(f); d->isLoadingPrefs = iFalse; } -- cgit v1.2.3