Harden namespacing

When using namespaced Qt, we need to prevent symbol clashes with symbols
of the same name.

* namespace some globally visible classes
* use hidden function as static lib initializer

Task-number: QTBUG-138543
Pick-to: 6.10
Change-Id: I096064e1c4d17c172659f802459f5c1f91fa7454
Reviewed-by: Tomi Korpipää <tomi.korpipaa@qt.io>
This commit is contained in:
Tim Blechmann 2025-07-18 12:27:57 +08:00
parent 3aa9c52946
commit 6847e9b4cf
4 changed files with 16 additions and 11 deletions

View File

@ -14,17 +14,13 @@
#include <QtCore/qmath.h>
// Resources need to be explicitly initialized when building as static library
class StaticLibInitializer
static void initResources()
{
public:
StaticLibInitializer()
{
Q_INIT_RESOURCE(datavisualizationshaders);
Q_INIT_RESOURCE(datavisualizationmeshes);
}
};
StaticLibInitializer staticLibInitializer;
Q_INIT_RESOURCE(datavisualizationshaders);
Q_INIT_RESOURCE(datavisualizationmeshes);
}
Q_CONSTRUCTOR_FUNCTION(initResources)
QT_BEGIN_NAMESPACE

View File

@ -26,10 +26,11 @@
#include <QtCore/QMutex>
#include <QtCore/QSharedPointer>
class GLStateStore;
QT_BEGIN_NAMESPACE
class GLStateStore;
class AbstractDeclarative : public QQuickItem, public AbstractDeclarativeInterface
{
Q_OBJECT

View File

@ -11,6 +11,8 @@ static QFile *beforeFile = 0;
static QFile *afterFile = 0;
#endif
QT_BEGIN_NAMESPACE
GLStateStore::GLStateStore(QOpenGLContext *context, QObject *parent) :
QObject(parent),
QOpenGLFunctions(context)
@ -365,3 +367,5 @@ void GLStateStore::initGLDefaultState()
m_polygonOffsetFactor = 0.0;
m_polygonOffsetUnits = 0.0;
}
QT_END_NAMESPACE

View File

@ -18,6 +18,8 @@
#include <QtCore/QScopedArrayPointer>
#include "enumtostringmap_p.h"
QT_BEGIN_NAMESPACE
class GLStateStore : public QObject, protected QOpenGLFunctions
{
Q_OBJECT
@ -76,4 +78,6 @@ public:
GLfloat m_polygonOffsetUnits;
};
QT_END_NAMESPACE
#endif