From 9f4b8e47eb4d1097eebd29c7d9a4449fcbce2503 Mon Sep 17 00:00:00 2001 From: Donny Viszneki Date: Thu, 14 Aug 2014 05:18:06 -0700 Subject: [PATCH] addressed some synchronization issues in i18n to fix a crash with GDC 4.9.0; removed some minor unused features --- src/dlangui/core/i18n.d | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/src/dlangui/core/i18n.d b/src/dlangui/core/i18n.d index 7563f256..809f9097 100644 --- a/src/dlangui/core/i18n.d +++ b/src/dlangui/core/i18n.d @@ -94,21 +94,17 @@ struct UIString { alias value this; } -public __gshared UIStringTranslator i18n = new UIStringTranslator(); -//static shared this() { -// i18n = new UIStringTranslator(); -//} +shared UIStringTranslator i18n; +shared static this() { + i18n = new shared UIStringTranslator(); +} -class UIStringTranslator { +synchronized class UIStringTranslator { private UIStringList _main; private UIStringList _fallback; private string[] _resourceDirs; - /// get i18n resource directory - @property string[] resourceDirs() { return _resourceDirs; } - /// set i18n resource directory - @property void resourceDirs(string[] dirs) { _resourceDirs = dirs; } /// looks for i18n directory inside one of passed dirs, and uses first found as directory to read i18n files from - string[] findTranslationsDir(string[] dirs ...) { + void findTranslationsDir(string[] dirs ...) { _resourceDirs.length = 0; import std.file; foreach(dir; dirs) { @@ -118,7 +114,6 @@ class UIStringTranslator { _resourceDirs ~= path; } } - return _resourceDirs; } /// convert resource path - append resource dir if necessary @@ -140,8 +135,8 @@ class UIStringTranslator { } this() { - _main = new UIStringList(); - _fallback = new UIStringList(); + _main = new shared UIStringList(); + _fallback = new shared UIStringList(); } /// load translation file(s) bool load(string mainFilename, string fallbackFilename = null) { @@ -168,7 +163,7 @@ class UIStringTranslator { } /// UI string translator -class UIStringList { +private shared class UIStringList { private dstring[string] _map; /// remove all items void clear() {