summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@qt.io>2022-07-01 15:21:39 +0200
committerMarc Mutz <marc.mutz@qt.io>2022-07-21 09:49:45 +0000
commitfbe9947bd65dd1818c48c4be426e9000d2a4e695 (patch)
tree6f541058c7b57e6141a67facefeeb3c5f12dc6c2
parent7871ebc90a749975c8d405a40f8ffa547c58c462 (diff)
Fix layering violation involving AbstractDeclarative
When trying an ubsan build of qtdatavis3d, I get: abstract3dcontroller.cpp.o: undefined reference to `typeinfo for AbstractDeclarative' Turns out that AbstractDeclarative is defined in DataVisualizationQml, a separate library, which depends on DataVisualization. It seems this worked because Abstract3DController only used inline members of AbstractDeclarative, so a normal build doesn't need the class exported, even though it's curious that inline isReady() calls exported QQuickItem::isComponentLoaded() and the linker didn't complain. But an UBSan build requires the type_info, which isn't available, because the class wasn't exported, and cannot be made available because of the layering violation. To fix, Extract Superclass AbstractDeclarativeInterface that provides only the required isReady() function, but lives in DataVisualization, and have the real AbstractDeclarative inherit it. As a drive-by, make isReady() const. Manual conflict resolutions: - ported from SPDX to classical copyright headers Fixes: QTBUG-104714 Change-Id: I0eb718746355f409a4105e2d53e79b7003fd8b22 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io> (cherry picked from commit 24106d1e1c818b358f919ce5cbff219b5a9f8b6a)
-rw-r--r--src/datavisualization/CMakeLists.txt1
-rw-r--r--src/datavisualization/engine/abstract3dcontroller_p.h3
-rw-r--r--src/datavisualization/engine/abstractdeclarativeinterface.cpp37
-rw-r--r--src/datavisualization/engine/abstractdeclarativeinterface_p.h57
-rw-r--r--src/datavisualizationqml/abstractdeclarative.cpp1
-rw-r--r--src/datavisualizationqml/abstractdeclarative_p.h5
6 files changed, 101 insertions, 3 deletions
diff --git a/src/datavisualization/CMakeLists.txt b/src/datavisualization/CMakeLists.txt
index ca75d284..74b76cc3 100644
--- a/src/datavisualization/CMakeLists.txt
+++ b/src/datavisualization/CMakeLists.txt
@@ -34,6 +34,7 @@ qt_internal_add_module(DataVisualization
data/scatteritemmodelhandler.cpp data/scatteritemmodelhandler_p.h
data/scatterrenderitem.cpp data/scatterrenderitem_p.h
data/surfaceitemmodelhandler.cpp data/surfaceitemmodelhandler_p.h
+ engine/abstractdeclarativeinterface.cpp engine/abstractdeclarativeinterface_p.h
engine/abstract3dcontroller.cpp engine/abstract3dcontroller_p.h
engine/abstract3drenderer.cpp engine/abstract3drenderer_p.h
engine/axisrendercache.cpp engine/axisrendercache_p.h
diff --git a/src/datavisualization/engine/abstract3dcontroller_p.h b/src/datavisualization/engine/abstract3dcontroller_p.h
index 30514fb2..e66560b1 100644
--- a/src/datavisualization/engine/abstract3dcontroller_p.h
+++ b/src/datavisualization/engine/abstract3dcontroller_p.h
@@ -57,6 +57,7 @@ QT_FORWARD_DECLARE_CLASS(QOpenGLFramebufferObject)
QT_BEGIN_NAMESPACE
+class AbstractDeclarativeInterface;
class AbstractDeclarative;
class Abstract3DRenderer;
class QAbstract3DSeries;
@@ -227,7 +228,7 @@ protected:
qreal m_margin;
QMutex m_renderMutex;
- AbstractDeclarative *m_qml = nullptr;
+ AbstractDeclarativeInterface *m_qml = nullptr;
explicit Abstract3DController(QRect initialViewport, Q3DScene *scene, QObject *parent = 0);
diff --git a/src/datavisualization/engine/abstractdeclarativeinterface.cpp b/src/datavisualization/engine/abstractdeclarativeinterface.cpp
new file mode 100644
index 00000000..26d38f3b
--- /dev/null
+++ b/src/datavisualization/engine/abstractdeclarativeinterface.cpp
@@ -0,0 +1,37 @@
+/****************************************************************************
+**
+** Copyright (C) 2022 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the Qt Data Visualization module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:GPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 or (at your option) any later version
+** approved by the KDE Free Qt Foundation. The licenses are as published by
+** the Free Software Foundation and appearing in the file LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtDataVisualization/private/abstractdeclarativeinterface_p.h>
+
+QT_BEGIN_NAMESPACE
+
+AbstractDeclarativeInterface::~AbstractDeclarativeInterface()
+ = default;
+
+QT_END_NAMESPACE
diff --git a/src/datavisualization/engine/abstractdeclarativeinterface_p.h b/src/datavisualization/engine/abstractdeclarativeinterface_p.h
new file mode 100644
index 00000000..8ab19440
--- /dev/null
+++ b/src/datavisualization/engine/abstractdeclarativeinterface_p.h
@@ -0,0 +1,57 @@
+/****************************************************************************
+**
+** Copyright (C) 2022 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the Qt Data Visualization module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:GPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 or (at your option) any later version
+** approved by the KDE Free Qt Foundation. The licenses are as published by
+** the Free Software Foundation and appearing in the file LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef ABSTRACTDECLARATIVEINTERFACE_P_H
+#define ABSTRACTDECLARATIVEINTERFACE_P_H
+
+#include <QtDataVisualization/qdatavisualizationglobal.h>
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the QtDataVisualization API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+
+QT_BEGIN_NAMESPACE
+
+class Q_DATAVISUALIZATION_EXPORT AbstractDeclarativeInterface
+{
+protected:
+ ~AbstractDeclarativeInterface();
+public:
+ virtual bool isReady() const = 0;
+};
+
+QT_END_NAMESPACE
+
+#endif
diff --git a/src/datavisualizationqml/abstractdeclarative.cpp b/src/datavisualizationqml/abstractdeclarative.cpp
index e449c7d5..5cbdd833 100644
--- a/src/datavisualizationqml/abstractdeclarative.cpp
+++ b/src/datavisualizationqml/abstractdeclarative.cpp
@@ -50,6 +50,7 @@ static QHash<AbstractDeclarative *, QQuickWindow *> graphWindowList;
AbstractDeclarative::AbstractDeclarative(QQuickItem *parent) :
QQuickItem(parent),
+ AbstractDeclarativeInterface(),
m_controller(0),
m_contextWindow(0),
m_renderMode(RenderIndirect),
diff --git a/src/datavisualizationqml/abstractdeclarative_p.h b/src/datavisualizationqml/abstractdeclarative_p.h
index ce98c8e7..76685603 100644
--- a/src/datavisualizationqml/abstractdeclarative_p.h
+++ b/src/datavisualizationqml/abstractdeclarative_p.h
@@ -44,6 +44,7 @@
#include <private/datavisualizationglobal_p.h>
#include <private/abstract3dcontroller_p.h>
+#include <QtDataVisualization/private/abstractdeclarativeinterface_p.h>
#include <QtQuick/QQuickItem>
#include <QtCore/QPointer>
@@ -55,7 +56,7 @@ class GLStateStore;
QT_BEGIN_NAMESPACE
-class AbstractDeclarative : public QQuickItem
+class AbstractDeclarative : public QQuickItem, public AbstractDeclarativeInterface
{
Q_OBJECT
Q_PROPERTY(SelectionFlags selectionMode READ selectionMode WRITE setSelectionMode NOTIFY selectionModeChanged)
@@ -239,7 +240,7 @@ public:
QMutex *mutex() { return &m_mutex; }
- bool isReady() { return isComponentComplete(); }
+ bool isReady() const override { return isComponentComplete(); }
public Q_SLOTS:
virtual void handleAxisXChanged(QAbstract3DAxis *axis) = 0;