r22151 by jghali -
scribus-commit
scribus-commit at lists.scribus.net
Fri Sep 1 10:49:39 UTC 2017
Author: jghali
Date: Fri Sep 1 10:49:39 2017
New Revision: 22151
URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=22151
Log:
fix potential crashes in charstyle widget caused by unexpected languages strings such as "fr_FR.UTF-8"
Modified:
branches/Version14x/Scribus/scribus/scribusapp.cpp
branches/Version14x/Scribus/scribus/util.cpp
branches/Version14x/Scribus/scribus/util.h
Modified: branches/Version14x/Scribus/scribus/scribusapp.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=22151&path=/branches/Version14x/Scribus/scribus/scribusapp.cpp
==============================================================================
--- branches/Version14x/Scribus/scribus/scribusapp.cpp (original)
+++ branches/Version14x/Scribus/scribus/scribusapp.cpp Fri Sep 1 10:49:39 2017
@@ -35,14 +35,15 @@
#include <QLocale>
#include <QTextStream>
+#include "commonstrings.h"
#include "scribusapp.h"
#include "scribuscore.h"
#include "scpaths.h"
#include "prefsfile.h"
#include "langmgr.h"
#include "prefsmanager.h"
-#include "commonstrings.h"
#include "upgradechecker.h"
+#include "util.h"
#if defined(_WIN32)
#include <windows.h>
@@ -281,6 +282,7 @@
PrefsContext* userprefsContext = prefsFile->getContext("user_preferences");
if (userprefsContext) {
QString prefslang = userprefsContext->get("gui_language","");
+ prefslang = cleanupLang(prefslang);
if (!prefslang.isEmpty())
langs.push_back(prefslang);
}
@@ -290,11 +292,23 @@
}
if (!(lang = ::getenv("LC_ALL")).isEmpty())
- langs.push_back(lang);
+ {
+ lang = cleanupLang(lang);
+ if (!lang.isEmpty())
+ langs.push_back(lang);
+ }
if (!(lang = ::getenv("LC_MESSAGES")).isEmpty())
- langs.push_back(lang);
+ {
+ lang = cleanupLang(lang);
+ if (!lang.isEmpty())
+ langs.push_back(lang);
+ }
if (!(lang = ::getenv("LANG")).isEmpty())
- langs.push_back(lang);
+ {
+ lang = cleanupLang(lang);
+ if (!lang.isEmpty())
+ langs.push_back(lang);
+ }
#if defined(_WIN32)
wchar_t out[256];
@@ -317,7 +331,7 @@
}
#endif
- langs.push_back(QString(QLocale::system().name()));
+ langs.push_back(QLocale::system().name());
// remove duplicate entries...
QStringList::Iterator it = langs.end();
Modified: branches/Version14x/Scribus/scribus/util.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=22151&path=/branches/Version14x/Scribus/scribus/util.cpp
==============================================================================
--- branches/Version14x/Scribus/scribus/util.cpp (original)
+++ branches/Version14x/Scribus/scribus/util.cpp Fri Sep 1 10:49:39 2017
@@ -50,6 +50,16 @@
void sDebug(QString message)
{
qDebug("%s", message.toAscii().constData());
+}
+
+QString cleanupLang(const QString& lang)
+{
+ int dotIndex = lang.indexOf(QChar('.'));
+ if (dotIndex < 0)
+ return lang;
+
+ QString cleanLang = lang.left(dotIndex);
+ return cleanLang;
}
int System(const QString exename, const QStringList & args, const QString fileStdErr, const QString fileStdOut, bool* cancel)
Modified: branches/Version14x/Scribus/scribus/util.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=22151&path=/branches/Version14x/Scribus/scribus/util.h
==============================================================================
--- branches/Version14x/Scribus/scribus/util.h (original)
+++ branches/Version14x/Scribus/scribus/util.h Fri Sep 1 10:49:39 2017
@@ -37,7 +37,10 @@
class ScStreamFilter;
struct CopyPasteBuffer;
-// class Foi;
+/*!
+\brief Cleanup language strings from extensions such as ".UTF-8" we can get from environment variables
+*/
+QString cleanupLang(const QString& lang);
/*! \brief Compare double values by pre-multiplying by 10000 and converting to long if possible.
If premultiplication does not allow to store result in a long value, perform a standard comparison.
More information about the scribus-commit
mailing list