summaryrefslogtreecommitdiffstats
path: root/src/widgets
diff options
context:
space:
mode:
authorVolker Hilsheimer <volker.hilsheimer@qt.io>2021-03-27 12:29:24 +0100
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2021-03-30 08:31:21 +0000
commit5e838e979ead8bbd1ae40c89f4774971b4913031 (patch)
tree27a9825157ff850263620976cea7654be46f5774 /src/widgets
parent516316e9a24fc3a290ce220a9a6cda0af541ca4c (diff)
Replace QTextDocumentResourceProvider with a std::function
376e3bd8ecf40881685714f6f19e12d68e92127e added the new class for Qt 6.1, but during header review we concluded that using a class introduces complexity wrt instance ownership and API design that can be avoided by using a std::function instead. The functionality is tied to QTextDocument, so the type definition and the default provider API is added there. Since std::function is not trivially copyable, the atomicity of the previous implementation is not maintained, and concurrent modifications of and access to the global default provider from multiple threads is not allowed. The relevant use case can be supported by implementing a resource provider that is thread safe. Task-number: QTBUG-90211 Fixes: QTBUG-92208 Change-Id: I39215c5e51c7bd27f1dd29e1d9d908aecf754fb7 Reviewed-by: Kai Koehne <kai.koehne@qt.io> (cherry picked from commit ccf1a1a9536be7b904494f5b3243202d71a33b06) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'src/widgets')
-rw-r--r--src/widgets/widgets/qlabel.cpp4
-rw-r--r--src/widgets/widgets/qlabel.h6
-rw-r--r--src/widgets/widgets/qlabel_p.h2
3 files changed, 6 insertions, 6 deletions
diff --git a/src/widgets/widgets/qlabel.cpp b/src/widgets/widgets/qlabel.cpp
index d2f176c67d..377f2967cf 100644
--- a/src/widgets/widgets/qlabel.cpp
+++ b/src/widgets/widgets/qlabel.cpp
@@ -1429,7 +1429,7 @@ void QLabel::setTextFormat(Qt::TextFormat format)
Returns the resource provider for rich text of this label.
*/
-QTextDocumentResourceProvider *QLabel::resourceProvider() const
+QTextDocument::ResourceProvider QLabel::resourceProvider() const
{
Q_D(const QLabel);
return d->control ? d->control->document()->resourceProvider() : d->resourceProvider;
@@ -1442,7 +1442,7 @@ QTextDocumentResourceProvider *QLabel::resourceProvider() const
\note The label \e{does not} take ownership of the \a provider.
*/
-void QLabel::setResourceProvider(QTextDocumentResourceProvider *provider)
+void QLabel::setResourceProvider(const QTextDocument::ResourceProvider &provider)
{
Q_D(QLabel);
d->resourceProvider = provider;
diff --git a/src/widgets/widgets/qlabel.h b/src/widgets/widgets/qlabel.h
index 1b6e946476..05fb39e0fa 100644
--- a/src/widgets/widgets/qlabel.h
+++ b/src/widgets/widgets/qlabel.h
@@ -43,13 +43,13 @@
#include <QtWidgets/qtwidgetsglobal.h>
#include <QtWidgets/qframe.h>
#include <QtGui/qpicture.h>
+#include <QtGui/qtextdocument.h>
QT_REQUIRE_CONFIG(label);
QT_BEGIN_NAMESPACE
-class QTextDocumentResourceProvider;
class QLabelPrivate;
class Q_WIDGETS_EXPORT QLabel : public QFrame
@@ -93,8 +93,8 @@ public:
Qt::TextFormat textFormat() const;
void setTextFormat(Qt::TextFormat);
- QTextDocumentResourceProvider *resourceProvider() const;
- void setResourceProvider(QTextDocumentResourceProvider *provider);
+ QTextDocument::ResourceProvider resourceProvider() const;
+ void setResourceProvider(const QTextDocument::ResourceProvider &provider);
Qt::Alignment alignment() const;
void setAlignment(Qt::Alignment);
diff --git a/src/widgets/widgets/qlabel_p.h b/src/widgets/widgets/qlabel_p.h
index 635042a8cd..d26bbf6a7f 100644
--- a/src/widgets/widgets/qlabel_p.h
+++ b/src/widgets/widgets/qlabel_p.h
@@ -154,7 +154,7 @@ public:
#endif
uint openExternalLinks : 1;
// <-- space for more bit field values here
- QTextDocumentResourceProvider *resourceProvider;
+ QTextDocument::ResourceProvider resourceProvider;
friend class QMessageBoxPrivate;
};