Skip to content

Commit

Permalink
Core: Remove 'properties' feature
Browse files Browse the repository at this point in the history
Even QtCore alone cannot be built without the properties feature since
Qt 5.5. While fixing this is easy, other modules like dbus,
networking are also using QObject::property() and friends liberally.

All in all I doubt that anybody will miss the feature (otherwise it
would have been fixed in the last decade).

Change-Id: Iaf3cc20bda54ee2ff3b809fac8fa82b94ecc88c0
Reviewed-by: Lars Knoll <[email protected]>
Reviewed-by: Edward Welbourne <[email protected]>
  • Loading branch information
kkoehne committed Feb 14, 2022
1 parent b99fdae commit 8275611
Show file tree
Hide file tree
Showing 15 changed files with 6 additions and 73 deletions.
8 changes: 1 addition & 7 deletions src/corelib/configure.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -679,12 +679,6 @@ qt_feature("threadsafe-cloexec"
)
qt_feature_definition("threadsafe-cloexec" "QT_THREADSAFE_CLOEXEC" VALUE "1")
qt_feature_config("threadsafe-cloexec" QMAKE_PUBLIC_QT_CONFIG)
qt_feature("properties" PUBLIC
SECTION "Kernel"
LABEL "Properties"
PURPOSE "Supports scripting Qt-based applications."
)
qt_feature_definition("properties" "QT_NO_PROPERTIES" NEGATE VALUE "1")
qt_feature("regularexpression" PUBLIC
SECTION "Kernel"
LABEL "QRegularExpression"
Expand Down Expand Up @@ -861,7 +855,7 @@ qt_feature("animation" PUBLIC
SECTION "Utilities"
LABEL "Animation"
PURPOSE "Provides a framework for animations."
CONDITION QT_FEATURE_properties AND QT_FEATURE_easingcurve
CONDITION QT_FEATURE_easingcurve
)
qt_feature_definition("animation" "QT_NO_ANIMATION" NEGATE VALUE "1")
qt_feature("gestures" PUBLIC
Expand Down
5 changes: 0 additions & 5 deletions src/corelib/kernel/qobject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4048,8 +4048,6 @@ int QObjectPrivate::signalIndex(const char *signalName,
Properties
*****************************************************************************/

#ifndef QT_NO_PROPERTIES

/*!
Sets the value of the object's \a name property to \a value.
Expand Down Expand Up @@ -4163,9 +4161,6 @@ QList<QByteArray> QObject::dynamicPropertyNames() const
return QList<QByteArray>();
}

#endif // QT_NO_PROPERTIES


/*****************************************************************************
QObject debugging output routines.
*****************************************************************************/
Expand Down
2 changes: 0 additions & 2 deletions src/corelib/kernel/qobject.h
Original file line number Diff line number Diff line change
Expand Up @@ -397,13 +397,11 @@ class Q_CORE_EXPORT QObject
void dumpObjectTree() const;
void dumpObjectInfo() const;

#ifndef QT_NO_PROPERTIES
bool setProperty(const char *name, const QVariant &value);
QVariant property(const char *name) const;
QList<QByteArray> dynamicPropertyNames() const;
QBindingStorage *bindingStorage() { return &d_ptr->bindingStorage; }
const QBindingStorage *bindingStorage() const { return &d_ptr->bindingStorage; }
#endif // QT_NO_PROPERTIES

Q_SIGNALS:
void destroyed(QObject * = nullptr);
Expand Down
1 change: 0 additions & 1 deletion src/gui/configure.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -1158,7 +1158,6 @@ qt_feature("accessibility" PUBLIC
SECTION "Utilities"
LABEL "Accessibility"
PURPOSE "Provides accessibility support."
CONDITION QT_FEATURE_properties
)
qt_feature_definition("accessibility" "QT_NO_ACCESSIBILITY" NEGATE VALUE "1")
qt_feature("multiprocess" PRIVATE
Expand Down
2 changes: 0 additions & 2 deletions src/gui/kernel/qguiapplication.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1281,7 +1281,6 @@ static void init_platform(const QString &pluginNamesWithArguments, const QString
if (!QGuiApplicationPrivate::platform_theme)
QGuiApplicationPrivate::platform_theme = new QPlatformTheme;

#ifndef QT_NO_PROPERTIES
// Set arguments as dynamic properties on the native interface as
// boolean 'foo' or strings: 'foo=bar'
if (!platformArguments.isEmpty()) {
Expand All @@ -1296,7 +1295,6 @@ static void init_platform(const QString &pluginNamesWithArguments, const QString
}
}
}
#endif

const auto platformIntegration = QGuiApplicationPrivate::platformIntegration();
fontSmoothingGamma = platformIntegration->styleHint(QPlatformIntegration::FontSmoothingGamma).toReal();
Expand Down
2 changes: 0 additions & 2 deletions src/testlib/qtestblacklist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,14 +191,12 @@ static QSet<QByteArray> keywords()
<< "cmake"
;

#if QT_CONFIG(properties)
QCoreApplication *app = QCoreApplication::instance();
if (app) {
const QVariant platformName = app->property("platformName");
if (platformName.isValid())
set << platformName.toByteArray();
}
#endif

return set;
}
Expand Down
6 changes: 0 additions & 6 deletions src/tools/moc/generator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1022,8 +1022,6 @@ void Generator::generateMetacall()
}

if (cdef->propertyList.size()) {

fprintf(out, "\n#ifndef QT_NO_PROPERTIES\n ");
if (needElse)
fprintf(out, "else ");
fprintf(out,
Expand All @@ -1032,7 +1030,6 @@ void Generator::generateMetacall()
" || _c == QMetaObject::RegisterPropertyMetaType) {\n"
" qt_static_metacall(this, _c, _id, _a);\n"
" _id -= %d;\n }", int(cdef->propertyList.count()));
fprintf(out, "\n#endif // QT_NO_PROPERTIES");
}
if (methodList.size() || cdef->propertyList.size())
fprintf(out, "\n ");
Expand Down Expand Up @@ -1283,8 +1280,6 @@ void Generator::generateStaticMetacall()
needReset |= !p.reset.isEmpty();
hasBindableProperties |= !p.bind.isEmpty();
}
fprintf(out, "\n#ifndef QT_NO_PROPERTIES\n ");

if (needElse)
fprintf(out, "else ");
fprintf(out, "if (_c == QMetaObject::ReadProperty) {\n");
Expand Down Expand Up @@ -1429,7 +1424,6 @@ void Generator::generateStaticMetacall()
fprintf(out, " }\n");
}
fprintf(out, " }");
fprintf(out, "\n#endif // QT_NO_PROPERTIES");
needElse = true;
}

