aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/qtquickglobal_p.h
diff options
context:
space:
mode:
authorMitch Curtis <mitch.curtis@qt.io>2021-08-06 12:27:35 +0200
committerMitch Curtis <mitch.curtis@qt.io>2021-09-13 21:17:04 +0200
commite310dadef779b28845b41fb091634cd001cda9de (patch)
tree610be234e82cc53752f58521ae3beba4693ff78f /src/quick/qtquickglobal_p.h
parentde0c1c8a4c834dcc080d1b374186a82cd86921ca (diff)
Consolidate test helpers into private libraries
Previously each test would include and build sources from the shared folder. Now we make those sources a library, build it once, then have each test link to it instead. We also take the opportunity to move some helpers that qtquickcontrols2 had added into the quicktestutils library where it makes sense, and for the helpers that don't make sense to be there, move them into quickcontrolstestutils. We add the libraries to src/ so that they are internal modules built as part of Qt, rather than tests. That way we can use them in a standalone test outside of qtdeclarative. Task-number: QTBUG-95621 Pick-to: 6.2 Change-Id: I0a2ab3976fdbff2e4414df7bdc0808f16453b80a Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src/quick/qtquickglobal_p.h')
-rw-r--r--src/quick/qtquickglobal_p.h30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/quick/qtquickglobal_p.h b/src/quick/qtquickglobal_p.h
index 797d9f169a..0ef394e739 100644
--- a/src/quick/qtquickglobal_p.h
+++ b/src/quick/qtquickglobal_p.h
@@ -72,6 +72,36 @@ Q_DECLARE_LOGGING_CATEGORY(lcMouse)
Q_DECLARE_LOGGING_CATEGORY(lcFocus)
Q_DECLARE_LOGGING_CATEGORY(lcDirty)
+/*
+ This is needed for QuickTestUtils. Q_AUTOTEST_EXPORT checks QT_BUILDING_QT
+ (amongst others) to see if it should export symbols. Until QuickTestUtils
+ was introduced, this was enough, as there weren't any intermediate test
+ helper libraries that used a Qt library and were in turn used by tests.
+
+ Taking QQuickItemViewPrivate as an example: previously it was using
+ Q_AUTOTEST_EXPORT. Since QuickTestUtils is a Qt library (albeit a private
+ one), QT_BUILDING_QT was true and so Q_AUTOTEST_EXPORT evaluated to an
+ export. However, QQuickItemViewPrivate was already exported by the Quick
+ library, so we would get errors like this:
+
+ Qt6Quickd.lib(Qt6Quickd.dll) : error LNK2005: "public: static class
+ QQuickItemViewPrivate * __cdecl QQuickItemViewPrivate::get(class QQuickItemView *)"
+ (?get@QQuickItemViewPrivate@@SAPEAV1@PEAVQQuickItemView@@@Z) already defined
+ in Qt6QuickTestUtilsd.lib(viewtestutils.cpp.obj)
+
+ So, to account for the special case of QuickTestUtils, we need to be more
+ specific about which part of Qt we're building; instead of checking if we're
+ building any Qt library at all, check if we're building the Quick library,
+ and only then export.
+*/
+#if defined(QT_BUILD_INTERNAL) && defined(QT_BUILD_QUICK_LIB) && defined(QT_SHARED)
+# define Q_QUICK_AUTOTEST_EXPORT Q_DECL_EXPORT
+#elif defined(QT_BUILD_INTERNAL) && defined(QT_SHARED)
+# define Q_QUICK_AUTOTEST_EXPORT Q_DECL_IMPORT
+#else
+# define Q_QUICK_AUTOTEST_EXPORT
+#endif
+
QT_END_NAMESPACE
#endif // QTQUICKGLOBAL_P_H