diff options
27 files changed, 156 insertions, 56 deletions
diff --git a/qmake/generators/win32/msvc_objectmodel.cpp b/qmake/generators/win32/msvc_objectmodel.cpp index 60734b4d1b..34975f2b7b 100644 --- a/qmake/generators/win32/msvc_objectmodel.cpp +++ b/qmake/generators/win32/msvc_objectmodel.cpp @@ -1153,7 +1153,12 @@ bool VCCLCompilerTool::parseOption(const char* option) } found = false; break; case 'u': - UndefineAllPreprocessorDefinitions = _True; + if (!second) + UndefineAllPreprocessorDefinitions = _True; + else if (second == 't' && third == 'f' && fourth == '8') + AdditionalOptions += option; + else + found = false; break; case 'v': if(second == 'd' || second == 'm') { diff --git a/src/corelib/global/qfloat16.h b/src/corelib/global/qfloat16.h index 8fd2f212af..651057f8e2 100644 --- a/src/corelib/global/qfloat16.h +++ b/src/corelib/global/qfloat16.h @@ -196,6 +196,10 @@ QF16_MAKE_ARITH_OP_INT(*) QF16_MAKE_ARITH_OP_INT(/) #undef QF16_MAKE_ARITH_OP_INT +QT_WARNING_PUSH +QT_WARNING_DISABLE_CLANG("-Wfloat-equal") +QT_WARNING_DISABLE_GCC("-Wfloat-equal") + inline bool operator>(qfloat16 a, qfloat16 b) Q_DECL_NOTHROW { return static_cast<float>(a) > static_cast<float>(b); } inline bool operator<(qfloat16 a, qfloat16 b) Q_DECL_NOTHROW { return static_cast<float>(a) < static_cast<float>(b); } inline bool operator>=(qfloat16 a, qfloat16 b) Q_DECL_NOTHROW { return static_cast<float>(a) >= static_cast<float>(b); } @@ -230,6 +234,8 @@ QF16_MAKE_BOOL_OP_INT(==) QF16_MAKE_BOOL_OP_INT(!=) #undef QF16_MAKE_BOOL_OP_INT +QT_WARNING_POP + /*! \internal */ diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp index 7ca22e4a93..6dba733fb4 100644 --- a/src/corelib/global/qglobal.cpp +++ b/src/corelib/global/qglobal.cpp @@ -958,7 +958,8 @@ Q_STATIC_ASSERT_X(QT_POINTER_SIZE == sizeof(void *), "QT_POINTER_SIZE defined in \snippet code/src_corelib_global_qglobal.cpp 53 - \sa qConstOverload(), qNonConstOverload() + \sa qConstOverload(), qNonConstOverload(), {Differences between String-Based + and Functor-Based Connections} */ /*! \fn auto qConstOverload(T memberFunctionPointer) @@ -969,7 +970,8 @@ Q_STATIC_ASSERT_X(QT_POINTER_SIZE == sizeof(void *), "QT_POINTER_SIZE defined in \snippet code/src_corelib_global_qglobal.cpp 54 - \sa qOverload, qNonConstOverload + \sa qOverload, qNonConstOverload, {Differences between String-Based + and Functor-Based Connections} */ /*! \fn auto qNonConstOverload(T memberFunctionPointer) @@ -980,7 +982,8 @@ Q_STATIC_ASSERT_X(QT_POINTER_SIZE == sizeof(void *), "QT_POINTER_SIZE defined in \snippet code/src_corelib_global_qglobal.cpp 54 - \sa qOverload, qNonConstOverload + \sa qOverload, qNonConstOverload, {Differences between String-Based + and Functor-Based Connections} */ /*! diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp index 2f4f76856f..1b05962c07 100644 --- a/src/corelib/kernel/qobject.cpp +++ b/src/corelib/kernel/qobject.cpp @@ -2653,7 +2653,8 @@ static inline void check_and_warn_compat(const QMetaObject *sender, const QMetaM call qRegisterMetaType() to register the data type before you establish the connection. - \sa disconnect(), sender(), qRegisterMetaType(), Q_DECLARE_METATYPE() + \sa disconnect(), sender(), qRegisterMetaType(), Q_DECLARE_METATYPE(), + {Differences between String-Based and Functor-Based Connections} */ QMetaObject::Connection QObject::connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, @@ -4655,6 +4656,8 @@ void qDeleteInEventHandler(QObject *o) make sure to declare the argument type with Q_DECLARE_METATYPE Overloaded functions can be resolved with help of \l qOverload. + + \sa {Differences between String-Based and Functor-Based Connections} */ /*! diff --git a/src/corelib/kernel/qobjectdefs_impl.h b/src/corelib/kernel/qobjectdefs_impl.h index bd08ca1763..3f5f2e78bb 100644 --- a/src/corelib/kernel/qobjectdefs_impl.h +++ b/src/corelib/kernel/qobjectdefs_impl.h @@ -90,14 +90,9 @@ namespace QtPrivate { explicit ApplyReturnValue(void *data_) : data(data_) {} }; template<typename T, typename U> - void operator,(const T &value, const ApplyReturnValue<U> &container) { - if (container.data) - *reinterpret_cast<U*>(container.data) = value; - } - template<typename T, typename U> void operator,(T &&value, const ApplyReturnValue<U> &container) { if (container.data) - *reinterpret_cast<U*>(container.data) = value; + *reinterpret_cast<U *>(container.data) = std::forward<T>(value); } template<typename T> void operator,(T, const ApplyReturnValue<void> &) {} diff --git a/src/gui/image/qxpmhandler.cpp b/src/gui/image/qxpmhandler.cpp index 1f1f6b388f..ce7f7b8a0f 100644 --- a/src/gui/image/qxpmhandler.cpp +++ b/src/gui/image/qxpmhandler.cpp @@ -852,6 +852,9 @@ static bool read_xpm_header( #endif return false; // < 4 numbers parsed + if (*w <= 0 || *w > 32767 || *h <= 0 || *h > 32767 || *ncols <= 0 || *ncols > (64 * 64 * 64 * 64) || *cpp <= 0 || *cpp > 15) + return false; // failed sanity check + return true; } diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp index 334dc4a288..b665750181 100644 --- a/src/gui/kernel/qguiapplication.cpp +++ b/src/gui/kernel/qguiapplication.cpp @@ -670,7 +670,7 @@ void QGuiApplication::setApplicationDisplayName(const QString &name) disconnect(qGuiApp, &QGuiApplication::applicationNameChanged, qGuiApp, &QGuiApplication::applicationDisplayNameChanged); - if (QGuiApplicationPrivate::displayName != applicationName()) + if (*QGuiApplicationPrivate::displayName != applicationName()) emit qGuiApp->applicationDisplayNameChanged(); } } else if (name != *QGuiApplicationPrivate::displayName) { diff --git a/src/gui/painting/qrgba64.h b/src/gui/painting/qrgba64.h index a3ae0c9b14..2c8f8fa8c4 100644 --- a/src/gui/painting/qrgba64.h +++ b/src/gui/painting/qrgba64.h @@ -64,26 +64,14 @@ class QRgba64 { #endif }; - // No constructors are allowed in C++98, since this needs to be usable in a union. - // We however require one for constexprs in C++11/C++14 -#ifdef Q_COMPILER_CONSTEXPR explicit Q_ALWAYS_INLINE Q_DECL_CONSTEXPR QRgba64(quint64 c) : rgba(c) { } -#endif public: -#ifdef Q_COMPILER_CONSTEXPR - Q_ALWAYS_INLINE Q_DECL_CONSTEXPR QRgba64() : rgba(0) { } -#endif + QRgba64() = default; Q_DECL_CONSTEXPR static QRgba64 fromRgba64(quint64 c) { -#ifdef Q_COMPILER_CONSTEXPR return QRgba64(c); -#else - QRgba64 rgba64; - rgba64.rgba = c; - return rgba64; -#endif } Q_DECL_CONSTEXPR static QRgba64 fromRgba64(quint16 red, quint16 green, quint16 blue, quint16 alpha) diff --git a/src/tools/moc/generator.cpp b/src/tools/moc/generator.cpp index 674398e783..c4184929ef 100644 --- a/src/tools/moc/generator.cpp +++ b/src/tools/moc/generator.cpp @@ -1193,7 +1193,7 @@ void Generator::generateStaticMetacall() } fprintf(out, ");"); if (f.normalizedType != "void") { - fprintf(out, "\n if (_a[0]) *reinterpret_cast< %s*>(_a[0]) = _r; } ", + fprintf(out, "\n if (_a[0]) *reinterpret_cast< %s*>(_a[0]) = std::move(_r); } ", noRef(f.normalizedType).constData()); isUsed_a = true; } @@ -1483,10 +1483,7 @@ void Generator::generateSignal(FunctionDef *def,int index) } Q_ASSERT(!def->normalizedType.isEmpty()); - if (def->arguments.isEmpty() && def->normalizedType == "void") { - if (def->isPrivateSignal) - fprintf(out, "QPrivateSignal"); - + if (def->arguments.isEmpty() && def->normalizedType == "void" && !def->isPrivateSignal) { fprintf(out, ")%s\n{\n" " QMetaObject::activate(%s, &staticMetaObject, %d, nullptr);\n" "}\n", constQualifier, thisPtr.constData(), index); @@ -1503,17 +1500,13 @@ void Generator::generateSignal(FunctionDef *def,int index) if (def->isPrivateSignal) { if (!def->arguments.isEmpty()) fprintf(out, ", "); - fprintf(out, "QPrivateSignal"); + fprintf(out, "QPrivateSignal _t%d", offset++); } fprintf(out, ")%s\n{\n", constQualifier); if (def->type.name.size() && def->normalizedType != "void") { QByteArray returnType = noRef(def->normalizedType); - if (returnType.endsWith('*')) { - fprintf(out, " %s _t0 = 0;\n", returnType.constData()); - } else { - fprintf(out, " %s _t0 = %s();\n", returnType.constData(), returnType.constData()); - } + fprintf(out, " %s _t0{};\n", returnType.constData()); } fprintf(out, " void *_a[] = { "); @@ -1527,7 +1520,7 @@ void Generator::generateSignal(FunctionDef *def,int index) } int i; for (i = 1; i < offset; ++i) - if (def->arguments.at(i - 1).type.isVolatile) + if (i <= def->arguments.count() && def->arguments.at(i - 1).type.isVolatile) fprintf(out, ", const_cast<void*>(reinterpret_cast<const volatile void*>(&_t%d))", i); else fprintf(out, ", const_cast<void*>(reinterpret_cast<const void*>(&_t%d))", i); diff --git a/src/widgets/accessible/complexwidgets.cpp b/src/widgets/accessible/complexwidgets.cpp index ea3b88468b..397a58a5d4 100644 --- a/src/widgets/accessible/complexwidgets.cpp +++ b/src/widgets/accessible/complexwidgets.cpp @@ -41,7 +41,6 @@ #include <qaccessible.h> #include <qapplication.h> -#include <qabstractbutton.h> #include <qevent.h> #include <qheaderview.h> #include <qtabbar.h> diff --git a/src/widgets/accessible/qaccessiblewidgetfactory.cpp b/src/widgets/accessible/qaccessiblewidgetfactory.cpp index c95b5b1097..e7db53c251 100644 --- a/src/widgets/accessible/qaccessiblewidgetfactory.cpp +++ b/src/widgets/accessible/qaccessiblewidgetfactory.cpp @@ -103,11 +103,13 @@ QAccessibleInterface *qAccessibleFactory(const QString &classname, QObject *obje } else if (classname == QLatin1String("QToolButton")) { iface = new QAccessibleToolButton(widget); #endif // QT_NO_TOOLBUTTON +#if QT_CONFIG(abstractbutton) } else if (classname == QLatin1String("QCheckBox") || classname == QLatin1String("QRadioButton") || classname == QLatin1String("QPushButton") || classname == QLatin1String("QAbstractButton")) { iface = new QAccessibleButton(widget); +#endif } else if (classname == QLatin1String("QDialog")) { iface = new QAccessibleWidget(widget, QAccessible::Dialog); } else if (classname == QLatin1String("QMessageBox")) { diff --git a/src/widgets/accessible/qaccessiblewidgets.cpp b/src/widgets/accessible/qaccessiblewidgets.cpp index 40aca37f11..7f77f7c524 100644 --- a/src/widgets/accessible/qaccessiblewidgets.cpp +++ b/src/widgets/accessible/qaccessiblewidgets.cpp @@ -64,7 +64,6 @@ #include <QAbstractItemView> #include <QDockWidget> #include <QMainWindow> -#include <QAbstractButton> #include <private/qdockwidget_p.h> #include <QFocusFrame> diff --git a/src/widgets/accessible/simplewidgets.cpp b/src/widgets/accessible/simplewidgets.cpp index 600754f90c..a53e5eaf30 100644 --- a/src/widgets/accessible/simplewidgets.cpp +++ b/src/widgets/accessible/simplewidgets.cpp @@ -39,7 +39,9 @@ #include "simplewidgets_p.h" +#if QT_CONFIG(abstractbutton) #include <qabstractbutton.h> +#endif #if QT_CONFIG(checkbox) #include <qcheckbox.h> #endif @@ -80,6 +82,7 @@ extern QList<QWidget*> childWidgets(const QWidget *widget); QString qt_accStripAmp(const QString &text); QString qt_accHotKey(const QString &text); +#if QT_CONFIG(abstractbutton) /*! \class QAccessibleButton \brief The QAccessibleButton class implements the QAccessibleInterface for button type widgets. @@ -267,7 +270,7 @@ QStringList QAccessibleButton::keyBindingsForAction(const QString &actionName) c } return QStringList(); } - +#endif // QT_CONFIG(abstractbutton) #ifndef QT_NO_TOOLBUTTON /*! diff --git a/src/widgets/accessible/simplewidgets_p.h b/src/widgets/accessible/simplewidgets_p.h index 8bd0af8261..1e4ae5ab67 100644 --- a/src/widgets/accessible/simplewidgets_p.h +++ b/src/widgets/accessible/simplewidgets_p.h @@ -65,6 +65,7 @@ class QToolButton; class QGroupBox; class QProgressBar; +#if QT_CONFIG(abstractbutton) class QAccessibleButton : public QAccessibleWidget { Q_DECLARE_TR_FUNCTIONS(QAccessibleButton) @@ -83,6 +84,7 @@ public: protected: QAbstractButton *button() const; }; +#endif #ifndef QT_NO_TOOLBUTTON class QAccessibleToolButton : public QAccessibleButton diff --git a/src/widgets/configure.json b/src/widgets/configure.json index 99e1bd6940..14e4d10d38 100644 --- a/src/widgets/configure.json +++ b/src/widgets/configure.json @@ -117,6 +117,12 @@ "condition": "features.tableview", "output": [ "publicFeature", "feature" ] }, + "abstractbutton": { + "label": "QAbstractButton", + "purpose": "Abstract base class of button widgets, providing functionality common to buttons.", + "section": "Widgets", + "output": [ "publicFeature" ] + }, "commandlinkbutton": { "label": "QCommandLinkButton", "purpose": "Provides a Vista style command link button.", @@ -193,6 +199,7 @@ "label": "QRadioButton", "purpose": "Provides a radio button with a text label.", "section": "Widgets", + "condition": "features.abstractbutton", "output": [ "publicFeature" ] }, "spinbox": { @@ -234,20 +241,21 @@ "label": "QCheckBox(", "purpose": "Provides a checkbox with a text label.", "section": "Widgets", + "condition": "features.abstractbutton", "output": [ "publicFeature" ] }, "pushbutton": { "label": "QPushButton", "purpose": "Provides a command button.", "section": "Widgets", - "condition": "features.action", + "condition": "features.abstractbutton && features.action", "output": [ "publicFeature" ] }, "toolbutton": { "label": "QToolButton", "purpose": "Provides quick-access buttons to commands and options.", "section": "Widgets", - "condition": "features.action", + "condition": "features.abstractbutton && features.action", "output": [ "publicFeature", "feature" ] }, "toolbar": { @@ -274,7 +282,7 @@ "label": "QButtonGroup", "purpose": "Supports organizing groups of button widgets.", "section": "Widgets", - "condition": "features.groupbox", + "condition": "features.abstractbutton && features.groupbox", "output": [ "publicFeature", "feature" ] }, "mainwindow": { diff --git a/src/widgets/itemviews/qtableview.cpp b/src/widgets/itemviews/qtableview.cpp index c7cc1d155e..ed6482a8bc 100644 --- a/src/widgets/itemviews/qtableview.cpp +++ b/src/widgets/itemviews/qtableview.cpp @@ -49,7 +49,9 @@ #include <qevent.h> #include <qbitarray.h> #include <qscrollbar.h> +#if QT_CONFIG(abstractbutton) #include <qabstractbutton.h> +#endif #include <private/qtableview_p.h> #include <private/qheaderview_p.h> #include <private/qscrollbar_p.h> @@ -578,6 +580,7 @@ bool QSpanCollection::checkConsistency() const } #endif +#if QT_CONFIG(abstractbutton) class QTableCornerButton : public QAbstractButton { Q_OBJECT @@ -600,6 +603,7 @@ public: style()->drawControl(QStyle::CE_Header, &opt, &painter, this); } }; +#endif void QTableViewPrivate::init() { @@ -619,9 +623,11 @@ void QTableViewPrivate::init() tabKeyNavigation = true; +#if QT_CONFIG(abstractbutton) cornerWidget = new QTableCornerButton(q); cornerWidget->setFocusPolicy(Qt::NoFocus); QObject::connect(cornerWidget, SIGNAL(clicked()), q, SLOT(selectAll())); +#endif } /*! @@ -2121,6 +2127,7 @@ void QTableView::updateGeometries() if (d->horizontalHeader->isHidden()) QMetaObject::invokeMethod(d->horizontalHeader, "updateGeometries"); +#if QT_CONFIG(abstractbutton) // update cornerWidget if (d->horizontalHeader->isHidden() || d->verticalHeader->isHidden()) { d->cornerWidget->setHidden(true); @@ -2128,6 +2135,7 @@ void QTableView::updateGeometries() d->cornerWidget->setHidden(false); d->cornerWidget->setGeometry(verticalLeft, horizontalTop, width, height); } +#endif // update scroll bars @@ -2642,6 +2650,7 @@ bool QTableView::wordWrap() const return d->wrapItemText; } +#if QT_CONFIG(abstractbutton) /*! \property QTableView::cornerButtonEnabled \brief whether the button in the top-left corner is enabled @@ -2664,6 +2673,7 @@ bool QTableView::isCornerButtonEnabled() const Q_D(const QTableView); return d->cornerWidget->isEnabled(); } +#endif /*! \internal diff --git a/src/widgets/itemviews/qtableview.h b/src/widgets/itemviews/qtableview.h index 8c9ac379bc..b1c38d521f 100644 --- a/src/widgets/itemviews/qtableview.h +++ b/src/widgets/itemviews/qtableview.h @@ -58,7 +58,9 @@ class Q_WIDGETS_EXPORT QTableView : public QAbstractItemView Q_PROPERTY(Qt::PenStyle gridStyle READ gridStyle WRITE setGridStyle) Q_PROPERTY(bool sortingEnabled READ isSortingEnabled WRITE setSortingEnabled) Q_PROPERTY(bool wordWrap READ wordWrap WRITE setWordWrap) +#if QT_CONFIG(abstractbutton) Q_PROPERTY(bool cornerButtonEnabled READ isCornerButtonEnabled WRITE setCornerButtonEnabled) +#endif public: explicit QTableView(QWidget *parent = Q_NULLPTR); @@ -103,8 +105,10 @@ public: void setWordWrap(bool on); bool wordWrap() const; +#if QT_CONFIG(abstractbutton) void setCornerButtonEnabled(bool enable); bool isCornerButtonEnabled() const; +#endif QRect visualRect(const QModelIndex &index) const Q_DECL_OVERRIDE; void scrollTo(const QModelIndex &index, ScrollHint hint = EnsureVisible) Q_DECL_OVERRIDE; diff --git a/src/widgets/itemviews/qtableview_p.h b/src/widgets/itemviews/qtableview_p.h index 2ca158d657..d2f45d557d 100644 --- a/src/widgets/itemviews/qtableview_p.h +++ b/src/widgets/itemviews/qtableview_p.h @@ -192,7 +192,9 @@ public: QVector<int> rowsToUpdate; QHeaderView *horizontalHeader; QHeaderView *verticalHeader; +#if QT_CONFIG(abstractbutton) QWidget *cornerWidget; +#endif bool sortingEnabled; bool geometryRecursionBlock; QPoint visualCursor; // (Row,column) cell coordinates to track through span navigation. diff --git a/src/widgets/styles/qfusionstyle.cpp b/src/widgets/styles/qfusionstyle.cpp index 95fd0e5b2f..98d45587f0 100644 --- a/src/widgets/styles/qfusionstyle.cpp +++ b/src/widgets/styles/qfusionstyle.cpp @@ -45,7 +45,8 @@ #include <qcombobox.h> #if QT_CONFIG(pushbutton) #include <qpushbutton.h> -#else +#endif +#if QT_CONFIG(abstractbutton) #include <qabstractbutton.h> #endif #include <qpainter.h> @@ -3282,7 +3283,10 @@ void QFusionStyle::polish(QApplication *app) void QFusionStyle::polish(QWidget *widget) { QCommonStyle::polish(widget); - if (qobject_cast<QAbstractButton*>(widget) + if (false +#if QT_CONFIG(abstractbutton) + || qobject_cast<QAbstractButton*>(widget) +#endif #if QT_CONFIG(combobox) || qobject_cast<QComboBox *>(widget) #endif @@ -3323,7 +3327,10 @@ void QFusionStyle::polish(QPalette &pal) void QFusionStyle::unpolish(QWidget *widget) { QCommonStyle::unpolish(widget); - if (qobject_cast<QAbstractButton*>(widget) + if (false +#if QT_CONFIG(abstractbutton) + || qobject_cast<QAbstractButton*>(widget) +#endif #if QT_CONFIG(combobox) || qobject_cast<QComboBox *>(widget) #endif diff --git a/src/widgets/styles/qstylesheetstyle.cpp b/src/widgets/styles/qstylesheetstyle.cpp index 275a0550d2..2886093732 100644 --- a/src/widgets/styles/qstylesheetstyle.cpp +++ b/src/widgets/styles/qstylesheetstyle.cpp @@ -4268,6 +4268,7 @@ void QStyleSheetStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *op case PE_PanelButtonTool: case PE_PanelButtonCommand: +#if QT_CONFIG(abstractbutton) if (qobject_cast<const QAbstractButton *>(w) && rule.hasBackground() && rule.hasNativeBorder()) { //the window style will draw the borders ParentStyle::drawPrimitive(pe, opt, p, w); @@ -4276,6 +4277,7 @@ void QStyleSheetStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *op } return; } +#endif if (!rule.hasNativeBorder()) { rule.drawRule(p, rule.boxRect(opt->rect, QRenderRule::Margin)); return; diff --git a/src/widgets/styles/qwindowsxpstyle.cpp b/src/widgets/styles/qwindowsxpstyle.cpp index f3c6069f8a..b50c4b6be4 100644 --- a/src/widgets/styles/qwindowsxpstyle.cpp +++ b/src/widgets/styles/qwindowsxpstyle.cpp @@ -1139,7 +1139,10 @@ void QWindowsXPStyle::polish(QWidget *widget) if (!QWindowsXPStylePrivate::useXP()) return; - if (qobject_cast<QAbstractButton*>(widget) + if (false +#if QT_CONFIG(abstractbutton) + || qobject_cast<QAbstractButton*>(widget) +#endif || qobject_cast<QToolButton*>(widget) || qobject_cast<QTabBar*>(widget) #ifndef QT_NO_COMBOBOX @@ -1211,7 +1214,10 @@ void QWindowsXPStyle::unpolish(QWidget *widget) // already in the map might be old (other style). d->cleanupHandleMap(); } - if (qobject_cast<QAbstractButton*>(widget) + if (false +#if QT_CONFIG(abstractbutton) + || qobject_cast<QAbstractButton*>(widget) +#endif || qobject_cast<QToolButton*>(widget) || qobject_cast<QTabBar*>(widget) #ifndef QT_NO_COMBOBOX diff --git a/src/widgets/widgets/qabstractbutton.h b/src/widgets/widgets/qabstractbutton.h index 7bf0e0b9d6..4e438bd851 100644 --- a/src/widgets/widgets/qabstractbutton.h +++ b/src/widgets/widgets/qabstractbutton.h @@ -45,6 +45,8 @@ #include <QtGui/qkeysequence.h> #include <QtWidgets/qwidget.h> +QT_REQUIRE_CONFIG(abstractbutton); + QT_BEGIN_NAMESPACE diff --git a/src/widgets/widgets/qlabel.cpp b/src/widgets/widgets/qlabel.cpp index fa0cff45c9..39e072234e 100644 --- a/src/widgets/widgets/qlabel.cpp +++ b/src/widgets/widgets/qlabel.cpp @@ -41,7 +41,9 @@ #include "qevent.h" #include "qdrawutil.h" #include "qapplication.h" +#if QT_CONFIG(abstractbutton) #include "qabstractbutton.h" +#endif #include "qstyle.h" #include "qstyleoption.h" #include <limits.h> @@ -972,12 +974,14 @@ bool QLabel::event(QEvent *e) QShortcutEvent *se = static_cast<QShortcutEvent *>(e); if (se->shortcutId() == d->shortcutId) { QWidget * w = d->buddy; - QAbstractButton *button = qobject_cast<QAbstractButton *>(w); if (w->focusPolicy() != Qt::NoFocus) w->setFocus(Qt::ShortcutFocusReason); +#if QT_CONFIG(abstractbutton) + QAbstractButton *button = qobject_cast<QAbstractButton *>(w); if (button && !se->isAmbiguous()) button->animateClick(); else +#endif window()->setAttribute(Qt::WA_KeyboardFocusChange); return true; } diff --git a/src/widgets/widgets/qtoolbutton.h b/src/widgets/widgets/qtoolbutton.h index 95d159f12d..e2470524da 100644 --- a/src/widgets/widgets/qtoolbutton.h +++ b/src/widgets/widgets/qtoolbutton.h @@ -41,13 +41,14 @@ #define QTOOLBUTTON_H #include <QtWidgets/qtwidgetsglobal.h> + +#if QT_CONFIG(toolbutton) + #include <QtWidgets/qabstractbutton.h> QT_BEGIN_NAMESPACE -#ifndef QT_NO_TOOLBUTTON - class QToolButtonPrivate; class QMenu; class QStyleOptionToolButton; @@ -134,8 +135,8 @@ private: }; -#endif // QT_NO_TOOLBUTTON - QT_END_NAMESPACE +#endif // QT_CONFIG(toolbutton) + #endif // QTOOLBUTTON_H diff --git a/src/widgets/widgets/widgets.pri b/src/widgets/widgets/widgets.pri index f67640e40f..22e083a3d4 100644 --- a/src/widgets/widgets/widgets.pri +++ b/src/widgets/widgets/widgets.pri @@ -3,8 +3,6 @@ HEADERS += \ widgets/qbuttongroup.h \ widgets/qbuttongroup_p.h \ - widgets/qabstractbutton.h \ - widgets/qabstractbutton_p.h \ widgets/qabstractspinbox.h \ widgets/qabstractspinbox_p.h \ widgets/qcalendarwidget.h \ @@ -76,7 +74,6 @@ HEADERS += \ SOURCES += \ widgets/qbuttongroup.cpp \ - widgets/qabstractbutton.cpp \ widgets/qabstractspinbox.cpp \ widgets/qcalendarwidget.cpp \ widgets/qcombobox.cpp \ @@ -128,6 +125,15 @@ SOURCES += \ widgets/qtoolbararealayout.cpp \ widgets/qplaintextedit.cpp +qtConfig(abstractbutton) { + HEADERS += \ + widgets/qabstractbutton.h \ + widgets/qabstractbutton_p.h + + SOURCES += \ + widgets/qabstractbutton.cpp +} + qtConfig(abstractslider) { HEADERS += \ widgets/qabstractslider.h \ diff --git a/tests/auto/corelib/kernel/qobject/tst_qobject.cpp b/tests/auto/corelib/kernel/qobject/tst_qobject.cpp index e4677c6e34..5a5c4d3a40 100644 --- a/tests/auto/corelib/kernel/qobject/tst_qobject.cpp +++ b/tests/auto/corelib/kernel/qobject/tst_qobject.cpp @@ -5307,6 +5307,15 @@ void tst_QObject::connectNoDefaultConstructorArg() QVERIFY(connect(&ob, &NoDefaultContructorArguments::mySignal, &ob, &NoDefaultContructorArguments::mySlot, Qt::QueuedConnection)); } +struct MoveOnly +{ + int value; + explicit MoveOnly(int v = 1) : value(v) {} + MoveOnly(MoveOnly &&o) : value(o.value) { o.value = -1; } + MoveOnly &operator=(MoveOnly &&o) { value = o.value; o.value = -1; return *this; } + Q_DISABLE_COPY(MoveOnly); +}; + class ReturnValue : public QObject { friend class tst_QObject; Q_OBJECT @@ -5316,6 +5325,7 @@ signals: int returnInt(int); void returnVoid(int); CustomType returnCustomType(int); + MoveOnly returnMoveOnly(int); QObject *returnPointer(); public slots: @@ -5328,6 +5338,7 @@ public slots: QString returnHello() { return QStringLiteral("hello"); } QObject *returnThisSlot1() { return this; } ReturnValue *returnThisSlot2() { return this; } + MoveOnly returnMoveOnlySlot(int i) { return MoveOnly(i); } public: struct VariantFunctor { QVariant operator()(int i) { return i; } @@ -5344,6 +5355,9 @@ public: struct VoidFunctor { void operator()(int) {} }; + struct MoveOnlyFunctor { + MoveOnly operator()(int i) { return MoveOnly(i); } + }; }; QString someFunctionReturningString(int i) { @@ -5381,6 +5395,7 @@ void tst_QObject::returnValue() emit r.returnVoid(45); QCOMPARE((emit r.returnCustomType(45)).value(), CustomType().value()); QCOMPARE((emit r.returnPointer()), static_cast<QObject *>(0)); + QCOMPARE((emit r.returnMoveOnly(666)).value, MoveOnly().value); } { // connected to a slot returning the same type CheckInstanceCount checker; @@ -5395,6 +5410,8 @@ void tst_QObject::returnValue() QCOMPARE((emit r.returnCustomType(45)).value(), CustomType(45).value()); QVERIFY(connect(&r, &ReturnValue::returnPointer, &receiver, &ReturnValue::returnThisSlot1, type)); QCOMPARE((emit r.returnPointer()), static_cast<QObject *>(&receiver)); + QVERIFY(connect(&r, &ReturnValue::returnMoveOnly, &receiver, &ReturnValue::returnMoveOnlySlot, type)); + QCOMPARE((emit r.returnMoveOnly(666)).value, 666); } if (!isBlockingQueued) { // connected to simple functions or functor CheckInstanceCount checker; @@ -5413,6 +5430,10 @@ void tst_QObject::returnValue() ReturnValue::IntFunctor intFunctor; QVERIFY(connect(&r, &ReturnValue::returnInt, intFunctor)); QCOMPARE(emit r.returnInt(45), int(45)); + + ReturnValue::MoveOnlyFunctor moveOnlyFunctor; + QVERIFY(connect(&r, &ReturnValue::returnMoveOnly, moveOnlyFunctor)); + QCOMPARE((emit r.returnMoveOnly(666)).value, 666); } { // connected to a slot with different type CheckInstanceCount checker; @@ -5451,6 +5472,8 @@ void tst_QObject::returnValue() QCOMPARE((emit r.returnCustomType(45)).value(), CustomType().value()); QVERIFY(connect(&r, &ReturnValue::returnPointer, &receiver, &ReturnValue::returnVoidSlot, type)); QCOMPARE((emit r.returnPointer()), static_cast<QObject *>(0)); + QVERIFY(connect(&r, &ReturnValue::returnMoveOnly, &receiver, &ReturnValue::returnVoidSlot, type)); + QCOMPARE((emit r.returnMoveOnly(666)).value, MoveOnly().value); } if (!isBlockingQueued) { // queued connection should not forward the return value @@ -5466,6 +5489,8 @@ void tst_QObject::returnValue() QCOMPARE((emit r.returnCustomType(45)).value(), CustomType().value()); QVERIFY(connect(&r, &ReturnValue::returnPointer, &receiver, &ReturnValue::returnThisSlot1, Qt::QueuedConnection)); QCOMPARE((emit r.returnPointer()), static_cast<QObject *>(0)); + QVERIFY(connect(&r, &ReturnValue::returnMoveOnly, &receiver, &ReturnValue::returnMoveOnlySlot, Qt::QueuedConnection)); + QCOMPARE((emit r.returnMoveOnly(666)).value, MoveOnly().value); QCoreApplication::processEvents(); @@ -5549,6 +5574,8 @@ void tst_QObject::returnValue2() QCOMPARE(emit r.returnInt(45), int(45)); QVERIFY(connect(&r, SIGNAL(returnCustomType(int)), &receiver, SLOT(returnCustomTypeSlot(int)), type)); QCOMPARE((emit r.returnCustomType(45)).value(), CustomType(45).value()); + QVERIFY(connect(&r, SIGNAL(returnMoveOnly(int)), &receiver, SLOT(returnMoveOnlySlot(int)), type)); + QCOMPARE((emit r.returnMoveOnly(45)).value, 45); } { // connected to a slot returning void CheckInstanceCount checker; @@ -5561,6 +5588,8 @@ void tst_QObject::returnValue2() QCOMPARE(emit r.returnInt(45), int()); QVERIFY(connect(&r, SIGNAL(returnCustomType(int)), &receiver, SLOT(returnVoidSlot()), type)); QCOMPARE((emit r.returnCustomType(45)).value(), CustomType().value()); + QVERIFY(connect(&r, SIGNAL(returnMoveOnly(int)), &receiver, SLOT(returnVoidSlot()), type)); + QCOMPARE((emit r.returnMoveOnly(45)).value, MoveOnly().value); } if (!isBlockingQueued) { // queued connection should not forward the return value @@ -5574,6 +5603,9 @@ void tst_QObject::returnValue2() QCOMPARE(emit r.returnInt(45), int()); QVERIFY(connect(&r, SIGNAL(returnCustomType(int)), &receiver, SLOT(returnCustomTypeSlot(int)), Qt::QueuedConnection)); QCOMPARE((emit r.returnCustomType(45)).value(), CustomType().value()); + QVERIFY(connect(&r, SIGNAL(returnMoveOnly(int)), &receiver, SLOT(returnMoveOnlySlot(int)), Qt::QueuedConnection)); + QCOMPARE((emit r.returnMoveOnly(45)).value, MoveOnly().value); + QCoreApplication::processEvents(); //Queued conneciton with different return type should be safe diff --git a/tests/auto/tools/moc/tst_moc.cpp b/tests/auto/tools/moc/tst_moc.cpp index 5f1a0618ab..8189227cbe 100644 --- a/tests/auto/tools/moc/tst_moc.cpp +++ b/tests/auto/tools/moc/tst_moc.cpp @@ -2841,6 +2841,21 @@ void tst_Moc::privateSignalConnection() // We can't use function pointer connections to private signals which are overloaded because we would have to cast in this case to: // static_cast<void (ClassWithPrivateSignals::*)(int, ClassWithPrivateSignals::QPrivateSignal)>(&ClassWithPrivateSignals::overloadedMaybePrivate) // Which doesn't work as ClassWithPrivateSignals::QPrivateSignal is private. + + // Connecting from one private signal to another + { + ClassWithPrivateSignals classWithPrivateSignals1; + ClassWithPrivateSignals classWithPrivateSignals2; + SignalConnectionTester tester; + QObject::connect(&classWithPrivateSignals1, &ClassWithPrivateSignals::privateSignal1, + &classWithPrivateSignals2, &ClassWithPrivateSignals::privateSignal1); + QObject::connect(&classWithPrivateSignals2, &ClassWithPrivateSignals::privateSignal1, + &tester, &SignalConnectionTester::testSlot); + + QVERIFY(!tester.testPassed); + classWithPrivateSignals1.emitPrivateSignals(); + QVERIFY(tester.testPassed); + } } void tst_Moc::finalClasses_data() |