diff options
author | Sergio Martins <sergio.martins@kdab.com> | 2016-01-10 23:59:29 +0000 |
---|---|---|
committer | Sérgio Martins <iamsergio@gmail.com> | 2016-01-15 20:04:58 +0000 |
commit | 640b381a2bf72b32e6a98adc366e5f56140a5597 (patch) | |
tree | 2d66798a07c56a54992c8b76ca10c50079791861 /src | |
parent | 8ba610490e2d93526c165584e2f52c7ae8e9edc0 (diff) | |
download | qtxmlpatterns-640b381a2bf72b32e6a98adc366e5f56140a5597.tar.gz |
Fix QAbstractMessageHandler's docs regarding thread safety
The QMutexLocker's usage was bogus, it didn't do any locking
because it was being created as an anonymous temporary.
It's too late in the game to fix the locking. The user's virtual
function might have it's own locking to workaround this bug and might
re-enter Qtxmlpatterns API causing a dead-lock.
So instead, make the docs consistent with the current behavior.
Change-Id: I4d2bdb1431b44262583abf48f795067ed37281d5
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/xmlpatterns/api/qabstractmessagehandler.cpp | 18 |
1 files changed, 4 insertions, 14 deletions
diff --git a/src/xmlpatterns/api/qabstractmessagehandler.cpp b/src/xmlpatterns/api/qabstractmessagehandler.cpp index 0916fe4..def8a39 100644 --- a/src/xmlpatterns/api/qabstractmessagehandler.cpp +++ b/src/xmlpatterns/api/qabstractmessagehandler.cpp @@ -31,22 +31,13 @@ ** ****************************************************************************/ -#include <QMutex> - #include "private/qobject_p.h" #include "qabstractmessagehandler.h" QT_BEGIN_NAMESPACE -class QAbstractMessageHandlerPrivate : public QObjectPrivate -{ -public: - QMutex mutex; -}; - /*! \class QAbstractMessageHandler - \threadsafe \since 4.4 \ingroup xml-tools \inmodule QtXmlPatterns @@ -65,8 +56,6 @@ public: instance of your subclass to any classes that must generate messages. The messages are sent to the message handler via the message() function, which forwards them to your handleMessge(). - The effect is to serialize the handling of all messages, which - means your QAbstractMessageHandler subclass is thread safe. A single instance of QAbstractMessageHandler can be called on to handle messages from multiple sources. Hence, the content of a @@ -81,7 +70,7 @@ public: Constructs a QAbstractMessageHandler. The \a parent is passed to the QObject base class constructor. */ -QAbstractMessageHandler::QAbstractMessageHandler(QObject *parent) : QObject(*new QAbstractMessageHandlerPrivate(), parent) +QAbstractMessageHandler::QAbstractMessageHandler(QObject *parent) : QObject(parent) { } @@ -121,8 +110,6 @@ void QAbstractMessageHandler::message(QtMsgType type, const QUrl &identifier, const QSourceLocation &sourceLocation) { - Q_D(QAbstractMessageHandler); - QMutexLocker(&d->mutex); handleMessage(type, description, identifier, sourceLocation); } @@ -135,6 +122,9 @@ void QAbstractMessageHandler::message(QtMsgType type, This function must be implemented by the sub-class. message() will call this function, passing in its parameters, \a type, \a description, \a identifier and \a sourceLocation unmodified. + + This function can potentially be called from multiple threads. It's the reimplementation's + responsibility to ensure thread safety. */ QT_END_NAMESPACE |