mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-04 00:16:51 +08:00
refactor: clang format line length
This commit is contained in:
@@ -45,7 +45,8 @@ namespace swift::misc
|
||||
if (type == QtFatalMsg && CLogHandler::instance()->thread() != QThread::currentThread())
|
||||
{
|
||||
// Fatal message means this thread is about to crash the application. A queued connection would be useless.
|
||||
// Blocking queued connection means we pause this thread just long enough to let the main thread handle the message.
|
||||
// Blocking queued connection means we pause this thread just long enough to let the main thread handle the
|
||||
// message.
|
||||
QMetaObject::invokeMethod(
|
||||
CLogHandler::instance(), [&] { messageHandler(type, context, message); }, Qt::BlockingQueuedConnection);
|
||||
return;
|
||||
@@ -65,7 +66,8 @@ namespace swift::misc
|
||||
};
|
||||
EventFilter ef;
|
||||
qApp->installNativeEventFilter(&ef);
|
||||
MessageBoxW(nullptr, message.toStdWString().c_str(), nullptr, MB_OK); // display assert dialog in release build
|
||||
MessageBoxW(nullptr, message.toStdWString().c_str(), nullptr,
|
||||
MB_OK); // display assert dialog in release build
|
||||
qApp->removeNativeEventFilter(&ef);
|
||||
# if defined(SWIFT_USE_CRASHPAD)
|
||||
CRASHPAD_SIMULATE_CRASH(); // workaround inability to catch __fastfail
|
||||
@@ -90,10 +92,7 @@ namespace swift::misc
|
||||
moveToThread(QCoreApplication::instance()->thread());
|
||||
}
|
||||
|
||||
CLogHandler::~CLogHandler()
|
||||
{
|
||||
qInstallMessageHandler(m_oldHandler);
|
||||
}
|
||||
CLogHandler::~CLogHandler() { qInstallMessageHandler(m_oldHandler); }
|
||||
|
||||
CLogPatternHandler *CLogHandler::handlerForPattern(const CLogPattern &pattern)
|
||||
{
|
||||
@@ -109,10 +108,7 @@ namespace swift::misc
|
||||
topologicallySortedInsert(m_patternHandlers, PatternPair(pattern, handler), comparator);
|
||||
return handler;
|
||||
}
|
||||
else
|
||||
{
|
||||
return (*it).second;
|
||||
}
|
||||
else { return (*it).second; }
|
||||
}
|
||||
|
||||
CLogPatternHandler *CLogHandler::handlerForCategory(const CLogCategory &category)
|
||||
@@ -125,10 +121,7 @@ namespace swift::misc
|
||||
QList<CLogPatternHandler *> m_handlers;
|
||||
for (const auto &pair : m_patternHandlers)
|
||||
{
|
||||
if (pair.first.match(message))
|
||||
{
|
||||
m_handlers.push_back(pair.second);
|
||||
}
|
||||
if (pair.first.match(message)) { m_handlers.push_back(pair.second); }
|
||||
}
|
||||
return m_handlers;
|
||||
}
|
||||
@@ -137,10 +130,7 @@ namespace swift::misc
|
||||
{
|
||||
for (const auto *handler : handlers)
|
||||
{
|
||||
if (!handler->m_inheritFallThrough)
|
||||
{
|
||||
return handler->m_enableFallThrough;
|
||||
}
|
||||
if (!handler->m_inheritFallThrough) { return handler->m_enableFallThrough; }
|
||||
}
|
||||
return m_enableFallThrough;
|
||||
}
|
||||
@@ -149,21 +139,29 @@ namespace swift::misc
|
||||
{
|
||||
using namespace swift::config;
|
||||
CStatusMessage statusMessage = i_statusMessage;
|
||||
if (!CBuildConfig::isLocalDeveloperDebugBuild() && CLogPattern::empty().withSeverity(CStatusMessage::SeverityError).match(statusMessage))
|
||||
if (!CBuildConfig::isLocalDeveloperDebugBuild() &&
|
||||
CLogPattern::empty().withSeverity(CStatusMessage::SeverityError).match(statusMessage))
|
||||
{
|
||||
// 99% this is a complex Qt implementation warning generated by qErrnoWarning, so downgrade its severity
|
||||
statusMessage.setSeverity(CStatusMessage::SeverityDebug);
|
||||
}
|
||||
|
||||
if (!CBuildConfig::isLocalDeveloperDebugBuild() && CLogPattern::exactMatch("default").withSeverity(CStatusMessage::SeverityWarning).match(statusMessage))
|
||||
if (!CBuildConfig::isLocalDeveloperDebugBuild() &&
|
||||
CLogPattern::exactMatch("default").withSeverity(CStatusMessage::SeverityWarning).match(statusMessage))
|
||||
{
|
||||
// All Qt warnings
|
||||
|
||||
// demoted because caused by airline icons, we would need to re-create literally dozens of these images
|
||||
if (statusMessage.getMessage().startsWith(QStringLiteral("libpng warning"))) { statusMessage.setSeverity(CStatusMessage::SeverityDebug); }
|
||||
if (statusMessage.getMessage().startsWith(QStringLiteral("libpng warning")))
|
||||
{
|
||||
statusMessage.setSeverity(CStatusMessage::SeverityDebug);
|
||||
}
|
||||
|
||||
// demoted, because in some swift APPs some options can be ignored
|
||||
else if (statusMessage.getMessage().startsWith(QStringLiteral("QCommandLineParser: option not defined"))) { statusMessage.setSeverity(CStatusMessage::SeverityDebug); }
|
||||
else if (statusMessage.getMessage().startsWith(QStringLiteral("QCommandLineParser: option not defined")))
|
||||
{
|
||||
statusMessage.setSeverity(CStatusMessage::SeverityDebug);
|
||||
}
|
||||
}
|
||||
|
||||
auto bucket = m_tokenBuckets.find(statusMessage);
|
||||
@@ -215,17 +213,13 @@ namespace swift::misc
|
||||
m_oldHandler(type, QMessageLogContext(nullptr, 0, nullptr, qPrintable(category)), message);
|
||||
}
|
||||
|
||||
for (auto *handler : handlers)
|
||||
{
|
||||
emit handler->messageLogged(statusMessage);
|
||||
}
|
||||
for (auto *handler : handlers) { emit handler->messageLogged(statusMessage); }
|
||||
}
|
||||
|
||||
void CLogHandler::removePatternHandler(CLogPatternHandler *handler)
|
||||
{
|
||||
auto it = std::find_if(m_patternHandlers.begin(), m_patternHandlers.end(), [handler](const PatternPair &pair) {
|
||||
return pair.second == handler;
|
||||
});
|
||||
auto it = std::find_if(m_patternHandlers.begin(), m_patternHandlers.end(),
|
||||
[handler](const PatternPair &pair) { return pair.second == handler; });
|
||||
if (it != m_patternHandlers.end())
|
||||
{
|
||||
it->second->deleteLater();
|
||||
@@ -246,7 +240,8 @@ namespace swift::misc
|
||||
return result;
|
||||
}
|
||||
|
||||
CLogPatternHandler::CLogPatternHandler(CLogHandler *parent, const CLogPattern &pattern) : QObject(parent), m_parent(parent), m_pattern(pattern)
|
||||
CLogPatternHandler::CLogPatternHandler(CLogHandler *parent, const CLogPattern &pattern)
|
||||
: QObject(parent), m_parent(parent), m_pattern(pattern)
|
||||
{
|
||||
connect(&m_subscriptionUpdateTimer, &QTimer::timeout, this, &CLogPatternHandler::updateSubscription);
|
||||
m_subscriptionUpdateTimer.start(1);
|
||||
@@ -262,20 +257,11 @@ namespace swift::misc
|
||||
if (isSubscribed != m_isSubscribed)
|
||||
{
|
||||
m_isSubscribed = isSubscribed;
|
||||
if (m_isSubscribed)
|
||||
{
|
||||
emit m_parent->subscriptionAdded(m_pattern);
|
||||
}
|
||||
else
|
||||
{
|
||||
emit m_parent->subscriptionRemoved(m_pattern);
|
||||
}
|
||||
if (m_isSubscribed) { emit m_parent->subscriptionAdded(m_pattern); }
|
||||
else { emit m_parent->subscriptionRemoved(m_pattern); }
|
||||
}
|
||||
|
||||
if (m_inheritFallThrough && !m_isSubscribed)
|
||||
{
|
||||
m_parent->removePatternHandler(this);
|
||||
}
|
||||
if (m_inheritFallThrough && !m_isSubscribed) { m_parent->removePatternHandler(this); }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -284,18 +270,18 @@ namespace swift::misc
|
||||
if (CLogHandler::instance()->thread() != QThread::currentThread())
|
||||
{
|
||||
Q_ASSERT(thread() == QThread::currentThread());
|
||||
singleShot(0, CLogHandler::instance(), [pattern, self = QPointer<CLogSubscriber>(this)]() { if (self) { self->changeSubscription(pattern); } });
|
||||
singleShot(0, CLogHandler::instance(), [pattern, self = QPointer<CLogSubscriber>(this)]() {
|
||||
if (self) { self->changeSubscription(pattern); }
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
unsubscribe();
|
||||
m_handler = CLogHandler::instance()->handlerForPattern(pattern);
|
||||
|
||||
if (!m_inheritFallThrough)
|
||||
{
|
||||
m_handler->enableConsoleOutput(m_enableFallThrough);
|
||||
}
|
||||
connect(m_handler.data(), &CLogPatternHandler::messageLogged, this, &CLogSubscriber::ps_logMessage, Qt::DirectConnection);
|
||||
if (!m_inheritFallThrough) { m_handler->enableConsoleOutput(m_enableFallThrough); }
|
||||
connect(m_handler.data(), &CLogPatternHandler::messageLogged, this, &CLogSubscriber::ps_logMessage,
|
||||
Qt::DirectConnection);
|
||||
}
|
||||
|
||||
void CLogSubscriber::unsubscribe()
|
||||
@@ -303,7 +289,9 @@ namespace swift::misc
|
||||
if (CLogHandler::instance()->thread() != QThread::currentThread())
|
||||
{
|
||||
Q_ASSERT(thread() == QThread::currentThread());
|
||||
singleShot(0, CLogHandler::instance(), [self = QPointer<CLogSubscriber>(this)]() { if (self) { self->unsubscribe(); } });
|
||||
singleShot(0, CLogHandler::instance(), [self = QPointer<CLogSubscriber>(this)]() {
|
||||
if (self) { self->unsubscribe(); }
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -319,15 +307,14 @@ namespace swift::misc
|
||||
if (CLogHandler::instance()->thread() != QThread::currentThread())
|
||||
{
|
||||
Q_ASSERT(thread() == QThread::currentThread());
|
||||
singleShot(0, CLogHandler::instance(), [self = QPointer<CLogSubscriber>(this)]() { if (self) { self->inheritConsoleOutput(); } });
|
||||
singleShot(0, CLogHandler::instance(), [self = QPointer<CLogSubscriber>(this)]() {
|
||||
if (self) { self->inheritConsoleOutput(); }
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
m_inheritFallThrough = true;
|
||||
if (m_handler)
|
||||
{
|
||||
m_handler->inheritConsoleOutput();
|
||||
}
|
||||
if (m_handler) { m_handler->inheritConsoleOutput(); }
|
||||
}
|
||||
|
||||
void CLogSubscriber::enableConsoleOutput(bool enable)
|
||||
@@ -335,16 +322,15 @@ namespace swift::misc
|
||||
if (CLogHandler::instance()->thread() != QThread::currentThread())
|
||||
{
|
||||
Q_ASSERT(thread() == QThread::currentThread());
|
||||
singleShot(0, CLogHandler::instance(), [enable, self = QPointer<CLogSubscriber>(this)]() { if (self) { self->enableConsoleOutput(enable); } });
|
||||
singleShot(0, CLogHandler::instance(), [enable, self = QPointer<CLogSubscriber>(this)]() {
|
||||
if (self) { self->enableConsoleOutput(enable); }
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
m_inheritFallThrough = false;
|
||||
m_enableFallThrough = enable;
|
||||
if (m_handler)
|
||||
{
|
||||
m_handler->enableConsoleOutput(enable);
|
||||
}
|
||||
if (m_handler) { m_handler->enableConsoleOutput(enable); }
|
||||
}
|
||||
} // namespace swift::misc
|
||||
|
||||
|
||||
Reference in New Issue
Block a user