core/log: crash if Quickshell's log filter is installed twice

Crashes from recursion inside filterCategories through the old filter
have been observed. Presumably this means the log filter is getting
installed twice somehow. This should catch it.
This commit is contained in:
outfoxxed 2026-04-06 00:45:26 -07:00
parent 5bf6a412b0
commit 7c5a6c4bd4
No known key found for this signature in database
GPG key ID: 4C88A185FB89301E

View file

@ -310,10 +310,15 @@ void LogManager::init(
instance->rules->append(parser.rules());
}
qInstallMessageHandler(&LogManager::messageHandler);
instance->lastCategoryFilter = QLoggingCategory::installFilter(&LogManager::filterCategory);
if (instance->lastCategoryFilter == &LogManager::filterCategory) {
qCFatal(logLogging) << "Quickshell's log filter has been installed twice. This is a bug.";
instance->lastCategoryFilter = nullptr;
}
qInstallMessageHandler(&LogManager::messageHandler);
qCDebug(logLogging) << "Creating offthread logger...";
auto* thread = new QThread();
instance->threadProxy.moveToThread(thread);