diff options
author | Liang Qi <liang.qi@theqtcompany.com> | 2016-02-15 20:43:25 +0100 |
---|---|---|
committer | Liang Qi <liang.qi@theqtcompany.com> | 2016-02-15 20:43:25 +0100 |
commit | 05808fb8b011c760a2af6dd520b781447db4a0ba (patch) | |
tree | 2319d622b05c7ff70e2e3874ace5ecd0aec75531 | |
parent | 307cd0ed678b37395f02bfb11fd58f8d000da6af (diff) | |
parent | 450651e8155bbdec44253a9c282ec385257b2f8a (diff) |
Merge remote-tracking branch 'origin/5.6' into 5.7v5.7.0-alpha1
Conflicts:
.qmake.conf
Change-Id: I06247d29c4b05020e91bb377a7f93e5374184f47
-rw-r--r-- | dist/changes-5.6.0 | 22 | ||||
-rw-r--r-- | examples/activeqt/simple/doc/src/simple.qdoc | 3 | ||||
-rw-r--r-- | src/activeqt/container/qaxbase.cpp | 83 | ||||
-rw-r--r-- | src/activeqt/container/qaxdump.cpp | 2 | ||||
-rw-r--r-- | src/activeqt/container/qaxobject.h | 4 | ||||
-rw-r--r-- | src/activeqt/container/qaxscript.cpp | 4 | ||||
-rw-r--r-- | src/activeqt/container/qaxwidget.cpp | 4 | ||||
-rw-r--r-- | src/activeqt/container/qaxwidget.h | 4 | ||||
-rw-r--r-- | src/activeqt/control/qaxserver.cpp | 70 | ||||
-rw-r--r-- | src/activeqt/control/qaxserverbase.cpp | 37 | ||||
-rw-r--r-- | src/activeqt/control/qaxserverdll.cpp | 2 | ||||
-rw-r--r-- | src/activeqt/control/qaxservermain.cpp | 4 | ||||
-rw-r--r-- | src/activeqt/shared/qaxutils.cpp | 28 | ||||
-rw-r--r-- | src/activeqt/shared/qaxutils_p.h | 3 | ||||
-rw-r--r-- | tools/dumpcpp/main.cpp | 34 | ||||
-rw-r--r-- | tools/testcon/invokemethod.cpp | 2 | ||||
-rw-r--r-- | tools/testcon/main.cpp | 20 |
17 files changed, 174 insertions, 152 deletions
diff --git a/dist/changes-5.6.0 b/dist/changes-5.6.0 new file mode 100644 index 0000000..36c6c10 --- /dev/null +++ b/dist/changes-5.6.0 @@ -0,0 +1,22 @@ +Qt 5.6 introduces many new features and improvements as well as bugfixes +over the 5.5.x series. For more details, refer to the online documentation +included in this distribution. The documentation is also available online: + + http://doc.qt.io/qt-5/index.html + +The Qt version 5.6 series is binary compatible with the 5.5.x series. +Applications compiled for 5.5 will continue to run with 5.6. + +Some of the changes listed in this file include issue tracking numbers +corresponding to tasks in the Qt Bug Tracker: + + https://bugreports.qt.io/ + +Each of these identifiers can be entered in the bug tracker to obtain more +information about a particular change. + +**************************************************************************** +* Library * +**************************************************************************** + +- [QTBUG-46615] Adapted to High DPI scaling. diff --git a/examples/activeqt/simple/doc/src/simple.qdoc b/examples/activeqt/simple/doc/src/simple.qdoc index dbfc0bd..76ac4ea 100644 --- a/examples/activeqt/simple/doc/src/simple.qdoc +++ b/examples/activeqt/simple/doc/src/simple.qdoc @@ -74,6 +74,9 @@ \example activeqt/simple \title Simple Example (ActiveQt) + \brief The Simple example demonstrates the use + of QAxBindable and QAxFactory. + The Simple example demonstrates the use of QAxBindable::requestPropertyChange() and QAxBindable::propertyChanged(), and the use of QAxFactory through the \c QAXFACTORY_BEGIN(), diff --git a/src/activeqt/container/qaxbase.cpp b/src/activeqt/container/qaxbase.cpp index acc319e..472e041 100644 --- a/src/activeqt/container/qaxbase.cpp +++ b/src/activeqt/container/qaxbase.cpp @@ -663,13 +663,10 @@ QByteArray QAxEventSink::findProperty(DISPID dispID) if (!typeinfo) return propname; - BSTR names; - UINT cNames; - typeinfo->GetNames(dispID, &names, 1, &cNames); - if (cNames) { - propname = QString::fromWCharArray(names).toLatin1(); - SysFreeString(names); - } + + const QByteArray propnameI = qaxTypeInfoName(typeinfo, dispID); + if (!propnameI.isEmpty()) + propname = propnameI; typeinfo->Release(); QByteArray propsignal(propname + "Changed("); @@ -1406,7 +1403,7 @@ bool QAxBase::initializeRemote(IUnknown** ptr) at = server.indexOf(QChar::fromLatin1('@')); if (at != -1) { user = server.left(at); - server = server.mid(at+1); + server.remove(0, at + 1); at = user.indexOf(QChar::fromLatin1(':')); if (at != -1) { @@ -1416,7 +1413,7 @@ bool QAxBase::initializeRemote(IUnknown** ptr) at = user.indexOf(QChar::fromLatin1('/')); if (at != -1) { domain = user.left(at); - user = user.mid(at+1); + user.remove(0, at + 1); } } @@ -2298,17 +2295,9 @@ void MetaObjectGenerator::readEnumInfo() int value = vardesc->lpvarValue->lVal; int memid = vardesc->memid; // Get the name of the value - BSTR valuename; - QByteArray valueName; - UINT maxNamesOut; - enuminfo->GetNames(memid, &valuename, 1, &maxNamesOut); - if (maxNamesOut) { - valueName = QString::fromWCharArray(valuename).toLatin1(); - SysFreeString(valuename); - } else { + QByteArray valueName = qaxTypeInfoName(enuminfo, memid); + if (valueName.isEmpty()) valueName = "value" + QByteArray::number(valueindex++); - } - if (clashCheck.contains(QString::fromLatin1(valueName))) valueName += QByteArray::number(++clashIndex); @@ -2457,25 +2446,15 @@ void MetaObjectGenerator::readFuncsInfo(ITypeInfo *typeinfo, ushort nFuncs) if (!funcdesc) break; - QByteArray function; QByteArray type; QByteArray prototype; QList<QByteArray> parameters; // parse function description - BSTR bstrNames[256]; - UINT maxNames = 255; - UINT maxNamesOut; - typeinfo->GetNames(funcdesc->memid, (BSTR*)&bstrNames, maxNames, &maxNamesOut); - QList<QByteArray> names; - int p; - for (p = 0; p < (int)maxNamesOut; ++p) { - names << QString::fromWCharArray(bstrNames[p]).toLatin1(); - SysFreeString(bstrNames[p]); - } - + const QByteArrayList names = qaxTypeInfoNames(typeinfo, funcdesc->memid); + const int maxNamesOut = names.size(); // function name - function = names.at(0); + const QByteArray &function = names.at(0); if ((maxNamesOut == 3 && function == "QueryInterface") || (maxNamesOut == 1 && function == "AddRef") || (maxNamesOut == 1 && function == "Release") || @@ -2574,7 +2553,7 @@ void MetaObjectGenerator::readFuncsInfo(ITypeInfo *typeinfo, ushort nFuncs) bool defargs; do { QByteArray pnames; - for (p = 0; p < parameters.count(); ++p) { + for (int p = 0; p < parameters.count(); ++p) { pnames += parameters.at(p); if (p < parameters.count() - 1) pnames += ','; @@ -2640,24 +2619,17 @@ void MetaObjectGenerator::readVarsInfo(ITypeInfo *typeinfo, ushort nVars) } // get variable name - BSTR bstrName; - UINT maxNames = 1; - UINT maxNamesOut; - typeinfo->GetNames(vardesc->memid, &bstrName, maxNames, &maxNamesOut); - if (maxNamesOut != 1 || !bstrName) { + const QByteArray variableName = qaxTypeInfoName(typeinfo, vardesc->memid); + if (variableName.isEmpty()) { typeinfo->ReleaseVarDesc(vardesc); continue; } - QByteArray variableType; - QByteArray variableName; - uint flags = 0; - variableName = QString::fromWCharArray(bstrName).toLatin1(); - SysFreeString(bstrName); + uint flags = 0; // get variable type TYPEDESC typedesc = vardesc->elemdescVar.tdesc; - variableType = guessTypes(typedesc, typeinfo, variableName); + const QByteArray variableType = guessTypes(typedesc, typeinfo, variableName); // generate meta property if (!hasProperty(variableName)) { @@ -2798,29 +2770,17 @@ void MetaObjectGenerator::readEventInterface(ITypeInfo *eventinfo, IConnectionPo continue; } - QByteArray function; QByteArray prototype; QList<QByteArray> parameters; - // parse event function description - BSTR bstrNames[256]; - UINT maxNames = 255; - UINT maxNamesOut; - eventinfo->GetNames(funcdesc->memid, (BSTR*)&bstrNames, maxNames, &maxNamesOut); - QList<QByteArray> names; - int p; - for (p = 0; p < (int)maxNamesOut; ++p) { - names << QString::fromWCharArray(bstrNames[p]).toLatin1(); - SysFreeString(bstrNames[p]); - } + // parse event function description, get event function prototype + const QByteArrayList names = qaxTypeInfoNames(eventinfo, funcdesc->memid); - // get event function prototype - function = names.at(0); QByteArray type; // dummy - we don't care about return values for signals prototype = createPrototype(/*in*/ funcdesc, eventinfo, names, /*out*/type, parameters); if (!hasSignal(prototype)) { QByteArray pnames; - for (p = 0; p < parameters.count(); ++p) { + for (int p = 0; p < parameters.count(); ++p) { pnames += parameters.at(p); if (p < parameters.count() - 1) pnames += ','; @@ -3872,7 +3832,7 @@ bool QAxBase::dynamicCallHelper(const char *name, void *inout, QList<QVariant> & parse = !varc && normFunction.length() > function.length() + 2; if (parse) { QString args = QLatin1String(normFunction); - args = args.mid(function.length() + 1); + args.remove(0, function.length() + 1); // parse argument string int list of arguments QString curArg; const QChar *c = args.unicode(); @@ -4492,7 +4452,8 @@ QVariant QAxBase::asVariant() const else if (d->ptr) qvar.setValue(d->ptr); } else { - cn = cn.mid(cn.lastIndexOf(':') + 1) + '*'; + cn.remove(0, cn.lastIndexOf(':') + 1); + cn += '*'; QObject *object = qObject(); int typeId = QMetaType::type(cn); if (typeId == QMetaType::UnknownType) diff --git a/src/activeqt/container/qaxdump.cpp b/src/activeqt/container/qaxdump.cpp index db124d4..be22892 100644 --- a/src/activeqt/container/qaxdump.cpp +++ b/src/activeqt/container/qaxdump.cpp @@ -113,7 +113,7 @@ static QByteArray toType(const QByteArray &t) type = "int"; if (type.at(0) == 'Q') - type = type.mid(1); + type.remove(0, 1); type[0] = toupper(type.at(0)); if (type == "VariantList") type = "List"; diff --git a/src/activeqt/container/qaxobject.h b/src/activeqt/container/qaxobject.h index 5ce5835..fc09a70 100644 --- a/src/activeqt/container/qaxobject.h +++ b/src/activeqt/container/qaxobject.h @@ -50,8 +50,8 @@ class QAxObject : public QObject, public QAxBase friend class QAxEventSink; Q_OBJECT_FAKE public: - QObject* qObject() const { return (QObject*)this; } - const char *className() const; + QObject* qObject() const Q_DECL_OVERRIDE { return static_cast<QObject *>(const_cast<QAxObject *>(this)); } + const char *className() const Q_DECL_OVERRIDE; QAxObject(QObject *parent = 0); QAxObject(const QString &c, QObject *parent = 0); diff --git a/src/activeqt/container/qaxscript.cpp b/src/activeqt/container/qaxscript.cpp index 1d1711b..861edab 100644 --- a/src/activeqt/container/qaxscript.cpp +++ b/src/activeqt/container/qaxscript.cpp @@ -45,8 +45,6 @@ // Workaround for mingw-w64 bug #464 // See https://sourceforge.net/p/mingw-w64/bugs/464/ # define _NO_SCRIPT_GUIDS -#elif defined(Q_CC_BOR) && __BORLANDC__ < 0x560 -# define QT_NO_QAXSCRIPT #endif #include <qapplication.h> @@ -327,7 +325,7 @@ QWidget *QAxScriptSite::window() const if (w) w = w->window(); if (!w && qApp) - w = qApp->activeWindow(); + w = QApplication::activeWindow(); return w; } diff --git a/src/activeqt/container/qaxwidget.cpp b/src/activeqt/container/qaxwidget.cpp index f85e2c9..22febc9 100644 --- a/src/activeqt/container/qaxwidget.cpp +++ b/src/activeqt/container/qaxwidget.cpp @@ -517,7 +517,7 @@ bool QAxNativeEventFilter::nativeEventFilter(const QByteArray &, void *m, long * QMouseEvent e(type, pos, gpos, (Qt::MouseButton)button, translateMouseButtonState(msg->wParam), translateModifierState(msg->wParam)); - QApplication::sendEvent(ax, &e); + QCoreApplication::sendEvent(ax, &e); } } } @@ -1391,7 +1391,7 @@ HRESULT WINAPI QAxClientSite::RemoveMenus(HMENU /*hmenuShared*/) HRESULT WINAPI QAxClientSite::SetStatusText(LPCOLESTR pszStatusText) { QStatusTipEvent tip(QString::fromWCharArray(pszStatusText)); - QApplication::sendEvent(widget, &tip); + QCoreApplication::sendEvent(widget, &tip); return S_OK; } diff --git a/src/activeqt/container/qaxwidget.h b/src/activeqt/container/qaxwidget.h index 421933d..ce5efd3 100644 --- a/src/activeqt/container/qaxwidget.h +++ b/src/activeqt/container/qaxwidget.h @@ -73,7 +73,7 @@ public: virtual QAxAggregated *createAggregate(); protected: - bool initialize(IUnknown**); + bool initialize(IUnknown **) Q_DECL_OVERRIDE; virtual bool createHostWindow(bool); bool createHostWindow(bool, const QByteArray&); @@ -89,7 +89,7 @@ private: QAxClientSite *container; QAxWidgetPrivate *d; - const QMetaObject *parentMetaObject() const; + const QMetaObject *parentMetaObject() const Q_DECL_OVERRIDE; }; template <> inline QAxWidget *qobject_cast<QAxWidget*>(const QObject *o) diff --git a/src/activeqt/control/qaxserver.cpp b/src/activeqt/control/qaxserver.cpp index 1703765..6abf2a7 100644 --- a/src/activeqt/control/qaxserver.cpp +++ b/src/activeqt/control/qaxserver.cpp @@ -248,7 +248,7 @@ HRESULT UpdateRegistry(BOOL bRegister) // we try to create the ActiveX widgets later on... bool delete_qApp = false; if (!qApp) { - int argc = 0; + static int argc = 0; // static lifetime, since it's passed as reference to QApplication, which has a lifetime exceeding the stack frame (void)new QApplication(argc, 0); delete_qApp = true; } @@ -496,13 +496,11 @@ static const char* const type_map[][2] = // Userdefined Qt datatypes - some not on Borland though { "QCursor", "enum MousePointer" }, { "Qt::FocusPolicy", "enum FocusPolicy" }, -#ifndef Q_CC_BOR -# if __REQUIRED_RPCNDR_H_VERSION__ >= Q_REQUIRED_RPCNDR_H_VERSION +#if __REQUIRED_RPCNDR_H_VERSION__ >= Q_REQUIRED_RPCNDR_H_VERSION { "QRect", "struct QRect" }, { "QSize", "struct QSize" }, { "QPoint", "struct QPoint" }, -# endif -#endif +#endif // __REQUIRED_RPCNDR_H_VERSION__ >= Q_REQUIRED_RPCNDR_H_VERSION // And we support COM data types { "BOOL", "BOOL" }, { "BSTR", "BSTR" }, @@ -704,7 +702,15 @@ bool ignoreProps(const char *test) return ignore(test, ignore_props); } -#define STRIPCB(x) x = x.mid(1, x.length()-2) +static QString stripCurlyBraces(const QUuid &uuid) +{ + if (uuid.isNull()) + return QString(); + QString result = uuid.toString().toUpper(); + result.chop(1); + result.remove(0, 1); + return result; +} static QByteArray prototype(const QList<QByteArray> ¶meterTypes, const QList<QByteArray> ¶meterNames, bool *ok) { @@ -804,17 +810,14 @@ static HRESULT classIDL(QObject *o, const QMetaObject *mo, const QString &classN control = true; } - QString classID = qAxFactory()->classID(className).toString().toUpper(); - if (QUuid(classID).isNull()) + const QString classID = stripCurlyBraces(qAxFactory()->classID(className)); + if (classID.isEmpty()) return 4; - STRIPCB(classID); - QString interfaceID = qAxFactory()->interfaceID(className).toString().toUpper(); - if (QUuid(interfaceID).isNull()) + const QString interfaceID = stripCurlyBraces(qAxFactory()->interfaceID(className)); + if (interfaceID.isEmpty()) return 5; - STRIPCB(interfaceID); - QString eventsID = qAxFactory()->eventsID(className).toString().toUpper(); - bool hasEvents = !QUuid(eventsID).isNull(); - STRIPCB(eventsID); + const QString eventsID = stripCurlyBraces(qAxFactory()->eventsID(className)); + const bool hasEvents = !eventsID.isEmpty(); QString cleanClassName = qax_clean_type(className, mo); QString defProp(QLatin1String(mo->classInfo(mo->indexOfClassInfo("DefaultProperty")).value())); @@ -950,7 +953,7 @@ static HRESULT classIDL(QObject *o, const QMetaObject *mo, const QString &classN if (i <= qtSlots && ignoreSlots(name)) continue; - signature = signature.mid(name.length() + 1); + signature.remove(0, name.length() + 1); signature.truncate(signature.length() - 1); name = renameOverloads(replaceKeyword(name)); if (ignoreSlots(name)) @@ -970,7 +973,8 @@ static HRESULT classIDL(QObject *o, const QMetaObject *mo, const QString &classN if (!ok) outBuffer += "\t/****** Slot parameter uses unsupported datatype\n"; - outBuffer += "\t\t[id(" + QString::number(id).toLatin1() + ")] " + type + ' ' + name + '(' + ptype + ");\n"; + outBuffer += "\t\t[id(" + QByteArray::number(id) + ")] " + type + ' ' + + name + '(' + ptype + ");\n"; if (!ok) outBuffer += "\t******/\n"; @@ -1016,7 +1020,7 @@ static HRESULT classIDL(QObject *o, const QMetaObject *mo, const QString &classN QByteArray signature(signal.methodSignature()); QByteArray name(signature.left(signature.indexOf('('))); - signature = signature.mid(name.length() + 1); + signature.remove(0, name.length() + 1); signature.truncate(signature.length() - 1); QList<QByteArray> parameterTypes(signal.parameterTypes()); @@ -1082,11 +1086,7 @@ static HRESULT classIDL(QObject *o, const QMetaObject *mo, const QString &classN return S_OK; } -#if defined(Q_CC_BOR) -extern "C" __stdcall HRESULT DumpIDL(const QString &outfile, const QString &ver) -#else extern "C" HRESULT __stdcall DumpIDL(const QString &outfile, const QString &ver) -#endif { qAxIsServer = false; QTextStream out; @@ -1101,14 +1101,12 @@ extern "C" HRESULT __stdcall DumpIDL(const QString &outfile, const QString &ver) QString filebase = QString::fromWCharArray(qAxModuleFilename); filebase.truncate(filebase.lastIndexOf(QLatin1Char('.'))); - QString appID = qAxFactory()->appID().toString().toUpper(); - if (QUuid(appID).isNull()) + const QString appID = stripCurlyBraces(qAxFactory()->appID()); + if (appID.isEmpty()) return 1; - STRIPCB(appID); - QString typeLibID = qAxFactory()->typeLibID().toString().toUpper(); - if (QUuid(typeLibID).isNull()) + const QString typeLibID = stripCurlyBraces(qAxFactory()->typeLibID()); + if (typeLibID.isEmpty()) return 2; - STRIPCB(typeLibID); QString typelib = filebase.right(filebase.length() - filebase.lastIndexOf(QLatin1String("\\"))-1); if (!file.open(QIODevice::WriteOnly)) @@ -1124,12 +1122,9 @@ extern "C" HRESULT __stdcall DumpIDL(const QString &outfile, const QString &ver) if (version.isEmpty()) version = QLatin1String("1.0"); - QString idQRect(QUuid(CLSID_QRect).toString()); - STRIPCB(idQRect); - QString idQSize(QUuid(CLSID_QSize).toString()); - STRIPCB(idQSize); - QString idQPoint(QUuid(CLSID_QPoint).toString()); - STRIPCB(idQPoint); + const QString idQRect = stripCurlyBraces(QUuid(CLSID_QRect)); + const QString idQSize = stripCurlyBraces(QUuid(CLSID_QSize)); + const QString idQPoint = stripCurlyBraces(QUuid(CLSID_QPoint)); out << "/****************************************************************************" << endl; out << "** Interface definition generated for ActiveQt project" << endl; @@ -1147,7 +1142,7 @@ extern "C" HRESULT __stdcall DumpIDL(const QString &outfile, const QString &ver) // dummy application to create widgets bool delete_qApp = false; if (!qApp) { - int argc=0; + static int argc = 0; // static lifetime, since it's passed as reference to QApplication, which has a lifetime exceeding the stack frame (void)new QApplication(argc, 0); delete_qApp = true; } @@ -1172,7 +1167,6 @@ extern "C" HRESULT __stdcall DumpIDL(const QString &outfile, const QString &ver) out << "\t** use the correct files." << endl; out << "\t**" << endl; -#ifndef Q_CC_BOR #if __REQUIRED_RPCNDR_H_VERSION__ < Q_REQUIRED_RPCNDR_H_VERSION out << "\t** Required version of MIDL could not be verified. QRect, QSize and QPoint" << endl; out << "\t** support needs an updated Platform SDK to be installed." << endl; @@ -1204,10 +1198,6 @@ extern "C" HRESULT __stdcall DumpIDL(const QString &outfile, const QString &ver) #if __REQUIRED_RPCNDR_H_VERSION__ < Q_REQUIRED_RPCNDR_H_VERSION out << "\t*/" << endl; #endif -#else - out << "\t** Custom data types not supported with Borland." << endl; - out << "\t*************************************************************************" << endl; -#endif out << endl; out << "\t/* Forward declaration of classes that might be used as parameters */" << endl << endl; diff --git a/src/activeqt/control/qaxserverbase.cpp b/src/activeqt/control/qaxserverbase.cpp index b1eac89..d6af214 100644 --- a/src/activeqt/control/qaxserverbase.cpp +++ b/src/activeqt/control/qaxserverbase.cpp @@ -433,7 +433,7 @@ class QAxServerAggregate : public IUnknown { public: QAxServerAggregate(const QString &className, IUnknown *outerUnknown) - : m_outerUnknown(outerUnknown), ref(0) + : ref(0) { object = new QAxServerBase(className, outerUnknown); object->registerActiveObject(this); @@ -476,7 +476,6 @@ public: private: QAxServerBase *object; - IUnknown *m_outerUnknown; LONG ref; CRITICAL_SECTION refCountSection; @@ -790,7 +789,7 @@ private: LRESULT QT_WIN_CALLBACK axs_FilterProc(int nCode, WPARAM wParam, LPARAM lParam) { if (qApp && !invokeCount) - qApp->sendPostedEvents(); + QCoreApplication::sendPostedEvents(); return CallNextHookEx(qax_hhook, nCode, wParam, lParam); } @@ -906,7 +905,7 @@ public: int argc = 0; new QApplication(argc, 0); } - qApp->setQuitOnLastWindowClosed(false); + QGuiApplication::setQuitOnLastWindowClosed(false); if (qAxOutProcServer) QAbstractEventDispatcher::instance()->installNativeEventFilter(qax_winEventFilter()); @@ -921,7 +920,7 @@ public: // If we created QApplication instance, ensure native event loop starts properly // by calling processEvents. if (qax_ownQApp) - qApp->processEvents(); + QCoreApplication::processEvents(); HRESULT res; // Create the ActiveX wrapper - aggregate if requested @@ -1321,7 +1320,7 @@ bool QAxServerBase::internalCreate() if (isWidget) { if (!stayTopLevel) { QEvent e(QEvent::EmbeddingControl); - QApplication::sendEvent(qt.widget, &e); + QCoreApplication::sendEvent(qt.widget, &e); } qt.widget->setAttribute(Qt::WA_QuitOnClose, false); qt.widget->move(0, 0); @@ -1970,7 +1969,7 @@ int QAxServerBase::qt_metacall(QMetaObject::Call call, int index, void **argv) } } - signature = signature.mid(name.length() + 1); + signature.remove(0, name.length() + 1); signature.truncate(signature.length() - 1); if (!signature.isEmpty()) @@ -2291,15 +2290,11 @@ HRESULT WINAPI QAxServerBase::Invoke(DISPID dispidMember, REFIID riid, index = mo->indexOfProperty(name); } } else { - BSTR bname; - UINT cname = 0; - if (m_spTypeInfo) - m_spTypeInfo->GetNames(dispidMember, &bname, 1, &cname); - if (!cname) + if (!m_spTypeInfo) + return res; + name = qaxTypeInfoName(m_spTypeInfo, dispidMember); + if (name.isEmpty()) return res; - - name = QString::fromWCharArray(bname).toLatin1(); - SysFreeString(bname); } } @@ -2620,13 +2615,9 @@ HRESULT WINAPI QAxServerBase::Invoke(DISPID dispidMember, REFIID riid, if (!exception->context.isNull()) { QString context = exception->context; int contextID = 0; - int br = context.indexOf(QLatin1Char('[')); + const int br = context.indexOf(QLatin1Char('[')); // "error[42]" if (br != -1) { - context = context.mid(br+1); - context.chop(1); - contextID = context.toInt(); - - context = exception->context; + contextID = context.midRef(br + 1, context.size() - br - 2).toInt(); context.truncate(br-1); } pexcepinfo->bstrHelpFile = QStringToBSTR(context); @@ -3343,7 +3334,7 @@ HRESULT WINAPI QAxServerBase::OnAmbientPropertyChange(DISPID dispID) case DISPID_AMBIENT_RIGHTTOLEFT: if (var.vt != VT_BOOL) break; - qApp->setLayoutDirection(var.boolVal?Qt::RightToLeft:Qt::LeftToRight); + QGuiApplication::setLayoutDirection(var.boolVal ? Qt::RightToLeft : Qt::LeftToRight); break; } @@ -3582,7 +3573,7 @@ HRESULT WINAPI QAxServerBase::TranslateAcceleratorW(MSG *pMsg) QKeyEvent override(QEvent::ShortcutOverride, key, (Qt::KeyboardModifiers)state); override.ignore(); - QApplication::sendEvent(qt.widget->focusWidget(), &override); + QCoreApplication::sendEvent(qt.widget->focusWidget(), &override); if (override.isAccepted()) return S_FALSE; } diff --git a/src/activeqt/control/qaxserverdll.cpp b/src/activeqt/control/qaxserverdll.cpp index fa4619b..7117cbb 100644 --- a/src/activeqt/control/qaxserverdll.cpp +++ b/src/activeqt/control/qaxserverdll.cpp @@ -96,7 +96,7 @@ STDAPI DllCanUnloadNow() return S_OK; // check if qApp still runs widgets (in other DLLs) - QWidgetList widgets = qApp->allWidgets(); + QWidgetList widgets = QApplication::allWidgets(); int count = widgets.count(); for (int w = 0; w < widgets.count(); ++w) { // remove all Qt generated widgets diff --git a/src/activeqt/control/qaxservermain.cpp b/src/activeqt/control/qaxservermain.cpp index 96cd503..8adb504 100644 --- a/src/activeqt/control/qaxservermain.cpp +++ b/src/activeqt/control/qaxservermain.cpp @@ -73,11 +73,7 @@ extern HRESULT GetClassObject(const GUID &clsid, const GUID &iid, void **ppUnk); extern ulong qAxLockCount(); extern bool qax_winEventFilter(void *message); -#if defined(Q_CC_BOR) -extern "C" __stdcall HRESULT DumpIDL(const QString &outfile, const QString &ver); -#else STDAPI DumpIDL(const QString &outfile, const QString &ver); -#endif // Monitors the shutdown event static DWORD WINAPI MonitorProc(void* /* pv */) diff --git a/src/activeqt/shared/qaxutils.cpp b/src/activeqt/shared/qaxutils.cpp index 9f94835..7c7e967 100644 --- a/src/activeqt/shared/qaxutils.cpp +++ b/src/activeqt/shared/qaxutils.cpp @@ -346,4 +346,32 @@ HRGN qaxHrgnFromQRegion(const QRegion ®ion, const QWidget *widget) #endif // QT_WIDGETS_LIB +QByteArray qaxTypeInfoName(ITypeInfo *typeInfo, MEMBERID memId) +{ + QByteArray result; + BSTR names; + UINT cNames = 0; + typeInfo->GetNames(memId, &names, 1, &cNames); + if (cNames && names) { + result = QString::fromWCharArray(names).toLatin1(); + SysFreeString(names); + } + return result; +} + +QByteArrayList qaxTypeInfoNames(ITypeInfo *typeInfo, MEMBERID memId) +{ + QByteArrayList result; + BSTR bstrNames[256]; + UINT maxNames = 255; + UINT maxNamesOut = 0; + typeInfo->GetNames(memId, reinterpret_cast<BSTR *>(&bstrNames), maxNames, &maxNamesOut); + result.reserve(maxNamesOut); + for (UINT p = 0; p < maxNamesOut; ++p) { + result.append(QString::fromWCharArray(bstrNames[p]).toLatin1()); + SysFreeString(bstrNames[p]); + } + return result; +} + QT_END_NAMESPACE diff --git a/src/activeqt/shared/qaxutils_p.h b/src/activeqt/shared/qaxutils_p.h index acd0eb8..f2576c1 100644 --- a/src/activeqt/shared/qaxutils_p.h +++ b/src/activeqt/shared/qaxutils_p.h @@ -120,6 +120,9 @@ QRect qaxFromNativeRect(const RECT &r, const QWidget *w); HRGN qaxHrgnFromQRegion(const QRegion ®ion, const QWidget *widget); #endif // QT_WIDGETS_LIB +QByteArray qaxTypeInfoName(ITypeInfo *typeInfo, MEMBERID memId); +QByteArrayList qaxTypeInfoNames(ITypeInfo *typeInfo, MEMBERID memId); + QT_END_NAMESPACE Q_DECLARE_METATYPE(IDispatch**) diff --git a/tools/dumpcpp/main.cpp b/tools/dumpcpp/main.cpp index 981039a..aa96d8c 100644 --- a/tools/dumpcpp/main.cpp +++ b/tools/dumpcpp/main.cpp @@ -65,6 +65,9 @@ enum ObjectCategory Licensed = 0x100, }; +Q_DECLARE_FLAGS(ObjectCategories, ObjectCategory) +Q_DECLARE_OPERATORS_FOR_FLAGS(ObjectCategories) + extern QMetaObject *qax_readEnumInfo(ITypeLib *typeLib, const QMetaObject *parentObject); extern QMetaObject *qax_readClassInfo(ITypeLib *typeLib, ITypeInfo *typeInfo, const QMetaObject *parentObject); extern QMetaObject *qax_readInterfaceInfo(ITypeLib *typeLib, ITypeInfo *typeInfo, const QMetaObject *parentObject); @@ -149,7 +152,9 @@ QByteArray constRefify(const QByteArray &type) return ctype; } -void generateClassDecl(QTextStream &out, const QString &controlID, const QMetaObject *mo, const QByteArray &className, const QByteArray &nameSpace, ObjectCategory category) +void generateClassDecl(QTextStream &out, const QString &controlID, const QMetaObject *mo, + const QByteArray &className, const QByteArray &nameSpace, + ObjectCategories category) { QList<QByteArray> functions; @@ -409,7 +414,7 @@ void generateClassDecl(QTextStream &out, const QString &controlID, const QMetaOb if (slotSignature.endsWith("()")) { // no parameters - no names slotNamedSignature = slotSignature; } else { - slotNamedSignature = slotSignature.left(slotSignature.indexOf('(') + 1); + slotNamedSignature.truncate(slotSignature.indexOf('(') + 1); QByteArray slotSignatureTruncated(slotSignature.mid(slotNamedSignature.length())); slotSignatureTruncated.truncate(slotSignatureTruncated.length() - 1); @@ -684,7 +689,8 @@ void generateMethodParameters(QTextStream &out, const QMetaObject *mo, const QMe out << endl; } -void generateClassImpl(QTextStream &out, const QMetaObject *mo, const QByteArray &className, const QByteArray &nameSpace, ObjectCategory category) +void generateClassImpl(QTextStream &out, const QMetaObject *mo, const QByteArray &className, + const QByteArray &nameSpace, ObjectCategories category) { Q_STATIC_ASSERT_X(QMetaObjectPrivate::OutputRevision == 7, "dumpcpp should generate the same version as moc"); @@ -928,7 +934,7 @@ static QByteArrayList vTableOnlyStubsFromTypeLib(ITypeLib *typelib, const QStrin } bool generateTypeLibrary(QString typeLibFile, QString outname, - const QString &nameSpace, ObjectCategory category) + const QString &nameSpace, ObjectCategories category) { typeLibFile.replace(QLatin1Char('/'), QLatin1Char('\\')); @@ -1087,7 +1093,7 @@ bool generateTypeLibrary(QString typeLibFile, QString outname, QByteArray refTypeLib; if (refType.contains("::")) { refTypeLib = refType; - refType = refType.mid(refType.lastIndexOf("::") + 2); + refType.remove(0, refType.lastIndexOf("::") + 2); if (refTypeLib.contains(' ')) { refType = refTypeLib.left(refTypeLib.indexOf(' ')) + ' ' + refType; } @@ -1165,7 +1171,7 @@ bool generateTypeLibrary(QString typeLibFile, QString outname, TYPEKIND typekind; typelib->GetTypeInfoType(index, &typekind); - uint object_category = category; + ObjectCategories object_category = category; if (!(typeattr->wTypeFlags & TYPEFLAG_FCANCREATE)) object_category |= SubObject; else if (typeattr->wTypeFlags & TYPEFLAG_FCONTROL) @@ -1219,18 +1225,22 @@ bool generateTypeLibrary(QString typeLibFile, QString outname, if (typeattr->wTypeFlags & TYPEFLAG_FLICENSED) object_category |= Licensed; if (typekind == TKIND_COCLASS) { // write those later... - generateClassDecl(classesOut, guid.toString(), metaObject, className, libName.toLatin1(), (ObjectCategory)(object_category|NoInlines)); + generateClassDecl(classesOut, guid.toString(), metaObject, className, libName.toLatin1(), + object_category | NoInlines); classesOut << endl; } else { - generateClassDecl(declOut, guid.toString(), metaObject, className, libName.toLatin1(), (ObjectCategory)(object_category|NoInlines)); + generateClassDecl(declOut, guid.toString(), metaObject, className, libName.toLatin1(), + object_category | NoInlines); declOut << endl; } subtypes << className; - generateClassDecl(inlinesOut, guid.toString(), metaObject, className, libName.toLatin1(), (ObjectCategory)(object_category|OnlyInlines)); + generateClassDecl(inlinesOut, guid.toString(), metaObject, className, libName.toLatin1(), + object_category | OnlyInlines); inlinesOut << endl; } if (implFile.isOpen()) - generateClassImpl(classImplOut, metaObject, className, libName.toLatin1(), (ObjectCategory)object_category); + generateClassImpl(classImplOut, metaObject, className, libName.toLatin1(), + object_category); } currentTypeInfo = 0; } @@ -1411,7 +1421,7 @@ struct Options Options() : mode(GenerateMode), category(DefaultObject), dispatchEqualsIDispatch(false) {} ProgramMode mode; - uint category; + ObjectCategories category; bool dispatchEqualsIDispatch; QString outname; @@ -1594,7 +1604,7 @@ int main(int argc, char **argv) return -2; } - if (!generateTypeLibrary(typeLib, options.outname, options.nameSpace, (ObjectCategory)options.category)) { + if (!generateTypeLibrary(typeLib, options.outname, options.nameSpace, options.category)) { qWarning("dumpcpp: error processing type library '%s'", qPrintable(typeLib)); return -1; } diff --git a/tools/testcon/invokemethod.cpp b/tools/testcon/invokemethod.cpp index d8cafb3..92c7a91 100644 --- a/tools/testcon/invokemethod.cpp +++ b/tools/testcon/invokemethod.cpp @@ -109,7 +109,7 @@ void InvokeMethod::on_comboMethods_activated(const QString &method) const QMetaObject *mo = activex->metaObject(); const QMetaMethod slot = mo->method(mo->indexOfSlot(method.toLatin1())); QString signature = QString::fromLatin1(slot.methodSignature()); - signature = signature.mid(signature.indexOf(QLatin1Char('(')) + 1); + signature.remove(0, signature.indexOf(QLatin1Char('(')) + 1); signature.truncate(signature.length()-1); QList<QByteArray> pnames = slot.parameterNames(); diff --git a/tools/testcon/main.cpp b/tools/testcon/main.cpp index 7891452..cce315c 100644 --- a/tools/testcon/main.cpp +++ b/tools/testcon/main.cpp @@ -44,6 +44,15 @@ QAXFACTORY_DEFAULT(MainWindow, QT_USE_NAMESPACE +static bool isOptionSet(int argc, char *argv[], const char *option) +{ + for (int i = 1; i < argc; ++i) { + if (!qstrcmp(argv[i], option)) + return true; + } + return false; +} + static void redirectDebugOutput(QtMsgType, const QMessageLogContext &, const QString &msg) { if (MainWindow *mainWindow = MainWindow::instance()) @@ -52,6 +61,11 @@ static void redirectDebugOutput(QtMsgType, const QMessageLogContext &, const QSt int main( int argc, char **argv ) { + if (isOptionSet(argc, argv, "--no-scaling")) + QCoreApplication::setAttribute(Qt::AA_DisableHighDpiScaling); + if (isOptionSet(argc, argv, "--no-native-siblings")) + QCoreApplication::setAttribute(Qt::AA_DontCreateNativeWidgetSiblings); + QApplication app( argc, argv ); QCoreApplication::setApplicationName(QLatin1String("TestCon")); QCoreApplication::setOrganizationName(QLatin1String("QtProject")); @@ -67,6 +81,12 @@ int main( int argc, char **argv ) QCommandLineOption noMessageHandlerOption(QLatin1String("no-messagehandler"), QLatin1String("Suppress installation of the message handler.")); parser.addOption(noMessageHandlerOption); + QCommandLineOption noScalingDummy(QLatin1String("no-scaling"), + QLatin1String("Set Qt::AA_DisableHighDpiScaling.")); + parser.addOption(noScalingDummy); + QCommandLineOption noNativeSiblingsDummy(QLatin1String("no-native-siblings"), + QLatin1String("Set Qt::AA_DontCreateNativeWidgetSiblings.")); + parser.addOption(noNativeSiblingsDummy); parser.addPositionalArgument(QLatin1String("clsid/file"), QLatin1String("The clsid/file to show.")); parser.process(app); |