mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-17 12:40:35 +01:00
Improve element collection loading time
According to Qt creator flame graph, call QSettings take lot of time. When loading the element collection, each items of the collection get the current language by calling the function QString QETApp::langFromSetting(). This function instantiate a QSettings object each time and take a lot of time. Now the QSettings is instantiate only at the first call, and the value is stored in memory, then all other call of the function don't instantiate a QSettings, but just return the value in memory.
This commit is contained in:
@@ -71,6 +71,9 @@ QString QETApp::m_user_custom_elements_dir = QString();
|
||||
QString QETApp::m_user_custom_tbt_dir = QString();
|
||||
QETApp *QETApp::m_qetapp = nullptr;
|
||||
|
||||
bool lang_is_set = false;
|
||||
QString system_language = QString();
|
||||
|
||||
|
||||
/**
|
||||
@brief QETApp::QETApp
|
||||
@@ -227,11 +230,16 @@ void QETApp::setLanguage(const QString &desired_language) {
|
||||
*/
|
||||
QString QETApp::langFromSetting()
|
||||
{
|
||||
QSettings settings;
|
||||
QString system_language = settings.value("lang", "system").toString();
|
||||
if(system_language == "system") {
|
||||
system_language = QLocale::system().name().left(2);
|
||||
if (!lang_is_set)
|
||||
{
|
||||
QSettings settings;
|
||||
system_language = settings.value("lang", "system").toString();
|
||||
if(system_language == "system") {
|
||||
system_language = QLocale::system().name().left(2);
|
||||
}
|
||||
lang_is_set = true;
|
||||
}
|
||||
|
||||
return system_language;
|
||||
}
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user