Don't construct a QFont globally (as a class static)

* It causes a crash when Qt is statically linked.
This commit is contained in:
baldurk
2017-05-18 15:05:03 +01:00
parent c5b79e9382
commit 5b74b66493
3 changed files with 14 additions and 4 deletions
+9 -2
View File
@@ -546,7 +546,7 @@ int Formatter::m_minFigures = 2, Formatter::m_maxFigures = 5, Formatter::m_expNe
Formatter::m_expPosCutoff = 7;
double Formatter::m_expNegValue = 0.00001; // 10^(-5)
double Formatter::m_expPosValue = 10000000.0; // 10^7
QFont Formatter::m_Font;
QFont *Formatter::m_Font = NULL;
void Formatter::setParams(const PersistantConfig &config)
{
@@ -558,10 +558,17 @@ void Formatter::setParams(const PersistantConfig &config)
m_expNegValue = qPow(10.0, -config.Formatter_NegExp);
m_expPosValue = qPow(10.0, config.Formatter_PosExp);
m_Font =
if(!m_Font)
m_Font = new QFont();
*m_Font =
config.Font_PreferMonospaced ? QFontDatabase::systemFont(QFontDatabase::FixedFont) : QFont();
}
void Formatter::shutdown()
{
delete m_Font;
}
QString Formatter::Format(double f, bool)
{
if(f != 0.0 && (qAbs(f) < m_expNegValue || qAbs(f) > m_expPosValue))
+3 -2
View File
@@ -656,6 +656,7 @@ QString GetComponentString(byte mask);
struct Formatter
{
static void setParams(const PersistantConfig &config);
static void shutdown();
static QString Format(double f, bool hex = false);
static QString Format(uint64_t u, bool hex = false)
@@ -684,11 +685,11 @@ struct Formatter
return Format(u, true);
}
static QString Format(int32_t i, bool hex = false) { return QString::number(i); }
static const QFont &PreferredFont() { return m_Font; }
static const QFont &PreferredFont() { return *m_Font; }
private:
static int m_minFigures, m_maxFigures, m_expNegCutoff, m_expPosCutoff;
static double m_expNegValue, m_expPosValue;
static QFont m_Font;
static QFont *m_Font;
};
bool SaveToJSON(QVariantMap &data, QIODevice &f, const char *magicIdentifier, uint32_t magicVersion);
+2
View File
@@ -230,6 +230,8 @@ int main(int argc, char *argv[])
config.Save();
}
PythonContext::GlobalShutdown();
Formatter::shutdown();
}
delete[] argv_mod;