QErrorMessage: Filter out categorized logging for QErrorMessage::qtHandler()

The class was not written to handle categorized logging, which was
added after its inception. Processing categorized logging can quickly
lead to issues, as showing the QErrorMessage may trigger categorized
logging in itself.

Change-Id: Id1d3a75acc1e6d1a69493fa722a733ae2f1f5f63
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
bb10
Tor Arne Vestbø 2022-11-18 16:39:37 +01:00
parent 7e4c7d50a7
commit 21127b587b
1 changed files with 8 additions and 1 deletions

View File

@ -149,11 +149,16 @@ static QString msgType2i18nString(QtMsgType t)
return QCoreApplication::translate("QErrorMessage", messages[t]);
}
static void jump(QtMsgType t, const QMessageLogContext & /*context*/, const QString &m)
static void jump(QtMsgType t, const QMessageLogContext &context, const QString &m)
{
if (!qtMessageHandler)
return;
auto *defaultCategory = QLoggingCategory::defaultCategory();
if (context.category && defaultCategory
&& qstrcmp(context.category, defaultCategory->categoryName()) != 0)
return;
QString rich = "<p><b>"_L1 + msgType2i18nString(t) + "</b></p>"_L1
+ Qt::convertFromPlainText(m, Qt::WhiteSpaceNormal);
@ -254,6 +259,8 @@ void QErrorMessage::done(int a)
Returns a pointer to a QErrorMessage object that outputs the
default Qt messages. This function creates such an object, if there
isn't one already.
The object will only output log messages of QLoggingCategory::defaultCategory().
*/
QErrorMessage * QErrorMessage::qtHandler()