Revert "Initialize QLoggingRegistry rules on first use, not qApp construction"
This reverts commit 47cc9e23a313d67a4a3107242f205d2473842021. We use QCoreApplication::applicationDirPath in the logging initialization to find a possible qtlogging.ini file. Because QCoreApplication::applicationDirPath requires a QCoreApplication instance this leads to a qWarning, which in turn leads to a recursive call to the logging initialization, and in turn to a recursive mutex deadlock. Task-number: QTCREATORBUG-18031 Change-Id: Ic75e1e8c062eb647991725378489bf87c9648cca Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
This commit is contained in:
parent
8043202114
commit
924b02aecb
@ -255,7 +255,6 @@ void QLoggingSettingsParser::parseNextLine(QStringRef line)
|
|||||||
QLoggingRegistry::QLoggingRegistry()
|
QLoggingRegistry::QLoggingRegistry()
|
||||||
: categoryFilter(defaultCategoryFilter)
|
: categoryFilter(defaultCategoryFilter)
|
||||||
{
|
{
|
||||||
init();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool qtLoggingDebug()
|
static bool qtLoggingDebug()
|
||||||
|
@ -113,6 +113,8 @@ class Q_AUTOTEST_EXPORT QLoggingRegistry
|
|||||||
public:
|
public:
|
||||||
QLoggingRegistry();
|
QLoggingRegistry();
|
||||||
|
|
||||||
|
void init();
|
||||||
|
|
||||||
void registerCategory(QLoggingCategory *category, QtMsgType enableForLevel);
|
void registerCategory(QLoggingCategory *category, QtMsgType enableForLevel);
|
||||||
void unregisterCategory(QLoggingCategory *category);
|
void unregisterCategory(QLoggingCategory *category);
|
||||||
|
|
||||||
@ -124,7 +126,6 @@ public:
|
|||||||
static QLoggingRegistry *instance();
|
static QLoggingRegistry *instance();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void init();
|
|
||||||
void updateRules();
|
void updateRules();
|
||||||
|
|
||||||
static void defaultCategoryFilter(QLoggingCategory *category);
|
static void defaultCategoryFilter(QLoggingCategory *category);
|
||||||
|
@ -771,6 +771,8 @@ void QCoreApplicationPrivate::init()
|
|||||||
if (!coreappdata()->applicationVersionSet)
|
if (!coreappdata()->applicationVersionSet)
|
||||||
coreappdata()->applicationVersion = appVersion();
|
coreappdata()->applicationVersion = appVersion();
|
||||||
|
|
||||||
|
QLoggingRegistry::instance()->init();
|
||||||
|
|
||||||
#if QT_CONFIG(library)
|
#if QT_CONFIG(library)
|
||||||
// Reset the lib paths, so that they will be recomputed, taking the availability of argv[0]
|
// Reset the lib paths, so that they will be recomputed, taking the availability of argv[0]
|
||||||
// into account. If necessary, recompute right away and replay the manual changes on top of the
|
// into account. If necessary, recompute right away and replay the manual changes on top of the
|
||||||
|
@ -197,23 +197,9 @@ private slots:
|
|||||||
// Check whether QT_LOGGING_CONF is picked up from environment
|
// Check whether QT_LOGGING_CONF is picked up from environment
|
||||||
//
|
//
|
||||||
|
|
||||||
Q_ASSERT(!qApp);
|
qputenv("QT_LOGGING_CONF", QFINDTESTDATA("qtlogging.ini").toLocal8Bit());
|
||||||
|
|
||||||
qputenv("QT_LOGGING_RULES", "qt.foo.bar=true");
|
|
||||||
|
|
||||||
QLoggingRegistry registry;
|
QLoggingRegistry registry;
|
||||||
QCOMPARE(registry.apiRules.size(), 0);
|
|
||||||
QCOMPARE(registry.configRules.size(), 0);
|
|
||||||
QCOMPARE(registry.envRules.size(), 1);
|
|
||||||
QCOMPARE(registry.rules.size(), 1);
|
|
||||||
|
|
||||||
QLoggingCategory qtEnabledByLoggingRule("qt.foo.bar");
|
|
||||||
QCOMPARE(qtEnabledByLoggingRule.isDebugEnabled(), true);
|
|
||||||
QLoggingCategory qtDisabledByDefault("qt.foo.baz");
|
|
||||||
QCOMPARE(qtDisabledByDefault.isDebugEnabled(), false);
|
|
||||||
|
|
||||||
qunsetenv("QT_LOGGING_RULES");
|
|
||||||
qputenv("QT_LOGGING_CONF", QFINDTESTDATA("qtlogging.ini").toLocal8Bit());
|
|
||||||
registry.init();
|
registry.init();
|
||||||
|
|
||||||
QCOMPARE(registry.apiRules.size(), 0);
|
QCOMPARE(registry.apiRules.size(), 0);
|
||||||
@ -318,6 +304,6 @@ private slots:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
QTEST_APPLESS_MAIN(tst_QLoggingRegistry)
|
QTEST_MAIN(tst_QLoggingRegistry)
|
||||||
|
|
||||||
#include "tst_qloggingregistry.moc"
|
#include "tst_qloggingregistry.moc"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user