From 179696fcb809d5335dbbeceefb38a216bff81f5f Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Mon, 4 Jan 2021 09:57:55 +0100 Subject: uic: Do not generate QComboBox::AdjustToMinimumContentsLength into code The enumeration value was removed in Qt 6 by 1a342b2db14fa92bca717f5daff950b2eef869f7. Ignore it. Add a check to helper function checkProperty() and move the code from a5e2f2ddad0cc6b6a06f51e0dce6acf0fecf9de6 there as well. Pick-to: 6.0 Task-number: QTBUG-89093 Fixes: QTBUG-89700 Change-Id: I0890be8fff155d7342e2386b7f6b0783a5f3a192 Reviewed-by: Volker Hilsheimer Reviewed-by: Jarek Kobus --- src/tools/uic/cpp/cppwriteinitialization.cpp | 29 ++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) (limited to 'src/tools/uic/cpp/cppwriteinitialization.cpp') diff --git a/src/tools/uic/cpp/cppwriteinitialization.cpp b/src/tools/uic/cpp/cppwriteinitialization.cpp index d902052ee4..534a78791d 100644 --- a/src/tools/uic/cpp/cppwriteinitialization.cpp +++ b/src/tools/uic/cpp/cppwriteinitialization.cpp @@ -136,8 +136,29 @@ namespace { // Check on properties. Filter out empty legacy pixmap/icon properties // as Designer pre 4.4 used to remove missing resource references. // This can no longer be handled by the code as we have 'setIcon(QIcon())' as well as 'QIcon icon' - static bool checkProperty(const QString &fileName, const DomProperty *p) { + static bool checkProperty(const CustomWidgetsInfo *customWidgetsInfo, + const QString &fileName, const QString &className, + const DomProperty *p) { switch (p->kind()) { + // ### fixme Qt 7 remove this: Exclude deprecated properties of Qt 5. + case DomProperty::Set: + if (p->attributeName() == u"features" + && customWidgetsInfo->extends(className, QLatin1String("QDockWidget")) + && p->elementSet() == u"QDockWidget::AllDockWidgetFeatures") { + const QString msg = fileName + QLatin1String(": Warning: Deprecated enum value QDockWidget::AllDockWidgetFeatures was encountered."); + qWarning("%s", qPrintable(msg)); + return false; + } + break; + case DomProperty::Enum: + if (p->attributeName() == u"sizeAdjustPolicy" + && customWidgetsInfo->extends(className, QLatin1String("QComboBox")) + && p->elementEnum() == u"QComboBox::AdjustToMinimumContentsLength") { + const QString msg = fileName + QLatin1String(": Warning: Deprecated enum value QComboBox::AdjustToMinimumContentsLength was encountered."); + qWarning("%s", qPrintable(msg)); + return false; + } + break; case DomProperty::IconSet: if (const DomResourceIcon *dri = p->elementIconSet()) { if (!isIconFormat44(dri)) { @@ -1204,7 +1225,7 @@ void WriteInitialization::writeProperties(const QString &varName, bool frameShadowEncountered = false; for (const DomProperty *p : lst) { - if (!checkProperty(m_option.inputFile, p)) + if (!checkProperty(m_uic->customWidgetsInfo(), m_option.inputFile, className, p)) continue; QString propertyName = p->attributeName(); QString propertyValue; @@ -1297,10 +1318,6 @@ void WriteInitialization::writeProperties(const QString &varName, propertyName = QLatin1String("digitCount"); } else if (propertyName == QLatin1String("frameShadow")) { frameShadowEncountered = true; - } else if (p->kind() == DomProperty::Set && propertyName == u"features" - && m_uic->customWidgetsInfo()->extends(className, QLatin1String("QDockWidget")) - && p->elementSet() == u"QDockWidget::AllDockWidgetFeatures") { - continue; // ### fixme Qt 7 remove this: Exclude deprecated value of Qt 5. } bool stdset = m_stdsetdef; -- cgit v1.2.3