Expand Down
8 changes: 4 additions & 4 deletions src/widgets/configure.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ qt_feature("style-stylesheet" PUBLIC
SECTION "Styles"
LABEL "QStyleSheetStyle"
PURPOSE "Provides a widget style which is configurable via CSS."
CONDITION QT_FEATURE_style_windows AND QT_FEATURE_properties AND QT_FEATURE_cssparser
CONDITION QT_FEATURE_style_windows AND QT_FEATURE_cssparser
)
qt_feature_definition("style-stylesheet" "QT_NO_STYLE_STYLESHEET" NEGATE VALUE "1")
qt_feature("effects" PRIVATE
Expand Down Expand Up @@ -355,7 +355,7 @@ qt_feature("textedit" PUBLIC
SECTION "Widgets"
LABEL "QTextEdit"
PURPOSE "Supports rich text editing."
CONDITION QT_FEATURE_scrollarea AND QT_FEATURE_properties AND QT_FEATURE_widgettextcontrol
CONDITION QT_FEATURE_scrollarea AND QT_FEATURE_widgettextcontrol
)
qt_feature_definition("textedit" "QT_NO_TEXTEDIT" NEGATE VALUE "1")
qt_feature("syntaxhighlighter" PUBLIC
Expand Down Expand Up @@ -468,7 +468,7 @@ qt_feature("wizard" PUBLIC
SECTION "Dialogs"
LABEL "QWizard"
PURPOSE "Provides a framework for multi-page click-through dialogs."
CONDITION ( QT_FEATURE_dialog ) AND ( QT_FEATURE_pushbutton ) AND ( QT_FEATURE_properties ) AND ( QT_FEATURE_label )
CONDITION ( QT_FEATURE_dialog ) AND ( QT_FEATURE_pushbutton ) AND ( QT_FEATURE_label )
)
qt_feature_definition("wizard" "QT_NO_WIZARD" NEGATE VALUE "1")
qt_feature("listview" PUBLIC
Expand Down Expand Up @@ -496,7 +496,7 @@ qt_feature("datawidgetmapper" PUBLIC
SECTION "ItemViews"
LABEL "QDataWidgetMapper"
PURPOSE "Provides mapping between a section of a data model to widgets."
CONDITION QT_FEATURE_itemviews AND QT_FEATURE_properties
CONDITION QT_FEATURE_itemviews
)
qt_feature_definition("datawidgetmapper" "QT_NO_DATAWIDGETMAPPER" NEGATE VALUE "1")
qt_feature("columnview" PUBLIC
Expand Down
4 changes: 0 additions & 4 deletions src/widgets/dialogs/qinputdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,7 @@ private slots:
private:
void keyPressEvent(QKeyEvent *event) override {
if ((event->key() == Qt::Key_Return || event->key() == Qt::Key_Enter) && !hasAcceptableInput()) {
#ifndef QT_NO_PROPERTIES
setProperty("value", property("value"));
#endif
} else {
QSpinBox::keyPressEvent(event);
}
Expand Down Expand Up @@ -153,9 +151,7 @@ private slots:
private:
void keyPressEvent(QKeyEvent *event) override {
if ((event->key() == Qt::Key_Return || event->key() == Qt::Key_Enter) && !hasAcceptableInput()) {
#ifndef QT_NO_PROPERTIES
setProperty("value", property("value"));
#endif
} else {
QDoubleSpinBox::keyPressEvent(event);
}
Expand Down
11 changes: 0 additions & 11 deletions src/widgets/itemviews/qitemdelegate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -522,10 +522,6 @@ QWidget *QItemDelegate::createEditor(QWidget *parent,

void QItemDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const
{
#ifdef QT_NO_PROPERTIES
Q_UNUSED(editor);
Q_UNUSED(index);
#else
QVariant v = index.data(Qt::EditRole);
QByteArray n = editor->metaObject()->userProperty().name();

Expand All @@ -534,7 +530,6 @@ void QItemDelegate::setEditorData(QWidget *editor, const QModelIndex &index) con
v = QVariant(editor->property(n).metaType());
editor->setProperty(n, v);
}
#endif
}

/*!
Expand All @@ -552,11 +547,6 @@ void QItemDelegate::setModelData(QWidget *editor,
QAbstractItemModel *model,
const QModelIndex &index) const
{
#ifdef QT_NO_PROPERTIES
Q_UNUSED(model);
Q_UNUSED(editor);
Q_UNUSED(index);
#else
Q_D(const QItemDelegate);
Q_ASSERT(model);
Q_ASSERT(editor);
Expand All @@ -566,7 +556,6 @@ void QItemDelegate::setModelData(QWidget *editor,
model->data(index, Qt::EditRole).userType());
if (!n.isEmpty())
model->setData(index, editor->property(n), Qt::EditRole);
#endif
}

/*!
Expand Down
11 changes: 0 additions & 11 deletions src/widgets/itemviews/qstyleditemdelegate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -458,10 +458,6 @@ QWidget *QStyledItemDelegate::createEditor(QWidget *parent,
*/
void QStyledItemDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const
{
#ifdef QT_NO_PROPERTIES
Q_UNUSED(editor);
Q_UNUSED(index);
#else
QVariant v = index.data(Qt::EditRole);
QByteArray n = editor->metaObject()->userProperty().name();

Expand All @@ -470,7 +466,6 @@ void QStyledItemDelegate::setEditorData(QWidget *editor, const QModelIndex &inde
v = QVariant(editor->property(n).metaType());
editor->setProperty(n, v);
}
#endif
}

/*!
Expand All @@ -487,11 +482,6 @@ void QStyledItemDelegate::setModelData(QWidget *editor,
QAbstractItemModel *model,
const QModelIndex &index) const
{
#ifdef QT_NO_PROPERTIES
Q_UNUSED(model);
Q_UNUSED(editor);
Q_UNUSED(index);
#else
Q_D(const QStyledItemDelegate);
Q_ASSERT(model);
Q_ASSERT(editor);
Expand All @@ -501,7 +491,6 @@ void QStyledItemDelegate::setModelData(QWidget *editor,
model->data(index, Qt::EditRole).userType());
if (!n.isEmpty())
model->setData(index, editor->property(n), Qt::EditRole);
#endif
}

/*!
Expand Down
2 changes: 0 additions & 2 deletions src/widgets/kernel/qwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9236,7 +9236,6 @@ bool QWidget::event(QEvent *event)
d->renderToTextureReallyDirty = 1;
#endif
break;
#ifndef QT_NO_PROPERTIES
case QEvent::DynamicPropertyChange: {
const QByteArray &propName = static_cast<QDynamicPropertyChangeEvent *>(event)->propertyName();
if (propName.length() == 13 && !qstrncmp(propName, "_q_customDpi", 12)) {
Expand All @@ -9254,7 +9253,6 @@ bool QWidget::event(QEvent *event)
windowHandle()->setProperty(propName, property(propName));
Q_FALLTHROUGH();
}
#endif
default:
return QObject::event(event);
}
Expand Down
10 changes: 0 additions & 10 deletions src/widgets/widgets/qwidgettextcontrol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1433,9 +1433,7 @@ QRectF QWidgetTextControlPrivate::rectForPosition(int position) const
int cursorWidth;
{
bool ok = false;
#ifndef QT_NO_PROPERTIES
cursorWidth = docLayout->property("cursorWidth").toInt(&ok);
#endif
if (!ok)
cursorWidth = 1;
}
Expand Down Expand Up @@ -2468,24 +2466,16 @@ void QWidgetTextControl::setOverwriteMode(bool overwrite)

int QWidgetTextControl::cursorWidth() const
{
#ifndef QT_NO_PROPERTIES
Q_D(const QWidgetTextControl);
return d->doc->documentLayout()->property("cursorWidth").toInt();
#else
return 1;
#endif
}

void QWidgetTextControl::setCursorWidth(int width)
{
Q_D(QWidgetTextControl);
#ifdef QT_NO_PROPERTIES
Q_UNUSED(width);
#else
if (width == -1)
width = QApplication::style()->pixelMetric(QStyle::PM_TextCursorWidth, nullptr);
d->doc->documentLayout()->setProperty("cursorWidth", width);
#endif
d->repaintCursor();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1481,9 +1481,7 @@ int TestObject::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
if (_id < ownMethodCount)
qt_static_metacall(this, _c, _id, _a);
_id -= ownMethodCount;
}
#ifndef QT_NO_PROPERTIES
else if (_c == QMetaObject::ReadProperty) {
} else if (_c == QMetaObject::ReadProperty) {
void *_v = _a[0];
switch (_id) {
case 0: *reinterpret_cast< int*>(_v) = intProp(); break;
Expand All @@ -1506,7 +1504,6 @@ int TestObject::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
} else if (_c == QMetaObject::ResetProperty) {
_id -= ownPropertyCount;
}
#endif // QT_NO_PROPERTIES
return _id;
}

Expand Down
2 changes: 0 additions & 2 deletions tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1481,14 +1481,12 @@ void tst_QComboBox::setCurrentText()
else
QCOMPARE(testWidget->currentText(), QString("foo"));

#ifndef QT_NO_PROPERTIES
// verify WRITE for currentText property
testWidget->setCurrentIndex(0);
const QByteArray n("currentText");
QCOMPARE(testWidget->property(n).toString(), QString("foo"));
testWidget->setProperty(n, QString("bar"));
QCOMPARE(testWidget->property(n).toString(), QString("bar"));
#endif
}

void tst_QComboBox::currentTextChanged_data()
Expand Down

0 comments on commit 8275611

Please sign in to comment.