mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-05-06 01:50:38 +00:00
Don't construct a QFont globally (as a class static)
* It causes a crash when Qt is statically linked.
This commit is contained in:
@@ -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))
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -230,6 +230,8 @@ int main(int argc, char *argv[])
|
||||
config.Save();
|
||||
}
|
||||
PythonContext::GlobalShutdown();
|
||||
|
||||
Formatter::shutdown();
|
||||
}
|
||||
|
||||
delete[] argv_mod;
|
||||
|
||||
Reference in New Issue
Block a user