summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2017-10-11 09:47:32 -0700
committerThiago Macieira <thiago.macieira@intel.com>2020-08-05 21:51:24 -0700
commit9f4c9529f609d947e2884af527208ac4c76a12d6 (patch)
tree420ebddacc4436a0546049bd41ef6770aba88c4e /src
parente80767d1fc45cfca96694937289712f0278f4945 (diff)
MSVC: remove the extern template
The problem was that QtCore exported those classes deriving from containers, which caused applications to try and import those same functions from QtCore, depending on whether they saw the #include or not. Now we don't need the hack anymore. Change-Id: I0a103569c81b4711a649fffd14ec9282454a1fdc Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/corelib/itemmodels/qitemselectionmodel.h34
-rw-r--r--src/corelib/serialization/qxmlstream.h18
-rw-r--r--src/corelib/tools/qlist.h15
-rw-r--r--src/gui/painting/qpolygon.h64
4 files changed, 52 insertions, 79 deletions
diff --git a/src/corelib/itemmodels/qitemselectionmodel.h b/src/corelib/itemmodels/qitemselectionmodel.h
index f735bf85a8..cf6b004f7e 100644
--- a/src/corelib/itemmodels/qitemselectionmodel.h
+++ b/src/corelib/itemmodels/qitemselectionmodel.h
@@ -207,37 +207,21 @@ private:
Q_DECLARE_OPERATORS_FOR_FLAGS(QItemSelectionModel::SelectionFlags)
-#ifdef Q_CC_MSVC
-
-/*
- ### Qt 6:
- ### This needs to be removed for next releases of Qt. It is a workaround for vc++ because
- ### Qt exports QItemSelection that inherits QList<QItemSelectionRange>.
-*/
-
-# ifndef Q_TEMPLATE_EXTERN
-# if defined(QT_BUILD_CORE_LIB)
-# define Q_TEMPLATE_EXTERN
-# else
-# define Q_TEMPLATE_EXTERN extern
-# endif
-# endif
-Q_TEMPLATE_EXTERN template class Q_CORE_EXPORT QList<QItemSelectionRange>;
-#endif // Q_CC_MSVC
-
-class Q_CORE_EXPORT QItemSelection : public QList<QItemSelectionRange>
+// We export each out-of-line method invidually to prevent MSVC from
+// exporting the whole QList class.
+class QItemSelection : public QList<QItemSelectionRange>
{
public:
QItemSelection() noexcept : QList<QItemSelectionRange>() {}
- QItemSelection(const QModelIndex &topLeft, const QModelIndex &bottomRight);
+ Q_CORE_EXPORT QItemSelection(const QModelIndex &topLeft, const QModelIndex &bottomRight);
// reusing QList::swap() here is OK!
- void select(const QModelIndex &topLeft, const QModelIndex &bottomRight);
- bool contains(const QModelIndex &index) const;
- QModelIndexList indexes() const;
- void merge(const QItemSelection &other, QItemSelectionModel::SelectionFlags command);
- static void split(const QItemSelectionRange &range,
+ Q_CORE_EXPORT void select(const QModelIndex &topLeft, const QModelIndex &bottomRight);
+ Q_CORE_EXPORT bool contains(const QModelIndex &index) const;
+ Q_CORE_EXPORT QModelIndexList indexes() const;
+ Q_CORE_EXPORT void merge(const QItemSelection &other, QItemSelectionModel::SelectionFlags command);
+ Q_CORE_EXPORT static void split(const QItemSelectionRange &range,
const QItemSelectionRange &other,
QItemSelection *result);
};
diff --git a/src/corelib/serialization/qxmlstream.h b/src/corelib/serialization/qxmlstream.h
index e197a0f999..31c605c981 100644
--- a/src/corelib/serialization/qxmlstream.h
+++ b/src/corelib/serialization/qxmlstream.h
@@ -110,17 +110,19 @@ public:
Q_DECLARE_TYPEINFO(QXmlStreamAttribute, Q_MOVABLE_TYPE);
-class Q_CORE_EXPORT QXmlStreamAttributes : public QList<QXmlStreamAttribute>
+// We export each out-of-line method invidually to prevent MSVC from
+// exporting the whole QList class.
+class QXmlStreamAttributes : public QList<QXmlStreamAttribute>
{
public:
inline QXmlStreamAttributes() {}
- QStringRef value(const QString &namespaceUri, const QString &name) const;
- QStringRef value(const QString &namespaceUri, QLatin1String name) const;
- QStringRef value(QLatin1String namespaceUri, QLatin1String name) const;
- QStringRef value(const QString &qualifiedName) const;
- QStringRef value(QLatin1String qualifiedName) const;
- void append(const QString &namespaceUri, const QString &name, const QString &value);
- void append(const QString &qualifiedName, const QString &value);
+ Q_CORE_EXPORT QStringRef value(const QString &namespaceUri, const QString &name) const;
+ Q_CORE_EXPORT QStringRef value(const QString &namespaceUri, QLatin1String name) const;
+ Q_CORE_EXPORT QStringRef value(QLatin1String namespaceUri, QLatin1String name) const;
+ Q_CORE_EXPORT QStringRef value(const QString &qualifiedName) const;
+ Q_CORE_EXPORT QStringRef value(QLatin1String qualifiedName) const;
+ Q_CORE_EXPORT void append(const QString &namespaceUri, const QString &name, const QString &value);
+ Q_CORE_EXPORT void append(const QString &qualifiedName, const QString &value);
inline bool hasAttribute(const QString &qualifiedName) const
{
diff --git a/src/corelib/tools/qlist.h b/src/corelib/tools/qlist.h
index 35dc286191..fad61bf8e6 100644
--- a/src/corelib/tools/qlist.h
+++ b/src/corelib/tools/qlist.h
@@ -832,21 +832,6 @@ auto operator>=(const QList<T> &lhs, const QList<T> &rhs)
return !(lhs < rhs);
}
-/*
- ### Qt 5:
- ### This needs to be removed for next releases of Qt. It is a workaround for vc++ because
- ### Qt exports QPolygon and QPolygonF that inherit QList<QPoint> and
- ### QList<QPointF> respectively.
-*/
-
-#if defined(Q_CC_MSVC) && !defined(QT_BUILD_CORE_LIB)
-QT_BEGIN_INCLUDE_NAMESPACE
-#include <QtCore/qpoint.h>
-QT_END_INCLUDE_NAMESPACE
-extern template class Q_CORE_EXPORT QList<QPointF>;
-extern template class Q_CORE_EXPORT QList<QPoint>;
-#endif
-
QList<uint> QStringView::toUcs4() const { return QtPrivate::convertToUcs4(*this); }
QT_END_NAMESPACE
diff --git a/src/gui/painting/qpolygon.h b/src/gui/painting/qpolygon.h
index 57c9a3fa46..5b3cd79c8c 100644
--- a/src/gui/painting/qpolygon.h
+++ b/src/gui/painting/qpolygon.h
@@ -51,7 +51,9 @@ class QTransform;
class QRect;
class QVariant;
-class Q_GUI_EXPORT QPolygon : public QList<QPoint>
+// We export each out-of-line method invidually to prevent MSVC from
+// exporting the whole QList class.
+class QPolygon : public QList<QPoint>
{
public:
inline QPolygon() {}
@@ -59,41 +61,41 @@ public:
inline explicit QPolygon(int size);
inline /*implicit*/ QPolygon(const QList<QPoint> &v) : QList<QPoint>(v) { }
/*implicit*/ QPolygon(QList<QPoint> &&v) noexcept : QList<QPoint>(std::move(v)) { }
- QPolygon(const QRect &r, bool closed=false);
- QPolygon(int nPoints, const int *points);
+ Q_GUI_EXPORT QPolygon(const QRect &r, bool closed=false);
+ Q_GUI_EXPORT QPolygon(int nPoints, const int *points);
QPolygon(const QPolygon &other) : QList<QPoint>(other) { }
QPolygon(QPolygon &&other) noexcept : QList<QPoint>(std::move(other)) { }
QPolygon &operator=(QPolygon &&other) noexcept { swap(other); return *this; }
QPolygon &operator=(const QPolygon &other) { QList<QPoint>::operator=(other); return *this; }
void swap(QPolygon &other) noexcept { QList<QPoint>::swap(other); } // prevent QList<QPoint><->QPolygon swaps
- operator QVariant() const;
+ Q_GUI_EXPORT operator QVariant() const;
- void translate(int dx, int dy);
+ Q_GUI_EXPORT void translate(int dx, int dy);
void translate(const QPoint &offset);
- Q_REQUIRED_RESULT QPolygon translated(int dx, int dy) const;
+ Q_REQUIRED_RESULT Q_GUI_EXPORT QPolygon translated(int dx, int dy) const;
Q_REQUIRED_RESULT inline QPolygon translated(const QPoint &offset) const;
- QRect boundingRect() const;
+ Q_GUI_EXPORT QRect boundingRect() const;
- void point(int i, int *x, int *y) const;
+ Q_GUI_EXPORT void point(int i, int *x, int *y) const;
QPoint point(int i) const;
void setPoint(int index, int x, int y);
void setPoint(int index, const QPoint &p);
- void setPoints(int nPoints, const int *points);
- void setPoints(int nPoints, int firstx, int firsty, ...);
- void putPoints(int index, int nPoints, const int *points);
- void putPoints(int index, int nPoints, int firstx, int firsty, ...);
- void putPoints(int index, int nPoints, const QPolygon & from, int fromIndex=0);
+ Q_GUI_EXPORT void setPoints(int nPoints, const int *points);
+ Q_GUI_EXPORT void setPoints(int nPoints, int firstx, int firsty, ...);
+ Q_GUI_EXPORT void putPoints(int index, int nPoints, const int *points);
+ Q_GUI_EXPORT void putPoints(int index, int nPoints, int firstx, int firsty, ...);
+ Q_GUI_EXPORT void putPoints(int index, int nPoints, const QPolygon & from, int fromIndex=0);
- bool containsPoint(const QPoint &pt, Qt::FillRule fillRule) const;
+ Q_GUI_EXPORT bool containsPoint(const QPoint &pt, Qt::FillRule fillRule) const;
- Q_REQUIRED_RESULT QPolygon united(const QPolygon &r) const;
- Q_REQUIRED_RESULT QPolygon intersected(const QPolygon &r) const;
- Q_REQUIRED_RESULT QPolygon subtracted(const QPolygon &r) const;
+ Q_REQUIRED_RESULT Q_GUI_EXPORT QPolygon united(const QPolygon &r) const;
+ Q_REQUIRED_RESULT Q_GUI_EXPORT QPolygon intersected(const QPolygon &r) const;
+ Q_REQUIRED_RESULT Q_GUI_EXPORT QPolygon subtracted(const QPolygon &r) const;
- bool intersects(const QPolygon &r) const;
+ Q_GUI_EXPORT bool intersects(const QPolygon &r) const;
};
Q_DECLARE_SHARED(QPolygon)
@@ -132,7 +134,7 @@ inline QPolygon QPolygon::translated(const QPoint &offset) const
class QRectF;
-class Q_GUI_EXPORT QPolygonF : public QList<QPointF>
+class QPolygonF : public QList<QPointF>
{
public:
inline QPolygonF() {}
@@ -140,35 +142,35 @@ public:
inline explicit QPolygonF(int size);
inline /*implicit*/ QPolygonF(const QList<QPointF> &v) : QList<QPointF>(v) { }
/* implicit */ QPolygonF(QList<QPointF> &&v) noexcept : QList<QPointF>(std::move(v)) { }
- QPolygonF(const QRectF &r);
- /*implicit*/ QPolygonF(const QPolygon &a);
+ Q_GUI_EXPORT QPolygonF(const QRectF &r);
+ /*implicit*/ Q_GUI_EXPORT QPolygonF(const QPolygon &a);
inline QPolygonF(const QPolygonF &a) : QList<QPointF>(a) { }
QPolygonF(QPolygonF &&other) noexcept : QList<QPointF>(std::move(other)) { }
QPolygonF &operator=(QPolygonF &&other) noexcept { swap(other); return *this; }
QPolygonF &operator=(const QPolygonF &other) { QList<QPointF>::operator=(other); return *this; }
inline void swap(QPolygonF &other) { QList<QPointF>::swap(other); } // prevent QList<QPointF><->QPolygonF swaps
- operator QVariant() const;
+ Q_GUI_EXPORT operator QVariant() const;
inline void translate(qreal dx, qreal dy);
- void translate(const QPointF &offset);
+ void Q_GUI_EXPORT translate(const QPointF &offset);
inline QPolygonF translated(qreal dx, qreal dy) const;
- Q_REQUIRED_RESULT QPolygonF translated(const QPointF &offset) const;
+ Q_REQUIRED_RESULT Q_GUI_EXPORT QPolygonF translated(const QPointF &offset) const;
- QPolygon toPolygon() const;
+ QPolygon Q_GUI_EXPORT toPolygon() const;
bool isClosed() const { return !isEmpty() && first() == last(); }
- QRectF boundingRect() const;
+ QRectF Q_GUI_EXPORT boundingRect() const;
- bool containsPoint(const QPointF &pt, Qt::FillRule fillRule) const;
+ Q_GUI_EXPORT bool containsPoint(const QPointF &pt, Qt::FillRule fillRule) const;
- Q_REQUIRED_RESULT QPolygonF united(const QPolygonF &r) const;
- Q_REQUIRED_RESULT QPolygonF intersected(const QPolygonF &r) const;
- Q_REQUIRED_RESULT QPolygonF subtracted(const QPolygonF &r) const;
+ Q_REQUIRED_RESULT Q_GUI_EXPORT QPolygonF united(const QPolygonF &r) const;
+ Q_REQUIRED_RESULT Q_GUI_EXPORT QPolygonF intersected(const QPolygonF &r) const;
+ Q_REQUIRED_RESULT Q_GUI_EXPORT QPolygonF subtracted(const QPolygonF &r) const;
- bool intersects(const QPolygonF &r) const;
+ Q_GUI_EXPORT bool intersects(const QPolygonF &r) const;
};
Q_DECLARE_SHARED(QPolygonF)