summaryrefslogtreecommitdiffstats
path: root/tools/dumpcpp/main.cpp
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2021-03-15 10:34:57 +0100
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2021-03-15 11:52:21 +0100
commit417b438c96c19bacd40e57307c7c6adba72a413c (patch)
tree7f09b37ea148a29c34a032f73c6086a8fb566a85 /tools/dumpcpp/main.cpp
parent03de877ae8e9da3b2d7b06268a5a2c1156ee50ee (diff)
Fix crash in dumpcpp-generated code
QWidget/QObject were generated as base classes for the generated class, which is no longer correct after the introduction of the QAxBaseWidget/Object classes. Pass the correct base QMetaObject and simplify the code since there is always a base class now. Pick-to: 6.1 Change-Id: I822f2de4ce65785cd45dc3b4adf1923efae556be Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Diffstat (limited to 'tools/dumpcpp/main.cpp')
-rw-r--r--tools/dumpcpp/main.cpp30
1 files changed, 12 insertions, 18 deletions
diff --git a/tools/dumpcpp/main.cpp b/tools/dumpcpp/main.cpp
index a7dbbea..092a3c0 100644
--- a/tools/dumpcpp/main.cpp
+++ b/tools/dumpcpp/main.cpp
@@ -29,6 +29,7 @@
#include "moc.h"
#include <QAxObject>
+#include <QAxBaseWidget>
#include <QFile>
#include <QMetaObject>
#include <QMetaEnum>
@@ -41,7 +42,6 @@
#include <QCoreApplication>
#include <QCommandLineOption>
#include <QCommandLineParser>
-#include <QWidget>
#include <QFileInfo>
#include <qt_windows.h>
#include <ocidl.h>
@@ -549,7 +549,6 @@ bool generateClassImpl(QTextStream &out, const QMetaObject *mo, const QByteArray
qualifiedClassName += className;
const QString moCode = mocCode(mo, QLatin1String(qualifiedClassName),
- category.testFlag(ActiveX) ? QLatin1String("QWidget") : QLatin1String("QObject"),
errorString);
if (moCode.isEmpty()) {
out << "#error moc error\n";
@@ -615,6 +614,13 @@ static void writeForwardDeclaration(QTextStream &declOut, const QByteArray &clas
}
}
+static const QMetaObject *baseMetaObject(ObjectCategories c)
+{
+ return c.testFlag(ActiveX)
+ ? &QAxBaseWidget::staticMetaObject
+ : &QAxBaseObject::staticMetaObject;
+}
+
bool generateTypeLibrary(QString typeLibFile, QString outname,
const QString &nameSpace, ObjectCategories category)
{
@@ -726,16 +732,10 @@ bool generateTypeLibrary(QString typeLibFile, QString outname,
// trigger meta object to collect references to other type libraries
switch (typekind) {
case TKIND_COCLASS:
- if (category & ActiveX)
- metaObject = qax_readClassInfo(typelib, typeinfo, &QWidget::staticMetaObject);
- else
- metaObject = qax_readClassInfo(typelib, typeinfo, &QObject::staticMetaObject);
+ metaObject = qax_readClassInfo(typelib, typeinfo, baseMetaObject(category));
break;
case TKIND_DISPATCH:
- if (category & ActiveX)
- metaObject = qax_readInterfaceInfo(typelib, typeinfo, &QWidget::staticMetaObject);
- else
- metaObject = qax_readInterfaceInfo(typelib, typeinfo, &QObject::staticMetaObject);
+ metaObject = qax_readInterfaceInfo(typelib, typeinfo, baseMetaObject(category));
break;
case TKIND_RECORD:
case TKIND_ENUM:
@@ -864,16 +864,10 @@ bool generateTypeLibrary(QString typeLibFile, QString outname,
switch (typekind) {
case TKIND_COCLASS:
- if (object_category & ActiveX)
- metaObject = qax_readClassInfo(typelib, typeinfo, &QWidget::staticMetaObject);
- else
- metaObject = qax_readClassInfo(typelib, typeinfo, &QObject::staticMetaObject);
+ metaObject = qax_readClassInfo(typelib, typeinfo, baseMetaObject(object_category));
break;
case TKIND_DISPATCH:
- if (object_category & ActiveX)
- metaObject = qax_readInterfaceInfo(typelib, typeinfo, &QWidget::staticMetaObject);
- else
- metaObject = qax_readInterfaceInfo(typelib, typeinfo, &QObject::staticMetaObject);
+ metaObject = qax_readInterfaceInfo(typelib, typeinfo, baseMetaObject(object_category));
break;
case TKIND_INTERFACE: { // only stub: QTBUG-27792, explicitly disable copy in inherited
// class to make related error messages clearer