Skip to content

Commit

Permalink
Make Connections object qmlWarning follow a logging category
Browse files Browse the repository at this point in the history
Connections{} emits a warning if an old syntax is used.

Unfortunately that syntax is not available in Qt5.12. Downstream needs
to support both at once, which means we have code constantly hitting
this warning. We can't even #ifdef the QML code.

By introducing a logging category we can still have the warning but
provides some option for downstream to temporarily disable through an
existing mechanism until older Qt is not supported.

Task-number: QDS-2007
Change-Id: Idd34c18ae3e8b3e53c430fab8229bb9812370d0e
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
  • Loading branch information
davidedmundson authored and Inkane committed Apr 30, 2020
1 parent c8bba05 commit a2eef6b
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/qml/types/qqmlconnections.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,16 @@
#include <private/qqmlvmemetaobject_p.h>
#include <qqmlinfo.h>

#include <QtCore/qloggingcategory.h>
#include <QtCore/qdebug.h>
#include <QtCore/qstringlist.h>

#include <private/qobject_p.h>

QT_BEGIN_NAMESPACE

Q_LOGGING_CATEGORY(lcQmlConnections, "qt.qml.connections")

class QQmlConnectionsPrivate : public QObjectPrivate
{
public:
Expand Down Expand Up @@ -276,8 +279,10 @@ void QQmlConnections::connectSignals()
connectSignalsToMethods();
} else {
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
qmlWarning(this) << tr("Implicitly defined onFoo properties in Connections are deprecated. "
"Use this syntax instead: function onFoo(<arguments>) { ... }");
if (lcQmlConnections().isWarningEnabled()) {
qmlWarning(this) << tr("Implicitly defined onFoo properties in Connections are deprecated. "
"Use this syntax instead: function onFoo(<arguments>) { ... }");
}
#endif
connectSignalsToBindings();
}
Expand Down

0 comments on commit a2eef6b

Please sign in to comment.