mirror of
https://github.com/aseprite/aseprite.git
synced 2025-01-17 07:10:36 +00:00
Move Strings initialization to App instance creation
This removes Strings::createInstance() and we can check with ASSERT() the singleton in the Strings class ctor/dtor.
This commit is contained in:
parent
9b82e1aac9
commit
60eee6e809
@ -129,21 +129,12 @@ public:
|
||||
app::UIContext m_context;
|
||||
};
|
||||
|
||||
class App::LoadLanguage {
|
||||
public:
|
||||
LoadLanguage(Preferences& pref,
|
||||
Extensions& exts) {
|
||||
Strings::createInstance(pref, exts);
|
||||
}
|
||||
};
|
||||
|
||||
class App::Modules {
|
||||
public:
|
||||
LoggerModule m_loggerModule;
|
||||
FileSystemModule m_file_system_module;
|
||||
Extensions m_extensions;
|
||||
// Load main language (after loading the extensions)
|
||||
LoadLanguage m_loadLanguage;
|
||||
Strings m_strings; // Load main language (after loading the extensions)
|
||||
tools::ToolBox m_toolbox;
|
||||
tools::ActiveToolManager m_activeToolManager;
|
||||
Commands m_commands;
|
||||
@ -160,7 +151,7 @@ public:
|
||||
Modules(const bool createLogInDesktop,
|
||||
Preferences& pref)
|
||||
: m_loggerModule(createLogInDesktop)
|
||||
, m_loadLanguage(pref, m_extensions)
|
||||
, m_strings(pref, m_extensions)
|
||||
, m_activeToolManager(&m_toolbox)
|
||||
, m_recent_files(pref.general.recentItems())
|
||||
#ifdef ENABLE_DATA_RECOVERY
|
||||
|
@ -29,14 +29,6 @@ static Strings* singleton = nullptr;
|
||||
|
||||
const char* Strings::kDefLanguage = "en";
|
||||
|
||||
// static
|
||||
void Strings::createInstance(Preferences& pref,
|
||||
Extensions& exts)
|
||||
{
|
||||
ASSERT(!singleton);
|
||||
singleton = new Strings(pref, exts);
|
||||
}
|
||||
|
||||
// static
|
||||
Strings* Strings::instance()
|
||||
{
|
||||
@ -48,9 +40,18 @@ Strings::Strings(Preferences& pref,
|
||||
: m_pref(pref)
|
||||
, m_exts(exts)
|
||||
{
|
||||
ASSERT(!singleton);
|
||||
singleton = this;
|
||||
|
||||
loadLanguage(currentLanguage());
|
||||
}
|
||||
|
||||
Strings::~Strings()
|
||||
{
|
||||
ASSERT(singleton == this);
|
||||
singleton = nullptr;
|
||||
}
|
||||
|
||||
std::set<LangInfo> Strings::availableLanguages() const
|
||||
{
|
||||
std::set<LangInfo> result;
|
||||
|
@ -28,10 +28,12 @@ namespace app {
|
||||
public:
|
||||
static const char* kDefLanguage;
|
||||
|
||||
static void createInstance(Preferences& pref,
|
||||
Extensions& exts);
|
||||
static Strings* instance();
|
||||
|
||||
Strings(Preferences& pref,
|
||||
Extensions& exts);
|
||||
~Strings();
|
||||
|
||||
const std::string& translate(const char* id) const;
|
||||
const std::string& defaultString(const char* id) const;
|
||||
|
||||
@ -60,9 +62,6 @@ namespace app {
|
||||
obs::signal<void()> LanguageChange;
|
||||
|
||||
private:
|
||||
Strings(Preferences& pref,
|
||||
Extensions& exts);
|
||||
|
||||
void loadLanguage(const std::string& langId);
|
||||
void loadStringsFromDataDir(const std::string& langId);
|
||||
void loadStringsFromExtension(const std::string& langId);
|
||||
|
Loading…
Reference in New Issue
Block a user