QtWidgets: Fix errors about fields from anonymous namespaces (-Werror=subobject-linkage)

Move types to QtPrivate, fixing errors like:

error: QCalendarWidgetPrivate’ has a field
QCalendarWidgetPrivate::m_model whose type uses the anonymous namespace [-Werror=subobject-linkage]

The error appears in CMake Unity (Jumbo) builds apparently
due to multiple anonymous namespaces per file.

Task-number: QTBUG-109394
Pick-to: 6.5
Change-Id: Id678af4db5633b1b2267425c7751f1312935d5d5
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
This commit is contained in:
Friedemann Kleint 2023-01-13 10:18:00 +01:00 committed by Axel Spoerl
parent 93af309a70
commit bd5589de65
5 changed files with 51 additions and 23 deletions

View File

@ -14,7 +14,7 @@
QT_BEGIN_NAMESPACE
namespace {
namespace QtPrivate {
class PageItem : public QGraphicsItem
{
public:
@ -136,7 +136,10 @@ protected:
}
};
} // anonymous namespace
} // namespace QtPrivate
using GraphicsView = QtPrivate::GraphicsView;
using PageItem = QtPrivate::PageItem;
class QPrintPreviewWidgetPrivate : public QWidgetPrivate
{

View File

@ -49,13 +49,21 @@ QT_BEGIN_NAMESPACE
using namespace Qt::StringLiterals;
namespace {
namespace QtPrivate {
class QColorLuminancePicker;
class QColorPicker;
class QColorShower;
class QWellArray;
class QColorWell;
class QColorPickingEventFilter;
} // unnamed namespace
} // namespace QtPrivate
using QColorLuminancePicker = QtPrivate::QColorLuminancePicker;
using QColorPicker = QtPrivate::QColorPicker;
using QColorShower = QtPrivate::QColorShower;
using QWellArray = QtPrivate::QWellArray;
using QColorWell = QtPrivate::QColorWell;
using QColorPickingEventFilter = QtPrivate::QColorPickingEventFilter;
class QColorDialogPrivate : public QDialogPrivate
{
@ -150,7 +158,7 @@ private:
//////////// QWellArray BEGIN
namespace {
namespace QtPrivate {
class QWellArray : public QWidget
{
@ -465,7 +473,7 @@ void QWellArray::keyPressEvent(QKeyEvent* e)
return;
}
}
} // namespace QtPrivate
//////////// QWellArray END
@ -555,7 +563,7 @@ static inline void rgb2hsv(QRgb rgb, int &h, int &s, int &v)
c.getHsv(&h, &s, &v);
}
namespace {
namespace QtPrivate {
class QColorWell : public QWellArray
{
@ -705,9 +713,13 @@ private:
bool crossVisible;
};
} // namespace QtPrivate
static int pWidth = 220;
static int pHeight = 200;
namespace QtPrivate {
class QColorLuminancePicker : public QWidget
{
Q_OBJECT
@ -1308,7 +1320,7 @@ QColorShower::QColorShower(QColorDialog *parent)
retranslateStrings();
}
} // unnamed namespace
} // namespace QtPrivate
inline QRgb QColorDialogPrivate::currentColor() const { return cs->currentColor(); }
inline int QColorDialogPrivate::currentAlpha() const { return cs->currentAlpha(); }

View File

@ -28,17 +28,15 @@ QT_BEGIN_NAMESPACE
using namespace Qt::StringLiterals;
namespace {
struct Message {
QString content;
QString type;
};
}
class QErrorMessagePrivate : public QDialogPrivate
{
Q_DECLARE_PUBLIC(QErrorMessage)
public:
struct Message {
QString content;
QString type;
};
QPushButton * ok;
QCheckBox * again;
QTextEdit * errors;

View File

@ -13,7 +13,7 @@
QT_BEGIN_NAMESPACE
namespace {
namespace QtPrivate {
// Fixed column matrix, stores items as [i11, i12, i21, i22...],
// with FORTRAN-style index operator(r, c).
template <class T, int NumColumns>
@ -152,7 +152,7 @@ class QFormLayoutPrivate : public QLayoutPrivate
Q_DECLARE_PUBLIC(QFormLayout)
public:
typedef FixedColumnMatrix<QFormLayoutItem *, ColumnCount> ItemMatrix;
typedef QtPrivate::FixedColumnMatrix<QFormLayoutItem *, ColumnCount> ItemMatrix;
QFormLayoutPrivate();
~QFormLayoutPrivate() { }

View File

@ -37,13 +37,13 @@ enum {
MinimumDayOffset = 1
};
namespace {
static QString formatNumber(int number, int fieldWidth)
{
return QString::number(number).rightJustified(fieldWidth, u'0');
}
namespace QtPrivate {
class QCalendarDateSectionValidator
{
public:
@ -398,9 +398,11 @@ struct SectionToken {
QCalendarDateSectionValidator *validator;
int repeat;
};
} // unnamed namespace
Q_DECLARE_TYPEINFO(SectionToken, Q_PRIMITIVE_TYPE);
namespace {
} // namespace QtPrivate
Q_DECLARE_TYPEINFO(QtPrivate::SectionToken, Q_PRIMITIVE_TYPE);
namespace QtPrivate {
class QCalendarDateValidator
{
@ -1606,7 +1608,20 @@ protected:
}
};
} // unnamed namespace
} // namespace QtPrivate
using QCalendarDateSectionValidator = QtPrivate::QCalendarDateSectionValidator;
using QCalendarDayValidator = QtPrivate::QCalendarDayValidator;
using QCalendarMonthValidator = QtPrivate::QCalendarMonthValidator;
using QCalendarYearValidator = QtPrivate::QCalendarYearValidator;
using QCalendarDateValidator = QtPrivate::QCalendarDateValidator;
using QPrevNextCalButton = QtPrivate::QPrevNextCalButton;
using QCalendarDelegate = QtPrivate::QCalendarDelegate;
using QCalToolButton = QtPrivate::QCalToolButton;
using QCalendarDelegate = QtPrivate::QCalendarDelegate;
using QCalendarModel = QtPrivate::QCalendarModel;
using QCalendarView = QtPrivate::QCalendarView;
using QCalendarTextNavigator = QtPrivate::QCalendarTextNavigator;
class QCalendarWidgetPrivate : public QWidgetPrivate
{