diff options
55 files changed, 903 insertions, 873 deletions
diff --git a/.qmake.conf b/.qmake.conf index 1ed62c5..f6895bb 100644 --- a/.qmake.conf +++ b/.qmake.conf @@ -1,3 +1,5 @@ load(qt_build_config) -MODULE_VERSION = 5.13.1 +DEFINES += QT_NO_FOREACH QT_NO_JAVA_STYLE_ITERATORS QT_NO_LINKED_LIST + +MODULE_VERSION = 5.14.0 diff --git a/examples/activeqt/comapp/main.cpp b/examples/activeqt/comapp/main.cpp index d341deb..74b7fa3 100644 --- a/examples/activeqt/comapp/main.cpp +++ b/examples/activeqt/comapp/main.cpp @@ -153,9 +153,7 @@ Document::Document(DocumentList *list) m_page->show(); } -Document::~Document() -{ -} +Document::~Document() = default; Application *Document::application() const { diff --git a/examples/activeqt/hierarchy/hierarchy.rc b/examples/activeqt/hierarchy/hierarchy.rc index da962f9..70eb503 100644 --- a/examples/activeqt/hierarchy/hierarchy.rc +++ b/examples/activeqt/hierarchy/hierarchy.rc @@ -1,2 +1,2 @@ 1 TYPELIB "hierarchy.rc" -1 ICON DISCARDABLE "hierarchy.ico" +1 ICON "hierarchy.ico" diff --git a/examples/activeqt/hierarchy/objects.h b/examples/activeqt/hierarchy/objects.h index 91f7e9d..cc9186e 100644 --- a/examples/activeqt/hierarchy/objects.h +++ b/examples/activeqt/hierarchy/objects.h @@ -68,7 +68,7 @@ class QParentWidget : public QWidget public: explicit QParentWidget(QWidget *parent = nullptr); - QSize sizeHint() const; + QSize sizeHint() const override; public slots: void createSubWidget(const QString &name); @@ -96,10 +96,10 @@ public: void setLabel(const QString &text); QString label() const; - QSize sizeHint() const; + QSize sizeHint() const override; protected: - void paintEvent(QPaintEvent *e); + void paintEvent(QPaintEvent *e) override; private: QString m_label; diff --git a/examples/activeqt/mediaplayer/mediaaxwidget.h b/examples/activeqt/mediaplayer/mediaaxwidget.h index a57ca05..a6da749 100644 --- a/examples/activeqt/mediaplayer/mediaaxwidget.h +++ b/examples/activeqt/mediaplayer/mediaaxwidget.h @@ -59,7 +59,7 @@ class MediaAxWidget : public QAxWidget { public: - MediaAxWidget(QWidget *parent = nullptr, Qt::WindowFlags f = 0) + MediaAxWidget(QWidget *parent = nullptr, Qt::WindowFlags f = {}) : QAxWidget(parent, f) { } diff --git a/examples/activeqt/menus/menus.cpp b/examples/activeqt/menus/menus.cpp index feb3540..18d1a5b 100644 --- a/examples/activeqt/menus/menus.cpp +++ b/examples/activeqt/menus/menus.cpp @@ -60,7 +60,7 @@ #include "filesave.xpm" QMenus::QMenus(QWidget *parent) - : QMainWindow(parent, 0) // QMainWindow's default flag is WType_TopLevel + : QMainWindow(parent, {}) // QMainWindow's default flag is WType_TopLevel { QAction *action; diff --git a/examples/activeqt/menus/menus.rc b/examples/activeqt/menus/menus.rc index fed692c..d466b35 100644 --- a/examples/activeqt/menus/menus.rc +++ b/examples/activeqt/menus/menus.rc @@ -1,2 +1,2 @@ 1 TYPELIB "menus.rc" -1 ICON DISCARDABLE "menus.ico" +1 ICON "menus.ico" diff --git a/examples/activeqt/multiple/ax1.h b/examples/activeqt/multiple/ax1.h index cbcc9e8..0a8ccb6 100644 --- a/examples/activeqt/multiple/ax1.h +++ b/examples/activeqt/multiple/ax1.h @@ -65,7 +65,7 @@ class QAxWidget1 : public QWidget Q_PROPERTY(QColor fillColor READ fillColor WRITE setFillColor) public: explicit QAxWidget1(QWidget *parent = nullptr) - : QWidget(parent), m_fillColor(Qt::red) + : QWidget(parent) { } @@ -81,7 +81,7 @@ public: } protected: - void paintEvent(QPaintEvent *e) + void paintEvent(QPaintEvent *e) override { QPainter paint(this); QRect r = rect(); @@ -90,7 +90,7 @@ protected: } private: - QColor m_fillColor; + QColor m_fillColor = Qt::red; }; //! [0] diff --git a/examples/activeqt/multiple/ax2.h b/examples/activeqt/multiple/ax2.h index 1e1b312..9249f1a 100644 --- a/examples/activeqt/multiple/ax2.h +++ b/examples/activeqt/multiple/ax2.h @@ -67,10 +67,7 @@ class QAxWidget2 : public QWidget Q_PROPERTY(int lineWidth READ lineWidth WRITE setLineWidth) public: - explicit QAxWidget2(QWidget *parent = nullptr) - : QWidget(parent), m_lineWidth(1) - { - } + using QWidget::QWidget; int lineWidth() const { @@ -84,7 +81,7 @@ public: } protected: - void paintEvent(QPaintEvent *e) + void paintEvent(QPaintEvent *e) override { QPainter paint(this); QPen pen = paint.pen(); @@ -97,7 +94,7 @@ protected: } private: - int m_lineWidth; + int m_lineWidth = 1; }; //! [0] diff --git a/examples/activeqt/multiple/multipleax.rc b/examples/activeqt/multiple/multipleax.rc index a847979..a9bcc1a 100644 --- a/examples/activeqt/multiple/multipleax.rc +++ b/examples/activeqt/multiple/multipleax.rc @@ -1,7 +1,7 @@ #include "winver.h" 1 TYPELIB "multipleax.rc" -1 ICON DISCARDABLE "multipleax.ico" +1 ICON "multipleax.ico" VS_VERSION_INFO VERSIONINFO FILEVERSION 1,0,0,0 diff --git a/examples/activeqt/opengl/glbox.cpp b/examples/activeqt/opengl/glbox.cpp index e0796cc..6eef79d 100644 --- a/examples/activeqt/opengl/glbox.cpp +++ b/examples/activeqt/opengl/glbox.cpp @@ -225,9 +225,9 @@ class ObjectSafetyImpl : public QAxAggregated, { public: //! [1] //! [2] - explicit ObjectSafetyImpl() {} + explicit ObjectSafetyImpl() = default; - long queryInterface(const QUuid &iid, void **iface) + long queryInterface(const QUuid &iid, void **iface) override { *iface = nullptr; if (iid == IID_IObjectSafety) @@ -243,14 +243,14 @@ public: QAXAGG_IUNKNOWN; //! [3] //! [4] - HRESULT WINAPI GetInterfaceSafetyOptions(REFIID riid, DWORD *pdwSupportedOptions, DWORD *pdwEnabledOptions) + HRESULT WINAPI GetInterfaceSafetyOptions(REFIID riid, DWORD *pdwSupportedOptions, DWORD *pdwEnabledOptions) override { *pdwSupportedOptions = INTERFACESAFE_FOR_UNTRUSTED_DATA | INTERFACESAFE_FOR_UNTRUSTED_CALLER; *pdwEnabledOptions = INTERFACESAFE_FOR_UNTRUSTED_DATA | INTERFACESAFE_FOR_UNTRUSTED_CALLER; return S_OK; } - HRESULT WINAPI SetInterfaceSafetyOptions(REFIID riid, DWORD pdwSupportedOptions, DWORD pdwEnabledOptions) + HRESULT WINAPI SetInterfaceSafetyOptions(REFIID riid, DWORD pdwSupportedOptions, DWORD pdwEnabledOptions) override { return S_OK; } diff --git a/examples/activeqt/opengl/glbox.h b/examples/activeqt/opengl/glbox.h index 00be3b9..b1bd828 100644 --- a/examples/activeqt/opengl/glbox.h +++ b/examples/activeqt/opengl/glbox.h @@ -75,7 +75,7 @@ class GLBox : public QGLWidget, public: explicit GLBox(QWidget *parent, const char *name = nullptr); virtual ~GLBox(); - QAxAggregated *createAggregate(); + QAxAggregated *createAggregate() override; public slots: void setXRotation(int degrees); @@ -84,9 +84,9 @@ public slots: void setZRotation(int degrees); protected: - void initializeGL(); - void paintGL(); - void resizeGL(int w, int h); + void initializeGL() override; + void paintGL() override; + void resizeGL(int w, int h) override; virtual GLuint makeObject(); private: diff --git a/examples/activeqt/opengl/main.cpp b/examples/activeqt/opengl/main.cpp index 4b4a4df..94cbf27 100644 --- a/examples/activeqt/opengl/main.cpp +++ b/examples/activeqt/opengl/main.cpp @@ -78,7 +78,6 @@ QAXFACTORY_END() int main(int argc, char *argv[]) { QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); - QApplication::setColorSpec(QApplication::CustomColor); QApplication a(argc,argv); if (QOpenGLContext::openGLModuleType() != QOpenGLContext::LibGL) { diff --git a/examples/activeqt/opengl/opengl.rc b/examples/activeqt/opengl/opengl.rc index f8282d8..02c0898 100644 --- a/examples/activeqt/opengl/opengl.rc +++ b/examples/activeqt/opengl/opengl.rc @@ -1,2 +1,2 @@ 1 TYPELIB "opengl.rc" -1 ICON DISCARDABLE "opengl.ico" +1 ICON "opengl.ico" diff --git a/examples/activeqt/simple/simple.rc b/examples/activeqt/simple/simple.rc index 3b40377..e38d406 100644 --- a/examples/activeqt/simple/simple.rc +++ b/examples/activeqt/simple/simple.rc @@ -1,3 +1,3 @@ 1 TYPELIB "simple.rc" -1 ICON DISCARDABLE "simple.ico" +1 ICON "simple.ico" diff --git a/examples/activeqt/simpleqml/simpleqml.rc b/examples/activeqt/simpleqml/simpleqml.rc index 7a6d549..d2978ce 100644 --- a/examples/activeqt/simpleqml/simpleqml.rc +++ b/examples/activeqt/simpleqml/simpleqml.rc @@ -1,2 +1,2 @@ 1 TYPELIB "simpleqml.rc" -1 ICON DISCARDABLE "simpleqml.ico" +1 ICON "simpleqml.ico" diff --git a/examples/activeqt/wrapper/main.cpp b/examples/activeqt/wrapper/main.cpp index 2683a41..3d8d0a1 100644 --- a/examples/activeqt/wrapper/main.cpp +++ b/examples/activeqt/wrapper/main.cpp @@ -64,12 +64,12 @@ public: : QAxFactory(lib, app) {} - QStringList featureList() const + QStringList featureList() const override { return m_activeElements.keys(); } - QObject *createObject(const QString &key) + QObject *createObject(const QString &key) override { auto it = m_activeElements.find(key); if (it != m_activeElements.end()) @@ -77,7 +77,7 @@ public: return nullptr; } - const QMetaObject *metaObject(const QString &key) const + const QMetaObject *metaObject(const QString &key) const override { auto it = m_activeElements.find(key); if (it != m_activeElements.end()) @@ -85,7 +85,7 @@ public: return nullptr; } - QUuid classID(const QString &key) const + QUuid classID(const QString &key) const override { auto it = m_activeElements.find(key); if (it != m_activeElements.end()) @@ -93,7 +93,7 @@ public: return QUuid(); } - QUuid interfaceID(const QString &key) const + QUuid interfaceID(const QString &key) const override { auto it = m_activeElements.find(key); if (it != m_activeElements.end()) @@ -101,7 +101,7 @@ public: return QUuid(); } - QUuid eventsID(const QString &key) const + QUuid eventsID(const QString &key) const override { auto it = m_activeElements.find(key); if (it != m_activeElements.end()) diff --git a/examples/activeqt/wrapper/wrapperax.rc b/examples/activeqt/wrapper/wrapperax.rc index 6db5316..c03c49e 100644 --- a/examples/activeqt/wrapper/wrapperax.rc +++ b/examples/activeqt/wrapper/wrapperax.rc @@ -1,7 +1,7 @@ #include "winver.h" 1 TYPELIB "wrapperax.rc" -1 ICON DISCARDABLE "wrapperax.ico" +1 ICON "wrapperax.ico" VS_VERSION_INFO VERSIONINFO FILEVERSION 1,0,0,0 diff --git a/src/activeqt/container/qaxbase.cpp b/src/activeqt/container/qaxbase.cpp index d87217f..1262944 100644 --- a/src/activeqt/container/qaxbase.cpp +++ b/src/activeqt/container/qaxbase.cpp @@ -125,8 +125,8 @@ struct QAxMetaObject : public QMetaObject { QAxMetaObject() { - d.data = 0; - d.stringdata = 0; + d.data = nullptr; + d.stringdata = nullptr; } ~QAxMetaObject() { @@ -135,7 +135,7 @@ struct QAxMetaObject : public QMetaObject } int numParameter(const QByteArray &prototype); - QByteArray paramType(const QByteArray &signature, int index, bool *out = 0); + QByteArray paramType(const QByteArray &signature, int index, bool *out = nullptr); QByteArray propertyType(const QByteArray &propertyName); void parsePrototype(const QByteArray &prototype); DISPID dispIDofName(const QByteArray &name, IDispatch *disp); @@ -244,7 +244,7 @@ static const char *const type_conversion[][2] = { "QList<bool>", "QVariantList" }, { "QList<QDateTime>", "QVariantList" }, { "QList<qlonglong>", "QVariantList" }, - { 0, 0 } + { nullptr, nullptr } }; /* @@ -257,11 +257,9 @@ static const char *const type_conversion[][2] = class QAxEventSink : public IDispatch, public IPropertyNotifySink { - Q_DISABLE_COPY(QAxEventSink) + Q_DISABLE_COPY_MOVE(QAxEventSink) public: - QAxEventSink(QAxBase *com) - : cpoint(0), ciid(IID_NULL), combase(com), ref(1) - {} + explicit QAxEventSink(QAxBase *com) : combase(com) {} virtual ~QAxEventSink() { Q_ASSERT(!cpoint); @@ -296,11 +294,11 @@ public: // disconnect from all connection points void unadvise() { - combase = 0; + combase = nullptr; if (cpoint) { cpoint->Unadvise(cookie); cpoint->Release(); - cpoint = 0; + cpoint = nullptr; } } @@ -343,7 +341,7 @@ public: } HRESULT __stdcall QueryInterface(REFIID riid, void **ppvObject) override { - *ppvObject = 0; + *ppvObject = nullptr; if (riid == IID_IUnknown) *ppvObject = static_cast<IUnknown *>(static_cast<IDispatch *>(this)); else if (riid == IID_IPropertyNotifySink) @@ -396,7 +394,7 @@ public: Q_ASSERT(index != -1); QString nameString = QLatin1String(signame); - void *argv[] = {0, &nameString, &pDispParams->cArgs, &pDispParams->rgvarg}; + void *argv[] = {nullptr, &nameString, &pDispParams->cArgs, &pDispParams->rgvarg}; QAxBase::qt_static_metacall(combase, QMetaObject::InvokeMetaMethod, index - meta->methodOffset(), argv); } @@ -425,9 +423,9 @@ public: void *static_argv_pointer[QAX_NUM_PARAMS + 1]; QVariant static_varp[QAX_NUM_PARAMS + 1]; - void **argv = 0; - void **argv_pointer = 0; // in case we need an additional level of indirection - QVariant *varp = 0; + void **argv = nullptr; + void **argv_pointer = nullptr; // in case we need an additional level of indirection + QVariant *varp = nullptr; if (pcount) { if (pcount <= QAX_NUM_PARAMS) { @@ -440,8 +438,8 @@ public: varp = new QVariant[pcount + 1]; } - argv[0] = 0; - argv_pointer[0] = 0; + argv[0] = nullptr; + argv_pointer[0] = nullptr; } int p; @@ -449,7 +447,7 @@ public: // map the VARIANT to the void* QByteArray ptype = axmeta->paramType(signame, p); varp[p + 1] = VARIANTToQVariant(pDispParams->rgvarg[pcount - p - 1], ptype); - argv_pointer[p + 1] = 0; + argv_pointer[p + 1] = nullptr; if (varp[p + 1].isValid()) { if (varp[p + 1].type() == QVariant::UserType) { argv[p + 1] = varp[p + 1].data(); @@ -519,7 +517,7 @@ public: int index = meta->indexOfSignal("propertyChanged(QString)"); if (index != -1) { QString propnameString = QString::fromLatin1(propname); - void *argv[] = {0, &propnameString}; + void *argv[] = {nullptr, &propnameString}; QAxBase::qt_static_metacall(combase, QMetaObject::InvokeMetaMethod, index - meta->methodOffset(), argv); } @@ -542,7 +540,7 @@ public: return S_OK; const QMetaProperty metaProp = meta->property(meta->indexOfProperty(propname)); - void *argv[] = {0, var.data()}; + void *argv[] = {nullptr, var.data()}; if (metaProp.type() == QVariant::Type(QMetaType::QVariant) || metaProp.type() == QVariant::LastType) argv[1] = &var; @@ -570,16 +568,16 @@ public: return static_cast<QAxObject *>(qobject)->receivers(QByteArray::number(QSIGNAL_CODE) + signalName); } - IConnectionPoint *cpoint; - IID ciid; - ULONG cookie; + IConnectionPoint *cpoint = nullptr; + IID ciid = IID_NULL; + ULONG cookie = 0; QMap<DISPID, QByteArray> sigs; QMap<DISPID, QByteArray> propsigs; QMap<DISPID, QByteArray> props; - QAxBase *combase; - LONG ref; + QAxBase *combase = nullptr; + LONG ref = 1; }; /* @@ -589,15 +587,13 @@ public: class QAxBasePrivate { - Q_DISABLE_COPY(QAxBasePrivate) + Q_DISABLE_COPY_MOVE(QAxBasePrivate) public: - typedef QHash<QUuid, QAxEventSink*> UuidEventSinkHash; + using UuidEventSinkHash = QHash<QUuid, QAxEventSink*>; QAxBasePrivate() : useEventSink(true), useMetaObject(true), useClassInfo(true), - cachedMetaObject(false), initialized(false), tryCache(false), - classContext(CLSCTX_SERVER), - ptr(0), disp(0), metaobj(0) + cachedMetaObject(false), initialized(false), tryCache(false) { // protect initialization QMutexLocker locker(&cache_mutex); @@ -640,10 +636,10 @@ public: uint cachedMetaObject :1; uint initialized :1; uint tryCache :1; - unsigned long classContext; + unsigned long classContext = CLSCTX_SERVER; - IUnknown *ptr; - mutable IDispatch *disp; + IUnknown *ptr = nullptr; + mutable IDispatch *disp = nullptr; QMap<QByteArray, bool> propWritable; @@ -656,7 +652,7 @@ public: mutable QMap<QString, LONG> verbs; - QAxMetaObject *metaobj; + QAxMetaObject *metaobj = nullptr; }; @@ -670,7 +666,7 @@ QByteArray QAxEventSink::findProperty(DISPID dispID) return propname; IDispatch *dispatch = combase->d->dispatch(); - ITypeInfo *typeinfo = 0; + ITypeInfo *typeinfo = nullptr; if (dispatch) dispatch->GetTypeInfo(0, LOCALE_USER_DEFAULT, &typeinfo); if (!typeinfo) @@ -904,7 +900,7 @@ QAxBase::~QAxBase() clear(); delete d; - d = 0; + d = nullptr; } /*! @@ -1153,11 +1149,11 @@ void QAxBase::clear() d->eventSink.clear(); if (d->disp) { d->disp->Release(); - d->disp = 0; + d->disp = nullptr; } if (d->ptr) { d->ptr->Release(); - d->ptr = 0; + d->ptr = nullptr; d->initialized = false; } @@ -1165,7 +1161,7 @@ void QAxBase::clear() if (!d->cachedMetaObject) delete d->metaobj; - d->metaobj = 0; + d->metaobj = nullptr; } /*! @@ -1184,10 +1180,10 @@ QStringList QAxBase::verbs() const return QStringList(); if (d->verbs.isEmpty()) { - IOleObject *ole = 0; + IOleObject *ole = nullptr; d->ptr->QueryInterface(IID_IOleObject, reinterpret_cast<void **>(&ole)); if (ole) { - IEnumOLEVERB *enumVerbs = 0; + IEnumOLEVERB *enumVerbs = nullptr; ole->EnumVerbs(&enumVerbs); if (enumVerbs) { enumVerbs->Reset(); @@ -1255,7 +1251,7 @@ bool QAxBase::initialize(IUnknown **ptr) asyncExposeSet = true; } - *ptr = 0; + *ptr = nullptr; bool res = false; @@ -1270,7 +1266,7 @@ bool QAxBase::initialize(IUnknown **ptr) res = initializeFromFile(ptr); if (!res) { // standard - HRESULT hres = CoCreateInstance(QUuid(ctrl), 0, d->classContext, IID_IUnknown, + HRESULT hres = CoCreateInstance(QUuid(ctrl), nullptr, d->classContext, IID_IUnknown, reinterpret_cast<void **>(ptr)); res = S_OK == hres; #ifndef QT_NO_DEBUG @@ -1279,7 +1275,7 @@ bool QAxBase::initialize(IUnknown **ptr) #endif } - return *ptr != 0; + return *ptr != nullptr; } /*! @@ -1299,15 +1295,15 @@ bool QAxBase::initializeLicensed(IUnknown** ptr) QString clsid(control().left(at)); QString key(control().mid(at+2)); - IClassFactory *factory = 0; - CoGetClassObject(QUuid(clsid), CLSCTX_SERVER, 0, IID_IClassFactory, + IClassFactory *factory = nullptr; + CoGetClassObject(QUuid(clsid), CLSCTX_SERVER, nullptr, IID_IClassFactory, reinterpret_cast<void **>(&factory)); if (!factory) return false; initializeLicensedHelper(factory, key, ptr); factory->Release(); - return *ptr != 0; + return *ptr != nullptr; } /* \internal @@ -1317,11 +1313,11 @@ bool QAxBase::initializeLicensed(IUnknown** ptr) bool QAxBase::initializeLicensedHelper(void *f, const QString &key, IUnknown **ptr) { IClassFactory *factory = reinterpret_cast<IClassFactory *>(f); - IClassFactory2 *factory2 = 0; + IClassFactory2 *factory2 = nullptr; factory->QueryInterface(IID_IClassFactory2, reinterpret_cast<void **>(&factory2)); if (factory2) { BSTR bkey = QStringToBSTR(key); - HRESULT hres = factory2->CreateInstanceLic(0, 0, IID_IUnknown, bkey, + HRESULT hres = factory2->CreateInstanceLic(nullptr, nullptr, IID_IUnknown, bkey, reinterpret_cast<void **>(ptr)); SysFreeString(bkey); #ifdef QT_DEBUG @@ -1359,9 +1355,9 @@ bool QAxBase::initializeLicensedHelper(void *f, const QString &key, IUnknown **p #endif factory2->Release(); } else { // give it a shot without license - factory->CreateInstance(0, IID_IUnknown, reinterpret_cast<void **>(ptr)); + factory->CreateInstance(nullptr, IID_IUnknown, reinterpret_cast<void **>(ptr)); } - return *ptr != 0; + return *ptr != nullptr; } @@ -1380,9 +1376,9 @@ bool QAxBase::initializeActive(IUnknown** ptr) int at = control().lastIndexOf(QLatin1String("}&")); QString clsid(control().left(at)); - GetActiveObject(QUuid(clsid), 0, ptr); + GetActiveObject(QUuid(clsid), nullptr, ptr); - return *ptr != 0; + return *ptr != nullptr; } #ifdef Q_CC_GNU @@ -1403,13 +1399,13 @@ bool QAxBase::initializeActive(IUnknown** ptr) */ bool QAxBase::initializeFromFile(IUnknown** ptr) { - IStorage *storage = 0; - ILockBytes * bytes = 0; - HRESULT hres = ::CreateILockBytesOnHGlobal(0, TRUE, &bytes); + IStorage *storage = nullptr; + ILockBytes * bytes = nullptr; + HRESULT hres = ::CreateILockBytesOnHGlobal(nullptr, TRUE, &bytes); hres = ::StgCreateDocfileOnILockBytes(bytes, STGM_SHARE_EXCLUSIVE|STGM_CREATE|STGM_READWRITE, 0, &storage); hres = OleCreateFromFile(CLSID_NULL, reinterpret_cast<const wchar_t*>(control().utf16()), - IID_IUnknown, OLERENDER_NONE, 0, 0, storage, + IID_IUnknown, OLERENDER_NONE, nullptr, nullptr, storage, reinterpret_cast<void **>(ptr)); storage->Release(); @@ -1490,7 +1486,7 @@ bool QAxBase::initializeRemote(IUnknown** ptr) COAUTHINFO authInfo; authInfo.dwAuthnSvc = RPC_C_AUTHN_WINNT; authInfo.dwAuthzSvc = RPC_C_AUTHZ_NONE; - authInfo.pwszServerPrincName = 0; + authInfo.pwszServerPrincName = nullptr; authInfo.dwAuthnLevel = RPC_C_AUTHN_LEVEL_DEFAULT; authInfo.dwImpersonationLevel = RPC_C_IMP_LEVEL_IMPERSONATE; authInfo.pAuthIdentityData = &authIdentity; @@ -1502,14 +1498,14 @@ bool QAxBase::initializeRemote(IUnknown** ptr) serverInfo.pAuthInfo = &authInfo; serverInfo.pwszName = reinterpret_cast<wchar_t *>(const_cast<ushort *>(server.utf16())); - IClassFactory *factory = 0; + IClassFactory *factory = nullptr; HRESULT res = CoGetClassObject(QUuid(clsid), CLSCTX_REMOTE_SERVER, &serverInfo, IID_IClassFactory, reinterpret_cast<void **>(&factory)); if (factory) { if (!key.isEmpty()) initializeLicensedHelper(factory, key, ptr); else - res = factory->CreateInstance(0, IID_IUnknown, reinterpret_cast<void **>(ptr)); + res = factory->CreateInstance(nullptr, IID_IUnknown, reinterpret_cast<void **>(ptr)); factory->Release(); } #ifndef QT_NO_DEBUG @@ -1531,7 +1527,7 @@ bool QAxBase::initializeRemote(IUnknown** ptr) */ long QAxBase::queryInterface(const QUuid &uuid, void **iface) const { - *iface = 0; + *iface = nullptr; if (!d->ptr) { const_cast<QAxBase *>(this)->initialize(&d->ptr); d->initialized = true; @@ -1566,9 +1562,8 @@ public: } private: - typedef QPair<QByteArray, int> ByteArrayIntPair; - typedef QList<ByteArrayIntPair> ByteArrayIntPairList; - typedef QMap<QByteArray, ByteArrayIntPairList>::ConstIterator EnumListMapConstIterator; + using ByteArrayIntPair = QPair<QByteArray, int>; + using ByteArrayIntPairList = QList<ByteArrayIntPair>; void init(); @@ -1696,10 +1691,10 @@ private: static int aggregateParameterCount(const QMap<QByteArray, Method> &map); struct Property { - Property() : flags(0) - {} + Property() = default; + QByteArray type; - uint flags; + uint flags = 0; QByteArray realType; }; QMap<QByteArray, Property> property_list; @@ -1742,13 +1737,13 @@ private: return enum_list.contains(enumname); } - QAxBase *that; - QAxBasePrivate *d; + QAxBase *that = nullptr; + QAxBasePrivate *d = nullptr; - IDispatch *disp; - ITypeInfo *dispInfo; - ITypeInfo *classInfo; - ITypeLib *typelib; + IDispatch *disp = nullptr; + ITypeInfo *dispInfo = nullptr; + ITypeInfo *classInfo = nullptr; + ITypeLib *typelib = nullptr; QByteArray current_typelib; QSettings iidnames; @@ -1762,7 +1757,7 @@ private: QMetaObject *qax_readEnumInfo(ITypeLib *typeLib, const QMetaObject *parentObject) { - MetaObjectGenerator generator(typeLib, 0); + MetaObjectGenerator generator(typeLib, nullptr); generator.readEnumInfo(); return generator.metaObject(parentObject, "EnumInfo"); @@ -1774,8 +1769,8 @@ QMetaObject *qax_readInterfaceInfo(ITypeLib *typeLib, ITypeInfo *typeInfo, const QString className; BSTR bstr; - if (S_OK != typeInfo->GetDocumentation(-1, &bstr, 0, 0, 0)) - return 0; + if (S_OK != typeInfo->GetDocumentation(-1, &bstr, nullptr, nullptr, nullptr)) + return nullptr; className = QString::fromWCharArray(bstr); SysFreeString(bstr); @@ -1789,14 +1784,14 @@ QMetaObject *qax_readInterfaceInfo(ITypeLib *typeLib, ITypeInfo *typeInfo, const QMetaObject *qax_readClassInfo(ITypeLib *typeLib, ITypeInfo *classInfo, const QMetaObject *parentObject) { - MetaObjectGenerator generator(typeLib, 0); + MetaObjectGenerator generator(typeLib, nullptr); generator.addSignal("exception(int,QString,QString,QString)", "code,source,disc,help"); generator.addSignal("propertyChanged(QString)", "name"); QString className; BSTR bstr; - if (S_OK != classInfo->GetDocumentation(-1, &bstr, 0, 0, 0)) - return 0; + if (S_OK != classInfo->GetDocumentation(-1, &bstr, nullptr, nullptr, nullptr)) + return nullptr; className = QString::fromWCharArray(bstr); SysFreeString(bstr); @@ -1819,23 +1814,23 @@ QMetaObject *qax_readClassInfo(ITypeLib *typeLib, ITypeInfo *classInfo, const QM if (flags & IMPLTYPEFLAG_FRESTRICTED) continue; - ITypeInfo *interfaceInfo = 0; + ITypeInfo *interfaceInfo = nullptr; classInfo->GetRefTypeInfo(refType, &interfaceInfo); if (!interfaceInfo) continue; - interfaceInfo->GetDocumentation(-1, &bstr, 0, 0, 0); + interfaceInfo->GetDocumentation(-1, &bstr, nullptr, nullptr, nullptr); QString interfaceName = QString::fromWCharArray(bstr); SysFreeString(bstr); QByteArray key; - TYPEATTR *typeattr = 0; + TYPEATTR *typeattr = nullptr; interfaceInfo->GetTypeAttr(&typeattr); if (flags & IMPLTYPEFLAG_FSOURCE) { if (typeattr && !(typeattr->wTypeFlags & TYPEFLAG_FHIDDEN)) key = "Event Interface " + QByteArray::number(index); - generator.readEventInterface(interfaceInfo, 0); + generator.readEventInterface(interfaceInfo, nullptr); } else { if (typeattr && !(typeattr->wTypeFlags & TYPEFLAG_FHIDDEN)) key = "Interface " + QByteArray::number(index); @@ -1860,15 +1855,15 @@ void qax_deleteMetaObject(QMetaObject *metaObject) } MetaObjectGenerator::MetaObjectGenerator(QAxBase *ax, QAxBasePrivate *dptr) -: that(ax), d(dptr), disp(0), dispInfo(0), classInfo(0), typelib(0), - iidnames(QLatin1String("HKEY_LOCAL_MACHINE\\Software\\Classes"), QSettings::NativeFormat) + : that(ax), d(dptr), + iidnames(QLatin1String("HKEY_LOCAL_MACHINE\\Software\\Classes"), QSettings::NativeFormat) { init(); } MetaObjectGenerator::MetaObjectGenerator(ITypeLib *tlib, ITypeInfo *tinfo) -: that(0), d(0), disp(0), dispInfo(tinfo), classInfo(0), typelib(tlib), - iidnames(QLatin1String("HKEY_LOCAL_MACHINE\\Software\\Classes"), QSettings::NativeFormat) + : dispInfo(tinfo), typelib(tlib), + iidnames(QLatin1String("HKEY_LOCAL_MACHINE\\Software\\Classes"), QSettings::NativeFormat) { init(); @@ -1877,7 +1872,7 @@ MetaObjectGenerator::MetaObjectGenerator(ITypeLib *tlib, ITypeInfo *tinfo) if (typelib) { typelib->AddRef(); BSTR bstr; - typelib->GetDocumentation(-1, &bstr, 0, 0, 0); + typelib->GetDocumentation(-1, &bstr, nullptr, nullptr, nullptr); current_typelib = QString::fromWCharArray(bstr).toLatin1(); SysFreeString(bstr); } @@ -1913,25 +1908,25 @@ QByteArray MetaObjectGenerator::usertypeToString(const TYPEDESC &tdesc, ITypeInf { HREFTYPE usertype = tdesc.hreftype; if (tdesc.vt != VT_USERDEFINED) - return 0; + return nullptr; QByteArray typeName; - ITypeInfo *usertypeinfo = 0; + ITypeInfo *usertypeinfo = nullptr; info->GetRefTypeInfo(usertype, &usertypeinfo); if (usertypeinfo) { - ITypeLib *usertypelib = 0; + ITypeLib *usertypelib = nullptr; UINT index; usertypeinfo->GetContainingTypeLib(&usertypelib, &index); if (usertypelib) { // get type library name - BSTR typelibname = 0; - usertypelib->GetDocumentation(-1, &typelibname, 0, 0, 0); + BSTR typelibname = nullptr; + usertypelib->GetDocumentation(-1, &typelibname, nullptr, nullptr, nullptr); QByteArray typeLibName = QString::fromWCharArray(typelibname).toLatin1(); SysFreeString(typelibname); // get type name - BSTR usertypename = 0; - usertypelib->GetDocumentation(INT(index), &usertypename, 0, 0, 0); + BSTR usertypename = nullptr; + usertypelib->GetDocumentation(INT(index), &usertypename, nullptr, nullptr, nullptr); QByteArray userTypeName = QString::fromWCharArray(usertypename).toLatin1(); SysFreeString(usertypename); @@ -1945,7 +1940,7 @@ QByteArray MetaObjectGenerator::usertypeToString(const TYPEDESC &tdesc, ITypeInf typeName = "QPixmap"; if (typeName.isEmpty()) { - TYPEATTR *typeattr = 0; + TYPEATTR *typeattr = nullptr; usertypeinfo->GetTypeAttr(&typeattr); if (typeattr) { switch(typeattr->typekind) { @@ -2160,12 +2155,12 @@ QByteArray MetaObjectGenerator::guessTypes(const TYPEDESC &tdesc, ITypeInfo *inf void MetaObjectGenerator::readClassInfo() { // Read class information - IProvideClassInfo *provideClassInfo = 0; + IProvideClassInfo *provideClassInfo = nullptr; if (d) d->ptr->QueryInterface(IID_IProvideClassInfo, reinterpret_cast<void **>(&provideClassInfo)); if (provideClassInfo) { provideClassInfo->GetClassInfo(&classInfo); - TYPEATTR *typeattr = 0; + TYPEATTR *typeattr = nullptr; if (classInfo) classInfo->GetTypeAttr(&typeattr); @@ -2186,7 +2181,7 @@ void MetaObjectGenerator::readClassInfo() classInfo->ReleaseTypeAttr(typeattr); } provideClassInfo->Release(); - provideClassInfo = 0; + provideClassInfo = nullptr; if (d->tryCache && !coClassID.isEmpty()) cacheKey = QString::fromLatin1("%1$%2$%3$%4").arg(coClassID) @@ -2259,7 +2254,7 @@ void MetaObjectGenerator::readClassInfo() break; } else { dispInfo->Release(); - dispInfo = 0; + dispInfo = nullptr; } } } @@ -2270,7 +2265,7 @@ void MetaObjectGenerator::readClassInfo() if (!d || !dispInfo || !cacheKey.isEmpty() || !d->tryCache) return; - TYPEATTR *typeattr = 0; + TYPEATTR *typeattr = nullptr; dispInfo->GetTypeAttr(&typeattr); QString interfaceID; @@ -2294,7 +2289,7 @@ void MetaObjectGenerator::readEnumInfo() QUuid libUuid; if (d && d->tryCache) { - TLIBATTR *libAttr = 0; + TLIBATTR *libAttr = nullptr; typelib->GetLibAttr(&libAttr); if (libAttr) { libUuid = QUuid(libAttr->guid); @@ -2316,7 +2311,7 @@ void MetaObjectGenerator::readEnumInfo() typelib->GetTypeInfoType(i, &typekind); if (typekind == TKIND_ENUM) { // Get the type information for the enum - ITypeInfo *enuminfo = 0; + ITypeInfo *enuminfo = nullptr; typelib->GetTypeInfo(i, &enuminfo); if (!enuminfo) continue; @@ -2324,7 +2319,7 @@ void MetaObjectGenerator::readEnumInfo() // Get the name of the enumeration BSTR enumname; QByteArray enumName; - if (typelib->GetDocumentation(INT(i), &enumname, 0, 0, 0) == S_OK) { + if (typelib->GetDocumentation(INT(i), &enumname, nullptr, nullptr, nullptr) == S_OK) { enumName = QString::fromWCharArray(enumname).toLatin1(); SysFreeString(enumname); } else { @@ -2332,12 +2327,12 @@ void MetaObjectGenerator::readEnumInfo() } // Get the attributes of the enum type - TYPEATTR *typeattr = 0; + TYPEATTR *typeattr = nullptr; enuminfo->GetTypeAttr(&typeattr); if (typeattr) { // Get all values of the enumeration for (UINT vd = 0; vd < typeattr->cVars; ++vd) { - VARDESC *vardesc = 0; + VARDESC *vardesc = nullptr; enuminfo->GetVarDesc(vd, &vardesc); if (vardesc && vardesc->varkind == VAR_CONST) { int value = vardesc->lpvarValue->lVal; @@ -2366,7 +2361,7 @@ void MetaObjectGenerator::readEnumInfo() void MetaObjectGenerator::addChangedSignal(const QByteArray &function, const QByteArray &type, int memid) { - QAxEventSink *eventSink = 0; + QAxEventSink *eventSink = nullptr; if (d) { eventSink = d->eventSink.value(iid_propNotifySink); if (!eventSink && d->useEventSink) { @@ -2409,8 +2404,7 @@ void MetaObjectGenerator::addSetterSlot(const QByteArray &property) QByteArray MetaObjectGenerator::createPrototype(FUNCDESC *funcdesc, ITypeInfo *typeinfo, const QList<QByteArray> &names, QByteArray &type, QList<QByteArray> ¶meters) { - QByteArray prototype; - QByteArray function(names.at(0)); + const QByteArray &function = names.at(0); const QByteArray hresult("HRESULT"); // get function prototype type = guessTypes(funcdesc->elemdescFunc.tdesc, typeinfo, function); @@ -2420,9 +2414,9 @@ QByteArray MetaObjectGenerator::createPrototype(FUNCDESC *funcdesc, ITypeInfo *t type = guessTypes(funcdesc->lprgelemdescParam->tdesc, typeinfo, function); } - prototype = function + '('; + QByteArray prototype = function + '('; if (funcdesc->invkind == INVOKE_FUNC && type == hresult) - type = 0; + type = nullptr; int p; for (p = 1; p < names.count(); ++p) { @@ -2479,7 +2473,7 @@ QByteArray MetaObjectGenerator::createPrototype(FUNCDESC *funcdesc, ITypeInfo *t void MetaObjectGenerator::readFuncsInfo(ITypeInfo *typeinfo, ushort nFuncs) { if (!nFuncs) { - TYPEATTR *typeattr = 0; + TYPEATTR *typeattr = nullptr; typeinfo->GetTypeAttr(&typeattr); if (typeattr) { nFuncs = typeattr->cFuncs; @@ -2489,7 +2483,7 @@ void MetaObjectGenerator::readFuncsInfo(ITypeInfo *typeinfo, ushort nFuncs) // get information about all functions for (ushort fd = 0; fd < nFuncs ; ++fd) { - FUNCDESC *funcdesc = 0; + FUNCDESC *funcdesc = nullptr; typeinfo->GetFuncDesc(fd, &funcdesc); if (!funcdesc) break; @@ -2645,7 +2639,7 @@ void MetaObjectGenerator::readFuncsInfo(ITypeInfo *typeinfo, ushort nFuncs) void MetaObjectGenerator::readVarsInfo(ITypeInfo *typeinfo, ushort nVars) { if (!nVars) { - TYPEATTR *typeattr = 0; + TYPEATTR *typeattr = nullptr; typeinfo->GetTypeAttr(&typeattr); if (typeattr) { nVars = typeattr->cVars; @@ -2764,19 +2758,19 @@ void MetaObjectGenerator::readInterfaceInfo() if (!nImpl) { typeinfo->Release(); - typeinfo = 0; + typeinfo = nullptr; break; } // go up one base class HREFTYPE pRefType; typeinfo->GetRefTypeOfImplType(0, &pRefType); - ITypeInfo *baseInfo = 0; + ITypeInfo *baseInfo = nullptr; typeinfo->GetRefTypeInfo(pRefType, &baseInfo); typeinfo->Release(); if (typeinfo == baseInfo) { // IUnknown inherits IUnknown ??? baseInfo->Release(); - typeinfo = 0; + typeinfo = nullptr; break; } typeinfo = baseInfo; @@ -2794,7 +2788,7 @@ void MetaObjectGenerator::readEventInterface(ITypeInfo *eventinfo, IConnectionPo return; } - QAxEventSink *eventSink = 0; + QAxEventSink *eventSink = nullptr; if (d) { IID conniid; cpoint->GetConnectionInterface(&conniid); @@ -2856,21 +2850,21 @@ void MetaObjectGenerator::readEventInterface(ITypeInfo *eventinfo, IConnectionPo void MetaObjectGenerator::readEventInfo() { int event_serial = 0; - IConnectionPointContainer *cpoints = 0; + IConnectionPointContainer *cpoints = nullptr; if (d && d->useEventSink) d->ptr->QueryInterface(IID_IConnectionPointContainer, reinterpret_cast<void **>(&cpoints)); if (cpoints) { // Get connection point enumerator - IEnumConnectionPoints *epoints = 0; + IEnumConnectionPoints *epoints = nullptr; cpoints->EnumConnectionPoints(&epoints); if (epoints) { ULONG c = 1; - IConnectionPoint *cpoint = 0; + IConnectionPoint *cpoint = nullptr; epoints->Reset(); QList<QUuid> cpointlist; do { if (cpoint) cpoint->Release(); - cpoint = 0; + cpoint = nullptr; HRESULT hr = epoints->Next(c, &cpoint, &c); if (!c || hr != S_OK) break; @@ -2899,7 +2893,7 @@ void MetaObjectGenerator::readEventInfo() continue; } - ITypeInfo *eventinfo = 0; + ITypeInfo *eventinfo = nullptr; if (typelib) typelib->GetTypeInfoOfGuid(conniid, &eventinfo); @@ -2914,7 +2908,7 @@ void MetaObjectGenerator::readEventInfo() if (cpoint) cpoint->Release(); epoints->Release(); } else if (classInfo) { // no enumeration - search source interfaces and ask for those - TYPEATTR *typeattr = 0; + TYPEATTR *typeattr = nullptr; classInfo->GetTypeAttr(&typeattr); if (typeattr) { for (UINT i = 0; i < typeattr->cImplTypes; ++i) { @@ -2925,14 +2919,14 @@ void MetaObjectGenerator::readEventInfo() HREFTYPE reference; if (S_OK != classInfo->GetRefTypeOfImplType(i, &reference)) continue; - ITypeInfo *eventInfo = 0; + ITypeInfo *eventInfo = nullptr; classInfo->GetRefTypeInfo(reference, &eventInfo); if (!eventInfo) continue; - TYPEATTR *eventattr = 0; + TYPEATTR *eventattr = nullptr; eventInfo->GetTypeAttr(&eventattr); if (eventattr) { - IConnectionPoint *cpoint = 0; + IConnectionPoint *cpoint = nullptr; cpoints->FindConnectionPoint(eventattr->guid, &cpoint); if (cpoint) { if (eventattr->guid == IID_IPropertyNotifySink) { @@ -2964,11 +2958,11 @@ QMetaObject *MetaObjectGenerator::tryCache() if (d->metaobj) { d->cachedMetaObject = true; - IConnectionPointContainer *cpoints = 0; + IConnectionPointContainer *cpoints = nullptr; d->ptr->QueryInterface(IID_IConnectionPointContainer, reinterpret_cast<void **>(&cpoints)); if (cpoints) { for (const QUuid &iid : qAsConst(d->metaobj->connectionInterfaces)) { - IConnectionPoint *cpoint = 0; + IConnectionPoint *cpoint = nullptr; cpoints->FindConnectionPoint(iid, &cpoint); if (cpoint) { QAxEventSink *sink = new QAxEventSink(that); @@ -2986,7 +2980,7 @@ QMetaObject *MetaObjectGenerator::tryCache() return d->metaobj; } } - return 0; + return nullptr; } static int nameToBuiltinType(const QByteArray &typeName) @@ -2998,10 +2992,9 @@ static int nameToBuiltinType(const QByteArray &typeName) static uint nameToTypeInfo(const QByteArray &typeName, QMetaStringTable &strings) { int id = nameToBuiltinType(typeName); - if (id != QMetaType::UnknownType) - return uint(id); - else - return IsUnresolvedType | uint(strings.enter(typeName)); + const int result = id != QMetaType::UnknownType + ? id : (IsUnresolvedType) | strings.enter(typeName); + return uint(result); } // Returns the sum of all parameters (including return type) for the given @@ -3022,7 +3015,7 @@ QMetaObject *MetaObjectGenerator::metaObject(const QMetaObject *parentObject, co readClassInfo(); if (typelib) { BSTR bstr; - typelib->GetDocumentation(-1, &bstr, 0, 0, 0); + typelib->GetDocumentation(-1, &bstr, nullptr, nullptr, nullptr); current_typelib = QString::fromWCharArray(bstr).toLatin1(); SysFreeString(bstr); } @@ -3053,8 +3046,7 @@ QMetaObject *MetaObjectGenerator::metaObject(const QMetaObject *parentObject, co int_data_size += (signal_list.count() + slot_list.count()) * 5 + paramsDataSize; int_data_size += property_list.count() * 3; int_data_size += enum_list.count() * 5; - const EnumListMapConstIterator ecend = enum_list.end(); - for (EnumListMapConstIterator it = enum_list.begin(); it != ecend; ++it) + for (auto it = enum_list.cbegin(), end = enum_list.cend(); it != end; ++it) int_data_size += it.value().count() * 2; ++int_data_size; // eod @@ -3084,13 +3076,9 @@ QMetaObject *MetaObjectGenerator::metaObject(const QMetaObject *parentObject, co int offset = header->classInfoData; // each class info in form key\0value\0 - typedef QMap<QByteArray, QByteArray>::ConstIterator ClassInfoConstIterator; - const ClassInfoConstIterator cend = classinfo_list.end(); - for (ClassInfoConstIterator it = classinfo_list.begin(); it != cend; ++it) { - QByteArray key(it.key()); - QByteArray value(it.value()); - int_data[offset++] = uint(strings.enter(key)); - int_data[offset++] = uint(strings.enter(value)); + for (auto it = classinfo_list.cbegin(), cend = classinfo_list.cend(); it != cend; ++it) { + int_data[offset++] = uint(strings.enter(it.key())); + int_data[offset++] = uint(strings.enter(it.value())); } Q_ASSERT(offset == header->methodData); @@ -3132,11 +3120,9 @@ QMetaObject *MetaObjectGenerator::metaObject(const QMetaObject *parentObject, co Q_ASSERT(offset == header->propertyData); // each property in form name\0type\0 - typedef QMap<QByteArray, Property>::ConstIterator PropertyMapConstIterator; - const PropertyMapConstIterator pcend = property_list.end(); - for (PropertyMapConstIterator it = property_list.begin(); it != pcend; ++it) { - QByteArray name(it.key()); - QByteArray type(it.value().type); + for (auto it = property_list.cbegin(), end = property_list.cend(); it != end; ++it) { + const QByteArray &name = it.key(); + const QByteArray &type = it.value().type; Q_ASSERT(!type.isEmpty()); QByteArray realType(it.value().realType); if (!realType.isEmpty() && realType != type) @@ -3149,7 +3135,7 @@ QMetaObject *MetaObjectGenerator::metaObject(const QMetaObject *parentObject, co int value_offset = offset + enum_list.count() * 5; // each enum in form name\0 - for (EnumListMapConstIterator it = enum_list.begin(); it != ecend; ++it) { + for (auto it = enum_list.cbegin(), end = enum_list.cend(); it != end; ++it) { QByteArray name(it.key()); int count = it.value().count(); @@ -3164,12 +3150,10 @@ QMetaObject *MetaObjectGenerator::metaObject(const QMetaObject *parentObject, co Q_ASSERT(offset == header->enumeratorData + enum_list.count() * 5); // each enum value in form key\0 - for (EnumListMapConstIterator it = enum_list.begin(); it != ecend; ++it) { - const ByteArrayIntPairList::ConstIterator vcend = it.value().end(); - for (ByteArrayIntPairList::ConstIterator it2 = it.value().begin(); it2 != vcend; ++it2) { - QByteArray key((*it2).first); - int_data[offset++] = uint(strings.enter(key)); - int_data[offset++] = uint((*it2).second); + for (auto it = enum_list.cbegin(), end = enum_list.cend(); it != end; ++it) { + for (const auto &e : it.value()) { + int_data[offset++] = uint(strings.enter(e.first)); + int_data[offset++] = uint(e.second); } } Q_ASSERT(offset == int_data_size-1); @@ -3180,10 +3164,10 @@ QMetaObject *MetaObjectGenerator::metaObject(const QMetaObject *parentObject, co // put the metaobject together metaobj->d.data = int_data; - metaobj->d.extradata = 0; + metaobj->d.extradata = nullptr; metaobj->d.stringdata = reinterpret_cast<const QByteArrayData *>(string_data); - metaobj->d.static_metacall = 0; - metaobj->d.relatedMetaObjects = 0; + metaobj->d.static_metacall = nullptr; + metaobj->d.relatedMetaObjects = nullptr; metaobj->d.superdata = parentObject; if (d) @@ -3287,7 +3271,7 @@ const QMetaObject *QAxBase::metaObject() const const QMetaObject* parentObject = parentMetaObject(); if (!d->ptr && !d->initialized) { - ((QAxBase*)this)->initialize(&d->ptr); + const_cast<QAxBase*>(this)->initialize(&d->ptr); d->initialized = true; } @@ -3317,9 +3301,9 @@ void QAxBase::connectNotify() if (d->eventSink.count()) // already listening return; - IEnumConnectionPoints *epoints = 0; + IEnumConnectionPoints *epoints = nullptr; if (d->ptr && d->useEventSink) { - IConnectionPointContainer *cpoints = 0; + IConnectionPointContainer *cpoints = nullptr; d->ptr->QueryInterface(IID_IConnectionPointContainer, reinterpret_cast<void **>(&cpoints)); if (!cpoints) return; @@ -3333,8 +3317,8 @@ void QAxBase::connectNotify() UINT index; IDispatch *disp = d->dispatch(); - ITypeInfo *typeinfo = 0; - ITypeLib *typelib = 0; + ITypeInfo *typeinfo = nullptr; + ITypeLib *typelib = nullptr; if (disp) disp->GetTypeInfo(0, LOCALE_USER_DEFAULT, &typeinfo); if (typeinfo) @@ -3349,11 +3333,11 @@ void QAxBase::connectNotify() bool haveEnumInfo = false; ULONG c = 1; - IConnectionPoint *cpoint = 0; + IConnectionPoint *cpoint = nullptr; epoints->Reset(); do { if (cpoint) cpoint->Release(); - cpoint = 0; + cpoint = nullptr; epoints->Next(c, &cpoint, &c); if (!c || !cpoint) break; @@ -3366,7 +3350,7 @@ void QAxBase::connectNotify() break; // Get ITypeInfo for source-interface, and skip if not supporting IDispatch - ITypeInfo *eventinfo = 0; + ITypeInfo *eventinfo = nullptr; typelib->GetTypeInfoOfGuid(conniid, &eventinfo); if (eventinfo) { TYPEATTR *eventAttr; @@ -3385,7 +3369,7 @@ void QAxBase::connectNotify() } // always into the cache to avoid recoursion - QAxEventSink *eventSink = eventinfo ? new QAxEventSink(this) : 0; + QAxEventSink *eventSink = eventinfo ? new QAxEventSink(this) : nullptr; d->eventSink.insert(connuuid, eventSink); if (!eventinfo) @@ -3455,7 +3439,7 @@ static bool checkHRESULT(HRESULT hres, EXCEPINFO *exc, QAxBase *that, const QStr help += QString::fromLatin1(" [%1]").arg(helpContext); if (QAxEventSink::signalHasReceivers(that->qObject(), "exception(int,QString,QString,QString)")) { - void *argv[] = {0, &code, &source, &desc, &help}; + void *argv[] = {nullptr, &code, &source, &desc, &help}; QAxBase::qt_static_metacall(that, QMetaObject::InvokeMetaMethod, exceptionSignal - mo->methodOffset(), argv); printWarning = false; @@ -3514,10 +3498,10 @@ int QAxBase::internalProperty(QMetaObject::Call call, int index, void **v) if (propname == "control") { switch(call) { case QMetaObject::ReadProperty: - *(QString*)*v = control(); + *static_cast<QString*>(*v) = control(); break; case QMetaObject::WriteProperty: - setControl(*(QString*)*v); + setControl(*static_cast<const QString*>(*v)); break; case QMetaObject::ResetProperty: clear(); @@ -3557,10 +3541,10 @@ int QAxBase::internalProperty(QMetaObject::Call call, int index, void **v) { params.cArgs = 0; params.cNamedArgs = 0; - params.rgdispidNamedArgs = 0; - params.rgvarg = 0; + params.rgdispidNamedArgs = nullptr; + params.rgvarg = nullptr; - hres = Invoke(disp, dispid, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_PROPERTYGET, ¶ms, &arg, &excepinfo, 0); + hres = Invoke(disp, dispid, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_PROPERTYGET, ¶ms, &arg, &excepinfo, nullptr); // map result VARIANTARG to void* uint type = QVariant::Int; @@ -3587,12 +3571,12 @@ int QAxBase::internalProperty(QMetaObject::Call call, int index, void **v) QVariant qvar; if (prop.isEnumType()) { qvar = *reinterpret_cast<const int *>(v[0]); - proptype = 0; + proptype = nullptr; } else { int typeId = prop.userType(); if (typeId == int(QMetaType::QVariant)) { qvar = *reinterpret_cast<const QVariant *>(v[0]); - proptype = 0; + proptype = nullptr; } else { qvar = QVariant(typeId, v[0]); if (typeId < QMetaType::User) @@ -3606,7 +3590,7 @@ int QAxBase::internalProperty(QMetaObject::Call call, int index, void **v) break; } } - hres = Invoke(disp, dispid, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_PROPERTYPUT, ¶ms, 0, &excepinfo, &argerr); + hres = Invoke(disp, dispid, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_PROPERTYPUT, ¶ms, nullptr, &excepinfo, &argerr); clearVARIANT(&arg); break; @@ -3660,8 +3644,8 @@ int QAxBase::internalInvoke(QMetaObject::Call call, int index, void **v) DISPID dispidNamed = DISPID_PROPERTYPUT; params.cArgs = UINT(d->metaobj->numParameter(signature)); params.cNamedArgs = isProperty ? 1 : 0; - params.rgdispidNamedArgs = isProperty ? &dispidNamed : 0; - params.rgvarg = 0; + params.rgdispidNamedArgs = isProperty ? &dispidNamed : nullptr; + params.rgvarg = nullptr; VARIANTARG static_rgvarg[QAX_NUM_PARAMS]; if (params.cArgs) { if (params.cArgs <= QAX_NUM_PARAMS) @@ -3747,7 +3731,7 @@ int QAxBase::internalInvoke(QMetaObject::Call call, int index, void **v) */ int QAxBase::qt_static_metacall(QAxBase *_t, QMetaObject::Call _c, int _id, void **_a) { - Q_ASSERT(_t != 0); + Q_ASSERT(_t != nullptr); if (_c == QMetaObject::InvokeMetaMethod) { const QMetaObject *mo = _t->metaObject(); switch (mo->method(_id + mo->methodOffset()).methodType()) { @@ -3858,7 +3842,7 @@ bool QAxBase::dynamicCallHelper(const char *name, void *inout, QList<QVariant> & QByteArray normFunction = QMetaObject::normalizedSignature(name); QByteArray function(normFunction); VARIANT staticarg[QAX_NUM_PARAMS]; - VARIANT *arg = 0; + VARIANT *arg = nullptr; VARIANTARG *res = reinterpret_cast<VARIANTARG *>(inout); unsigned short disptype; @@ -3974,7 +3958,7 @@ bool QAxBase::dynamicCallHelper(const char *name, void *inout, QList<QVariant> & type = prop.typeName(); } if (varc == 1) { - res = 0; + res = nullptr; disptype = DISPATCH_PROPERTYPUT; } else { disptype = DISPATCH_PROPERTYGET; @@ -3986,14 +3970,14 @@ bool QAxBase::dynamicCallHelper(const char *name, void *inout, QList<QVariant> & arg = varc <= QAX_NUM_PARAMS ? staticarg : new VARIANT[varc]; outArgs = QBitArray(varc); for (int i = 0; i < varc; ++i) { - QVariant var(vars.at(i)); + const QVariant &var = vars.at(i); VariantInit(arg + (varc - i - 1)); bool out = false; QByteArray paramType; if (disptype == DISPATCH_PROPERTYPUT) paramType = type; else if (parse || disptype == DISPATCH_PROPERTYGET) - paramType = 0; + paramType = nullptr; else paramType = d->metaobj->paramType(normFunction, i, &out); @@ -4030,7 +4014,7 @@ bool QAxBase::dynamicCallHelper(const char *name, void *inout, QList<QVariant> & params.cArgs = UINT(varc); params.cNamedArgs = (disptype == DISPATCH_PROPERTYPUT) ? 1 : 0; - params.rgdispidNamedArgs = (disptype == DISPATCH_PROPERTYPUT) ? &dispidNamed : 0; + params.rgdispidNamedArgs = (disptype == DISPATCH_PROPERTYPUT) ? &dispidNamed : nullptr; params.rgvarg = arg; EXCEPINFO excepinfo; memset(&excepinfo, 0, sizeof(excepinfo)); @@ -4240,13 +4224,13 @@ QAxObject *QAxBase::querySubObject(const char *name, */ QAxObject *QAxBase::querySubObject(const char *name, QList<QVariant> &vars) { - QAxObject *object = 0; + QAxObject *object = nullptr; VARIANTARG res; VariantInit(&res); QByteArray rettype; if (!dynamicCallHelper(name, &res, vars, rettype)) - return 0; + return nullptr; switch (res.vt) { case VT_DISPATCH: @@ -4255,12 +4239,12 @@ QAxObject *QAxBase::querySubObject(const char *name, QList<QVariant> &vars) object = new QAxObject(res.pdispVal, qObject()); } else if (QMetaType::type(rettype)) { QVariant qvar = VARIANTToQVariant(res, rettype, 0); - object = *(QAxObject**)qvar.constData(); + object = *static_cast<QAxObject**>(qvar.data()); // qVariantGet(qvar, object, rettype); res.pdispVal->AddRef(); } if (object) - ((QAxBase*)object)->d->tryCache = true; + static_cast<QAxBase*>(object)->d->tryCache = true; } break; case VT_UNKNOWN: @@ -4269,12 +4253,12 @@ QAxObject *QAxBase::querySubObject(const char *name, QList<QVariant> &vars) object = new QAxObject(res.punkVal, qObject()); } else if (QMetaType::type(rettype)) { QVariant qvar = VARIANTToQVariant(res, rettype, 0); - object = *(QAxObject**)qvar.constData(); + object = *static_cast<QAxObject**>(qvar.data()); // qVariantGet(qvar, object, rettype); res.punkVal->AddRef(); } if (object) - ((QAxBase*)object)->d->tryCache = true; + static_cast<QAxBase*>(object)->d->tryCache = true; } break; case VT_EMPTY: @@ -4303,14 +4287,14 @@ QAxObject *QAxBase::querySubObject(const char *name, QList<QVariant> &vars) class QtPropertyBag : public IPropertyBag { - Q_DISABLE_COPY(QtPropertyBag) + Q_DISABLE_COPY_MOVE(QtPropertyBag) public: - QtPropertyBag() :ref(0) {} + QtPropertyBag() = default; virtual ~QtPropertyBag() = default; HRESULT __stdcall QueryInterface(REFIID iid, LPVOID *iface) override { - *iface = 0; + *iface = nullptr; if (iid == IID_IUnknown) *iface = this; else if (iid == IID_IPropertyBag) @@ -4349,7 +4333,7 @@ public: if (!var) return E_POINTER; QString property = QString::fromWCharArray(name); - QVariant qvar = VARIANTToQVariant(*var, 0); + QVariant qvar = VARIANTToQVariant(*var, nullptr); map[property] = qvar; return S_OK; @@ -4358,7 +4342,7 @@ public: QAxBase::PropertyBag map; private: - LONG ref; + LONG ref = 0; }; /*! @@ -4384,7 +4368,7 @@ QAxBase::PropertyBag QAxBase::propertyBag() const if (isNull()) return result; - IPersistPropertyBag *persist = 0; + IPersistPropertyBag *persist = nullptr; d->ptr->QueryInterface(IID_IPersistPropertyBag, reinterpret_cast<void **>(&persist)); if (persist) { QtPropertyBag *pbag = new QtPropertyBag(); @@ -4425,13 +4409,13 @@ void QAxBase::setPropertyBag(const PropertyBag &bag) if (isNull()) return; - IPersistPropertyBag *persist = 0; + IPersistPropertyBag *persist = nullptr; d->ptr->QueryInterface(IID_IPersistPropertyBag, reinterpret_cast<void **>(&persist)); if (persist) { QtPropertyBag *pbag = new QtPropertyBag(); pbag->map = bag; pbag->AddRef(); - persist->Load(pbag, 0); + persist->Load(pbag, nullptr); pbag->Release(); persist->Release(); } else { @@ -4522,9 +4506,9 @@ QVariant QAxBase::asVariant() const void *qax_createObjectWrapper(int metaType, IUnknown *iface) { if (!iface) - return 0; + return nullptr; - void *object = QMetaType::create(metaType, 0); + void *object = QMetaType::create(metaType, nullptr); QAxBasePrivate *d = reinterpret_cast<const QAxObject *>(object)->d; d->ptr = iface; diff --git a/src/activeqt/container/qaxbase.h b/src/activeqt/container/qaxbase.h index 740fd6d..38dec7e 100644 --- a/src/activeqt/container/qaxbase.h +++ b/src/activeqt/container/qaxbase.h @@ -72,7 +72,7 @@ class QAxBase QDOC_PROPERTY(QString control READ control WRITE setControl) public: - typedef QMap<QString, QVariant> PropertyBag; + using PropertyBag = QMap<QString, QVariant>; explicit QAxBase(IUnknown *iface = nullptr); virtual ~QAxBase(); diff --git a/src/activeqt/container/qaxdump.cpp b/src/activeqt/container/qaxdump.cpp index 80133d7..e2122c3 100644 --- a/src/activeqt/container/qaxdump.cpp +++ b/src/activeqt/container/qaxdump.cpp @@ -74,7 +74,7 @@ QString qax_docuFromName(ITypeInfo *typeInfo, const QString &name) if (memId != DISPID_UNKNOWN) { BSTR docStringBstr, helpFileBstr; ulong helpContext; - HRESULT hres = typeInfo->GetDocumentation(memId, 0, &docStringBstr, &helpContext, &helpFileBstr); + HRESULT hres = typeInfo->GetDocumentation(memId, nullptr, &docStringBstr, &helpContext, &helpFileBstr); QString docString = QString::fromWCharArray(docStringBstr); QString helpFile = QString::fromWCharArray(helpFileBstr); SysFreeString(docStringBstr); @@ -142,8 +142,8 @@ QString qax_generateDocumentation(QAxBase *that) if (that->isNull()) return QString(); - ITypeInfo *typeInfo = 0; - IDispatch *dispatch = 0; + ITypeInfo *typeInfo = nullptr; + IDispatch *dispatch = nullptr; that->queryInterface(IID_IDispatch, reinterpret_cast<void **>(&dispatch)); if (dispatch) dispatch->GetTypeInfo(0, LOCALE_SYSTEM_DEFAULT, &typeInfo); @@ -160,7 +160,7 @@ QString qax_generateDocumentation(QAxBase *that) stream << "<h3>Interfaces</h3>" << endl; stream << "<ul>" << endl; - const char *inter = 0; + const char *inter = nullptr; UINT interCount = 1; while ((inter = mo->classInfo(mo->indexOfClassInfo("Interface " + QByteArray::number(interCount))).value())) { stream << "<li>" << inter << endl; @@ -246,13 +246,13 @@ QString qax_generateDocumentation(QAxBase *that) } int signalCount = mo->methodCount(); if (signalCount) { - ITypeLib *typeLib = 0; + ITypeLib *typeLib = nullptr; if (typeInfo) { UINT index = 0; typeInfo->GetContainingTypeLib(&typeLib, &index); typeInfo->Release(); } - typeInfo = 0; + typeInfo = nullptr; stream << "<h2>Signals:</h2>" << endl; stream << "<ul>" << endl; @@ -275,7 +275,7 @@ QString qax_generateDocumentation(QAxBase *that) do { if (typeInfo) typeInfo->Release(); - typeInfo = 0; + typeInfo = nullptr; typeLib->GetTypeInfo(++interCount, &typeInfo); QString typeLibDocu = docuFromName(typeInfo, QString::fromLatin1(name.constData())); if (!typeLibDocu.isEmpty()) { @@ -294,7 +294,7 @@ QString qax_generateDocumentation(QAxBase *that) methodDetails << detail; if (typeInfo) typeInfo->Release(); - typeInfo = 0; + typeInfo = nullptr; } stream << "</ul>" << endl; diff --git a/src/activeqt/container/qaxobject.cpp b/src/activeqt/container/qaxobject.cpp index 6389956..97a995d 100644 --- a/src/activeqt/container/qaxobject.cpp +++ b/src/activeqt/container/qaxobject.cpp @@ -92,7 +92,7 @@ QT_BEGIN_NAMESPACE const QMetaObject QAxObject::staticMetaObject = { { &QObject::staticMetaObject, qt_meta_stringdata_QAxBase.data, - qt_meta_data_QAxBase, qt_static_metacall, 0, 0 } + qt_meta_data_QAxBase, qt_static_metacall, nullptr, nullptr } }; /*! @@ -221,14 +221,14 @@ bool QAxObject::doVerb(const QString &verb) { if (!verbs().contains(verb)) return false; - IOleObject *ole = 0; + IOleObject *ole = nullptr; queryInterface(IID_IOleObject, reinterpret_cast<void **>(&ole)); if (!ole) return false; LONG index = indexOfVerb(verb); - HRESULT hres = ole->DoVerb(index, 0, 0, 0, 0, 0); + HRESULT hres = ole->DoVerb(index, nullptr, nullptr, 0, nullptr, nullptr); ole->Release(); diff --git a/src/activeqt/container/qaxscript.cpp b/src/activeqt/container/qaxscript.cpp index 0f0aa08..5179204 100644 --- a/src/activeqt/container/qaxscript.cpp +++ b/src/activeqt/container/qaxscript.cpp @@ -97,7 +97,7 @@ public: class QAxScriptSite : public IActiveScriptSite, public IActiveScriptSiteWindow { - Q_DISABLE_COPY(QAxScriptSite) + Q_DISABLE_COPY_MOVE(QAxScriptSite) public: QAxScriptSite(QAxScript *script); virtual ~QAxScriptSite() = default; @@ -125,14 +125,13 @@ protected: private: QAxScript *script; - LONG ref; + LONG ref = 1; }; /* Constructs the site for the \a s. */ -QAxScriptSite::QAxScriptSite(QAxScript *s) -: script(s), ref(1) +QAxScriptSite::QAxScriptSite(QAxScript *s) : script(s) { } @@ -161,7 +160,7 @@ ULONG WINAPI QAxScriptSite::Release() */ HRESULT WINAPI QAxScriptSite::QueryInterface(REFIID iid, void **ppvObject) { - *ppvObject = 0; + *ppvObject = nullptr; if (iid == IID_IUnknown) *ppvObject = static_cast<IUnknown *>(static_cast<IActiveScriptSite *>(this)); else if (iid == IID_IActiveScriptSite) @@ -194,12 +193,12 @@ HRESULT WINAPI QAxScriptSite::GetLCID(LCID * /*plcid*/) HRESULT WINAPI QAxScriptSite::GetItemInfo(LPCOLESTR pstrName, DWORD mask, IUnknown **item, ITypeInfo **type) { if (item) - *item = 0; + *item = nullptr; else if (mask & SCRIPTINFO_IUNKNOWN) return E_POINTER; if (type) - *type = 0; + *type = nullptr; else if (mask & SCRIPTINFO_ITYPEINFO) return E_POINTER; @@ -210,7 +209,7 @@ HRESULT WINAPI QAxScriptSite::GetItemInfo(LPCOLESTR pstrName, DWORD mask, IUnkno if (mask & SCRIPTINFO_IUNKNOWN) object->queryInterface(IID_IUnknown, reinterpret_cast<void **>(item)); if (mask & SCRIPTINFO_ITYPEINFO) { - IProvideClassInfo *classInfo = 0; + IProvideClassInfo *classInfo = nullptr; object->queryInterface(IID_IProvideClassInfo, reinterpret_cast<void **>(&classInfo)); if (classInfo) { classInfo->GetClassInfo(type); @@ -242,7 +241,7 @@ HRESULT WINAPI QAxScriptSite::OnScriptTerminate(const VARIANT *result, const EXC emit script->finished(); if (result && result->vt != VT_EMPTY) - emit script->finished(VARIANTToQVariant(*result, 0)); + emit script->finished(VARIANTToQVariant(*result, nullptr)); if (exception) emit script->finished(exception->wCode, QString::fromWCharArray(exception->bstrSource), @@ -328,7 +327,7 @@ HRESULT WINAPI QAxScriptSite::OnStateChange(SCRIPTSTATE ssScriptState) */ QWidget *QAxScriptSite::window() const { - QWidget *w = 0; + QWidget *w = nullptr; QObject *p = script->parent(); while (!w && p) { w = qobject_cast<QWidget*>(p); @@ -354,7 +353,7 @@ HRESULT WINAPI QAxScriptSite::GetWindow(HWND *phwnd) if (!phwnd) return E_POINTER; - *phwnd = 0; + *phwnd = nullptr; QWidget *w = window(); if (!w) return E_FAIL; @@ -429,7 +428,7 @@ HRESULT WINAPI QAxScriptSite::EnableModeless(BOOL fEnable) script. */ QAxScriptEngine::QAxScriptEngine(const QString &language, QAxScript *script) -: QAxObject(script), script_code(script), engine(0), script_language(language) +: QAxObject(script), script_code(script), engine(nullptr), script_language(language) { #ifdef QT_CHECK_STATE if (language.isEmpty()) @@ -471,7 +470,7 @@ QAxScriptEngine::~QAxScriptEngine() */ bool QAxScriptEngine::initialize(IUnknown **ptr) { - *ptr = 0; + *ptr = nullptr; #ifndef QT_NO_QAXSCRIPT if (!script_code || script_language.isEmpty()) @@ -482,57 +481,57 @@ bool QAxScriptEngine::initialize(IUnknown **ptr) if(FAILED(hres)) return false; - CoCreateInstance(clsid, 0, CLSCTX_INPROC_SERVER, IID_IActiveScript, reinterpret_cast<void **>(&engine)); + CoCreateInstance(clsid, nullptr, CLSCTX_INPROC_SERVER, IID_IActiveScript, reinterpret_cast<void **>(&engine)); if (!engine) return false; - IActiveScriptParse *parser = 0; + IActiveScriptParse *parser = nullptr; engine->QueryInterface(IID_IActiveScriptParse, reinterpret_cast<void **>(&parser)); if (!parser) { engine->Release(); - engine = 0; + engine = nullptr; return false; } if (engine->SetScriptSite(script_code->script_site) != S_OK) { engine->Release(); - engine = 0; + engine = nullptr; return false; } if (parser->InitNew() != S_OK) { parser->Release(); engine->Release(); - engine = 0; + engine = nullptr; return false; } BSTR bstrCode = QStringToBSTR(script_code->scriptCode()); #ifdef Q_OS_WIN64 - hres = parser->ParseScriptText(bstrCode, 0, 0, 0, DWORDLONG(this), 0, SCRIPTTEXT_ISVISIBLE, 0, 0); + hres = parser->ParseScriptText(bstrCode, nullptr, nullptr, nullptr, DWORDLONG(this), 0, SCRIPTTEXT_ISVISIBLE, nullptr, nullptr); #else hres = parser->ParseScriptText(bstrCode, 0, 0, 0, DWORD(this), 0, SCRIPTTEXT_ISVISIBLE, 0, 0); #endif SysFreeString(bstrCode); parser->Release(); - parser = 0; + parser = nullptr; script_code->updateObjects(); if (engine->SetScriptState(SCRIPTSTATE_CONNECTED) != S_OK) { - engine = 0; + engine = nullptr; return false; } - IDispatch *scriptDispatch = 0; - engine->GetScriptDispatch(0, &scriptDispatch); + IDispatch *scriptDispatch = nullptr; + engine->GetScriptDispatch(nullptr, &scriptDispatch); if (scriptDispatch) { scriptDispatch->QueryInterface(IID_IUnknown, reinterpret_cast<void **>(ptr)); scriptDispatch->Release(); } #endif - return *ptr != 0; + return *ptr != nullptr; } /*! @@ -552,7 +551,7 @@ bool QAxScriptEngine::hasIntrospection() const if (!isValid()) return false; - IDispatch *scriptDispatch = 0; + IDispatch *scriptDispatch = nullptr; QAxBase::queryInterface(IID_IDispatch, reinterpret_cast<void **>(&scriptDispatch)); if (!scriptDispatch) return false; @@ -574,7 +573,7 @@ bool QAxScriptEngine::hasIntrospection() const */ long QAxScriptEngine::queryInterface(const QUuid &uuid, void **iface) const { - *iface = 0; + *iface = nullptr; if (!engine) return E_NOTIMPL; @@ -683,7 +682,7 @@ void QAxScriptEngine::addItem(const QString &name) */ QAxScript::QAxScript(const QString &name, QAxScriptManager *manager) : QObject(manager), script_name(name), script_manager(manager), -script_engine(0) +script_engine(nullptr) { if (manager) { manager->d->scriptDict.insert(name, this); @@ -706,7 +705,7 @@ script_engine(0) QAxScript::~QAxScript() { delete script_engine; - script_engine = 0; + script_engine = nullptr; #ifndef QT_NO_QAXSCRIPT script_site->Release(); @@ -850,7 +849,7 @@ void QAxScript::updateObjects() QAxBase *QAxScript::findObject(const QString &name) { if (!script_manager) - return 0; + return nullptr; return script_manager->d->objectDict.value(name); } @@ -1067,7 +1066,7 @@ QAxScript *QAxScriptManager::load(const QString &code, const QString &name, cons return script; delete script; - return 0; + return nullptr; } /*! @@ -1090,13 +1089,13 @@ QAxScript *QAxScriptManager::load(const QString &file, const QString &name) { QFile f(file); if (!f.open(QIODevice::ReadOnly)) - return 0; + return nullptr; QByteArray data = f.readAll(); QString contents = QString::fromLocal8Bit(data, data.size()); f.close(); if (contents.isEmpty()) - return 0; + return nullptr; QString language; if (file.endsWith(QLatin1String(".js"))) { @@ -1118,7 +1117,7 @@ QAxScript *QAxScriptManager::load(const QString &file, const QString &name) return script; delete script; - return 0; + return nullptr; } /*! @@ -1283,7 +1282,7 @@ QAxScript *QAxScriptManager::scriptForFunction(const QString &function) const return it.value(); } - return 0; + return nullptr; } /*! diff --git a/src/activeqt/container/qaxscriptwrapper.cpp b/src/activeqt/container/qaxscriptwrapper.cpp index 418eff1..31a082f 100644 --- a/src/activeqt/container/qaxscriptwrapper.cpp +++ b/src/activeqt/container/qaxscriptwrapper.cpp @@ -58,8 +58,8 @@ QT_BEGIN_NAMESPACE QAxBase *qax_create_object_wrapper(QObject *object) { - IDispatch *dispatch = 0; - QAxObject *wrapper = 0; + IDispatch *dispatch = nullptr; + QAxObject *wrapper = nullptr; qAxFactory()->createObjectWrapper(object, &dispatch); if (dispatch) { wrapper = new QAxObject(dispatch, object); diff --git a/src/activeqt/container/qaxselect.cpp b/src/activeqt/container/qaxselect.cpp index 2f0f2aa..1caae35 100644 --- a/src/activeqt/container/qaxselect.cpp +++ b/src/activeqt/container/qaxselect.cpp @@ -187,10 +187,10 @@ inline bool operator==(const Control &c1, const Control &c2) { return !c1.compar static LONG RegistryQueryValue(HKEY hKey, LPCWSTR lpSubKey, LPBYTE lpData, LPDWORD lpcbData) { LONG ret = ERROR_FILE_NOT_FOUND; - HKEY hSubKey = NULL; + HKEY hSubKey = nullptr; RegOpenKeyEx(hKey, lpSubKey, 0, KEY_READ, &hSubKey); if (hSubKey) { - ret = RegQueryValueEx(hSubKey, 0, 0, 0, lpData, lpcbData); + ret = RegQueryValueEx(hSubKey, nullptr, nullptr, nullptr, lpData, lpcbData); RegCloseKey(hSubKey); } return ret; @@ -198,12 +198,12 @@ static LONG RegistryQueryValue(HKEY hKey, LPCWSTR lpSubKey, LPBYTE lpData, LPDWO static bool querySubKeyValue(HKEY hKey, const QString &subKeyName, LPBYTE lpData, LPDWORD lpcbData) { - HKEY hSubKey = NULL; + HKEY hSubKey = nullptr; const LONG openResult = RegOpenKeyEx(hKey, reinterpret_cast<const wchar_t *>(subKeyName.utf16()), 0, KEY_READ, &hSubKey); if (openResult != ERROR_SUCCESS) return false; - const bool result = RegQueryValueEx(hSubKey, 0, 0, 0, lpData, lpcbData) == ERROR_SUCCESS; + const bool result = RegQueryValueEx(hSubKey, nullptr, nullptr, nullptr, lpData, lpcbData) == ERROR_SUCCESS; RegCloseKey(hSubKey); return result; } @@ -225,7 +225,7 @@ static QList<Control> readControls(const wchar_t *rootKey, unsigned wordSize) FILETIME ft; do { szBuffer = sizeof(buffer) / sizeof(wchar_t); - result = RegEnumKeyEx(classesKey, index, buffer, &szBuffer, 0, 0, 0, &ft); + result = RegEnumKeyEx(classesKey, index, buffer, &szBuffer, nullptr, nullptr, nullptr, &ft); szBuffer = sizeof(buffer) / sizeof(wchar_t); if (result == ERROR_SUCCESS) { HKEY subKey; @@ -268,7 +268,7 @@ static QList<Control> readControls(const wchar_t *rootKey, unsigned wordSize) class ControlList : public QAbstractListModel { public: - ControlList(QObject *parent=0) + ControlList(QObject *parent=nullptr) : QAbstractListModel(parent) { m_controls = readControls(L"CLSID", unsigned(QSysInfo::WordSize)); @@ -415,13 +415,15 @@ QString QAxSelect::clsid() const */ QAxSelect::SandboxingLevel QAxSelect::sandboxingLevel() const { - int idx = d->selectUi.SandboxingCombo->currentIndex(); - if (idx == 1) + switch (d->selectUi.SandboxingCombo->currentIndex()) { + case 1: return SandboxingProcess; - else if (idx == 2) + case 2: return SandboxingLowIntegrity; - else - return SandboxingNone; + default: + break; + } + return SandboxingNone; } void QAxSelect::onActiveXListCurrentChanged(const QModelIndex &index) diff --git a/src/activeqt/container/qaxwidget.cpp b/src/activeqt/container/qaxwidget.cpp index a28c64f..6185b89 100644 --- a/src/activeqt/container/qaxwidget.cpp +++ b/src/activeqt/container/qaxwidget.cpp @@ -115,7 +115,7 @@ QT_BEGIN_NAMESPACE */ class QAxHostWidget : public QWidget { - Q_DISABLE_COPY(QAxHostWidget) + Q_DISABLE_COPY_MOVE(QAxHostWidget) friend class QAxClientSite; public: Q_OBJECT_CHECK @@ -136,7 +136,11 @@ public: QWindow *hostWindow() const; protected: +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + bool nativeEvent(const QByteArray &eventType, void *message, qintptr *result) override; +#else bool nativeEvent(const QByteArray &eventType, void *message, long *result) override; +#endif bool event(QEvent *e) override; bool eventFilter(QObject *o, QEvent *e) override; void resizeEvent(QResizeEvent *e) override; @@ -146,7 +150,7 @@ protected: void showEvent(QShowEvent *e) override; QPaintEngine *paintEngine() const override { - return 0; + return nullptr; } private: @@ -174,7 +178,7 @@ class QAxClientSite : public IDispatch, public IOleDocumentSite, public IAdviseSink { - Q_DISABLE_COPY(QAxClientSite) + Q_DISABLE_COPY_MOVE(QAxClientSite) friend class QAxHostWidget; public: QAxClientSite(QAxWidget *c); @@ -187,9 +191,9 @@ public: inline void reset(QWidget *p) { if (widget == p) - widget = 0; + widget = nullptr; else if (host == p) - host = 0; + host = nullptr; } inline IOleInPlaceActiveObject *inPlaceObject() const @@ -205,7 +209,7 @@ public: return OLE_E_NOT_INPLACEACTIVE; RECT rcPos = qaxNativeWidgetRect(host); - return m_spOleObject->DoVerb(index, 0, this, 0, + return m_spOleObject->DoVerb(index, nullptr, this, 0, reinterpret_cast<HWND>(host->winId()), &rcPos); } @@ -394,37 +398,37 @@ public: private: struct OleMenuItem { - OleMenuItem(HMENU hm = 0, int ID = 0, QMenu *menu = 0) + OleMenuItem(HMENU hm = nullptr, int ID = 0, QMenu *menu = nullptr) : hMenu(hm), subMenu(menu), id(ID) {} HMENU hMenu; QMenu *subMenu; int id; }; - typedef QMap<QAction*, OleMenuItem> MenuItemMap; + using MenuItemMap = QMap<QAction*, OleMenuItem>; QMenu *generatePopup(HMENU subMenu, QWidget *parent); - IOleObject *m_spOleObject; - IOleControl *m_spOleControl; - IOleInPlaceObjectWindowless *m_spInPlaceObject; - IOleInPlaceActiveObject *m_spInPlaceActiveObject; - IOleDocumentView *m_spActiveView; + IOleObject *m_spOleObject = nullptr; + IOleControl *m_spOleControl = nullptr; + IOleInPlaceObjectWindowless *m_spInPlaceObject = nullptr; + IOleInPlaceActiveObject *m_spInPlaceActiveObject = nullptr; + IOleDocumentView *m_spActiveView = nullptr; - QAxAggregated *aggregatedObject; + QAxAggregated *aggregatedObject = nullptr; bool inPlaceObjectWindowless :1; bool inPlaceModelessEnabled :1; bool canHostDocument : 1; - DWORD m_dwOleObject; - HWND m_menuOwner; + DWORD m_dwOleObject = 0; + HWND m_menuOwner = nullptr; CONTROLINFO control_info; QSize sizehint; - LONG ref; + LONG ref = 1; QAxWidget *widget; - QAxHostWidget *host; + QAxHostWidget *host = nullptr; QPointer<QMenuBar> menuBar; MenuItemMap menuItemMap; }; @@ -445,7 +449,7 @@ static const ushort mouseTbl[] = { static Qt::MouseButtons translateMouseButtonState(int s) { - Qt::MouseButtons bst = 0; + Qt::MouseButtons bst = nullptr; if (s & MK_LBUTTON) bst |= Qt::LeftButton; if (s & MK_MBUTTON) @@ -458,7 +462,7 @@ static Qt::MouseButtons translateMouseButtonState(int s) static Qt::KeyboardModifiers translateModifierState(int s) { - Qt::KeyboardModifiers bst = 0; + Qt::KeyboardModifiers bst = nullptr; if (s & MK_SHIFT) bst |= Qt::ShiftModifier; if (s & MK_CONTROL) @@ -475,11 +479,19 @@ static const wchar_t *qaxatom = L"QAxContainer4_Atom"; class QAxNativeEventFilter : public QAbstractNativeEventFilter { public: +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + bool nativeEventFilter(const QByteArray &eventType, void *message, qintptr *) override; +#else bool nativeEventFilter(const QByteArray &eventType, void *message, long *) override; +#endif }; Q_GLOBAL_STATIC(QAxNativeEventFilter, s_nativeEventFilter) +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) +bool QAxNativeEventFilter::nativeEventFilter(const QByteArray &, void *m, qintptr *) +#else bool QAxNativeEventFilter::nativeEventFilter(const QByteArray &, void *m, long *) +#endif { MSG *msg = static_cast<MSG *>(m); const uint message = msg->message; @@ -487,8 +499,8 @@ bool QAxNativeEventFilter::nativeEventFilter(const QByteArray &, void *m, long * qaxClearCachedSystemLogicalDpi(); if ((message >= WM_MOUSEFIRST && message <= WM_MOUSELAST) || (message >= WM_KEYFIRST && message <= WM_KEYLAST)) { HWND hwnd = msg->hwnd; - QAxWidget *ax = 0; - QAxHostWidget *host = 0; + QAxWidget *ax = nullptr; + QAxHostWidget *host = nullptr; while (!host && hwnd) { // FIXME: 4.10.2011: Does this still work? QWidget *widget = QWidget::find(reinterpret_cast<WId>(hwnd)); @@ -511,7 +523,7 @@ bool QAxNativeEventFilter::nativeEventFilter(const QByteArray &, void *m, long * return true; } else { int i; - for (i = 0; (UINT)mouseTbl[i] != message && mouseTbl[i]; i += 3) + for (i = 0; UINT(mouseTbl[i]) != message && mouseTbl[i]; i += 3) ; if (mouseTbl[i]) { @@ -540,7 +552,7 @@ bool QAxNativeEventFilter::nativeEventFilter(const QByteArray &, void *m, long * } QAxClientSite::QAxClientSite(QAxWidget *c) -: eventTranslated(true), ref(1), widget(c), host(0) +: eventTranslated(true), widget(c) { aggregatedObject = widget->createAggregate(); if (aggregatedObject) { @@ -548,19 +560,10 @@ QAxClientSite::QAxClientSite(QAxWidget *c) aggregatedObject->the_object = c; } - m_spOleObject = 0; - m_spOleControl = 0; - m_spInPlaceObject = 0; - m_spInPlaceActiveObject = 0; - m_spActiveView = 0; - inPlaceObjectWindowless = false; inPlaceModelessEnabled = true; canHostDocument = false; - m_dwOleObject = 0; - m_menuOwner = 0; - menuBar = 0; memset(&control_info, 0, sizeof(control_info)); } @@ -571,21 +574,21 @@ bool QAxClientSite::activateObject(bool initialized, const QByteArray &data) bool showHost = false; if (!m_spOleObject) - widget->queryInterface(IID_IOleObject, (void**)&m_spOleObject); + widget->queryInterface(IID_IOleObject, reinterpret_cast<void**>(&m_spOleObject)); if (m_spOleObject) { DWORD dwMiscStatus = 0; m_spOleObject->GetMiscStatus(DVASPECT_CONTENT, &dwMiscStatus); - IOleDocument *document = 0; - m_spOleObject->QueryInterface(IID_IOleDocument, (void**)&document); + IOleDocument *document = nullptr; + m_spOleObject->QueryInterface(IID_IOleDocument, reinterpret_cast<void**>(&document)); if (document) { - IPersistStorage *persistStorage = 0; - document->QueryInterface(IID_IPersistStorage, (void**)&persistStorage); + IPersistStorage *persistStorage = nullptr; + document->QueryInterface(IID_IPersistStorage, reinterpret_cast<void**>(&persistStorage)); if (persistStorage) { // try to activate as document server - IStorage *storage = 0; - ILockBytes * bytes = 0; - ::CreateILockBytesOnHGlobal(0, TRUE, &bytes); + IStorage *storage = nullptr; + ILockBytes * bytes = nullptr; + ::CreateILockBytesOnHGlobal(nullptr, TRUE, &bytes); ::StgCreateDocfileOnILockBytes(bytes, STGM_SHARE_EXCLUSIVE|STGM_CREATE|STGM_READWRITE, 0, &storage); persistStorage->InitNew(storage); @@ -606,15 +609,14 @@ bool QAxClientSite::activateObject(bool initialized, const QByteArray &data) m_spOleObject->SetClientSite(this); if (!initialized) { - IPersistStreamInit *spPSI = 0; - m_spOleObject->QueryInterface(IID_IPersistStreamInit, (void**)&spPSI); + IPersistStreamInit *spPSI = nullptr; + m_spOleObject->QueryInterface(IID_IPersistStreamInit, reinterpret_cast<void**>(&spPSI)); if (spPSI) { if (data.length()) { - IStream *pStream = 0; + IStream *pStream = nullptr; HGLOBAL hGlobal = GlobalAlloc(GMEM_MOVEABLE, data.length()); if (hGlobal) { - BYTE *pStByte = (BYTE *)GlobalLock(hGlobal); - if (pStByte) + if (auto pStByte = GlobalLock(hGlobal)) memcpy(pStByte, data.data(), data.length()); GlobalUnlock(hGlobal); if (SUCCEEDED(CreateStreamOnHGlobal(hGlobal, TRUE, &pStream))) { @@ -628,7 +630,7 @@ bool QAxClientSite::activateObject(bool initialized, const QByteArray &data) } spPSI->Release(); } else if (data.length()) { //try initializing using a IPersistStorage - IPersistStorage *spPS = 0; + IPersistStorage *spPS = nullptr; m_spOleObject->QueryInterface( IID_IPersistStorage, reinterpret_cast<void **>(&spPS)); if (spPS) { HGLOBAL hGlobal = GlobalAlloc(GMEM_MOVEABLE, size_t(data.length())); @@ -637,11 +639,11 @@ bool QAxClientSite::activateObject(bool initialized, const QByteArray &data) memcpy(pbData, data.data(), size_t(data.length())); GlobalUnlock(hGlobal); // open an IStorage on the data and pass it to Load - LPLOCKBYTES pLockBytes = 0; + LPLOCKBYTES pLockBytes = nullptr; if (SUCCEEDED(CreateILockBytesOnHGlobal(hGlobal, TRUE, &pLockBytes))) { - LPSTORAGE pStorage = 0; - if (SUCCEEDED(StgOpenStorageOnILockBytes(pLockBytes, 0, - STGM_READWRITE | STGM_SHARE_EXCLUSIVE, 0, 0, &pStorage))) { + LPSTORAGE pStorage = nullptr; + if (SUCCEEDED(StgOpenStorageOnILockBytes(pLockBytes, nullptr, + STGM_READWRITE | STGM_SHARE_EXCLUSIVE, nullptr, 0, &pStorage))) { spPS->Load(pStorage); pStorage->Release(); } @@ -658,11 +660,11 @@ bool QAxClientSite::activateObject(bool initialized, const QByteArray &data) m_spOleObject->SetClientSite(this); } - IViewObject *spViewObject = 0; + IViewObject *spViewObject = nullptr; m_spOleObject->QueryInterface(IID_IViewObject, reinterpret_cast<void **>(&spViewObject)); m_spOleObject->Advise(this, &m_dwOleObject); - IAdviseSink *spAdviseSink = 0; + IAdviseSink *spAdviseSink = nullptr; QueryInterface(IID_IAdviseSink, reinterpret_cast<void **>(&spAdviseSink)); if (spAdviseSink && spViewObject) { if (spViewObject) @@ -673,7 +675,7 @@ bool QAxClientSite::activateObject(bool initialized, const QByteArray &data) if (spViewObject) spViewObject->Release(); - m_spOleObject->SetHostNames(OLESTR("AXWIN"), 0); + m_spOleObject->SetHostNames(OLESTR("AXWIN"), nullptr); if (!(dwMiscStatus & OLEMISC_INVISIBLEATRUNTIME)) { SIZEL hmSize = qaxMapPixToLogHiMetrics(QSize(250, 250), widget); @@ -696,7 +698,7 @@ bool QAxClientSite::activateObject(bool initialized, const QByteArray &data) RECT rcPos = qaxQRect2Rect(QRect(qaxNativeWidgetPosition(host), qaxToNativeSize(host, sizehint))); const HWND hostWnd = reinterpret_cast<HWND>(host->winId()); - m_spOleObject->DoVerb(OLEIVERB_INPLACEACTIVATE, 0, static_cast<IOleClientSite *>(this), 0, + m_spOleObject->DoVerb(OLEIVERB_INPLACEACTIVATE, nullptr, static_cast<IOleClientSite *>(this), 0, hostWnd, &rcPos); @@ -740,7 +742,7 @@ bool QAxClientSite::activateObject(bool initialized, const QByteArray &data) CoTaskMemFree(userType); } } else { - IObjectWithSite *spSite = 0; + IObjectWithSite *spSite = nullptr; widget->queryInterface(IID_IObjectWithSite, reinterpret_cast<void **>(&spSite)); if (spSite) { spSite->SetSite(static_cast<IUnknown *>(static_cast<IDispatch *>(this))); @@ -763,11 +765,11 @@ bool QAxClientSite::activateObject(bool initialized, const QByteArray &data) QAxClientSite::~QAxClientSite() { if (host) { - host->axhost = 0; + host->axhost = nullptr; } if (aggregatedObject) - aggregatedObject->the_object = 0; + aggregatedObject->the_object = nullptr; delete aggregatedObject; delete host; } @@ -778,15 +780,15 @@ void QAxClientSite::releaseAll() m_spOleControl->Release(); m_spOleControl = nullptr; if (m_spOleObject) { - m_spOleObject->SetClientSite(0); m_spOleObject->Unadvise(m_dwOleObject); + m_spOleObject->SetClientSite(nullptr); m_spOleObject->Release(); } - m_spOleObject = 0; + m_spOleObject = nullptr; if (m_spInPlaceObject) m_spInPlaceObject->Release(); - m_spInPlaceObject = 0; + m_spInPlaceObject = nullptr; if (m_spInPlaceActiveObject) m_spInPlaceActiveObject->Release(); - m_spInPlaceActiveObject = 0; + m_spInPlaceActiveObject = nullptr; inPlaceObjectWindowless = false; } @@ -807,7 +809,7 @@ void QAxClientSite::deactivate() CoDisconnectObject(static_cast<IUnknown *>(static_cast<IDispatch *>(this)), 0); } - Q_ASSERT(m_spInPlaceObject == 0); + Q_ASSERT(m_spInPlaceObject == nullptr); } //**** IUnknown @@ -827,7 +829,7 @@ unsigned long WINAPI QAxClientSite::Release() HRESULT WINAPI QAxClientSite::QueryInterface(REFIID iid, void **iface) { - *iface = 0; + *iface = nullptr; if (iid == IID_IUnknown) { *iface = static_cast<IUnknown *>(static_cast<IDispatch *>(this)); @@ -957,7 +959,7 @@ HRESULT WINAPI QAxClientSite::GetMoniker(DWORD, DWORD, IMoniker **ppmk) if (!ppmk) return E_POINTER; - *ppmk = 0; + *ppmk = nullptr; return E_NOTIMPL; } @@ -966,7 +968,7 @@ HRESULT WINAPI QAxClientSite::GetContainer(LPOLECONTAINER *ppContainer) if (!ppContainer) return E_POINTER; - *ppContainer = 0; + *ppContainer = nullptr; return E_NOINTERFACE; } @@ -1005,7 +1007,7 @@ HRESULT WINAPI QAxClientSite::GetExtendedControl(IDispatch** ppDisp) if (!ppDisp) return E_POINTER; - *ppDisp = 0; + *ppDisp = nullptr; return E_NOTIMPL; } @@ -1134,10 +1136,10 @@ HRESULT WINAPI QAxClientSite::GetWindowContext(IOleInPlaceFrame **ppFrame, IOleI lpFrameInfo->cb = sizeof(OLEINPLACEFRAMEINFO); lpFrameInfo->fMDIApp = false; - lpFrameInfo->haccel = 0; + lpFrameInfo->haccel = nullptr; lpFrameInfo->cAccelEntries = 0; // FIXME: 4.10.2011: Parent's HWND required, should work. - lpFrameInfo->hwndFrame = widget ? hwnd : 0; + lpFrameInfo->hwndFrame = widget ? hwnd : nullptr; return S_OK; } @@ -1162,7 +1164,7 @@ HRESULT WINAPI QAxClientSite::OnInPlaceDeactivate() AX_DEBUG(QAxClientSite::OnInPlaceDeactivate); if (m_spInPlaceObject) m_spInPlaceObject->Release(); - m_spInPlaceObject = 0; + m_spInPlaceObject = nullptr; inPlaceObjectWindowless = false; OleLockRunning(m_spOleObject, false, false); @@ -1200,9 +1202,9 @@ HRESULT WINAPI QAxClientSite::InsertMenus(HMENU /*hmenuShared*/, LPOLEMENUGROUPW return E_NOTIMPL; menuBar = mb; - QMenu *fileMenu = 0; - QMenu *viewMenu = 0; - QMenu *windowMenu = 0; + QMenu *fileMenu = nullptr; + QMenu *viewMenu = nullptr; + QMenu *windowMenu = nullptr; QList<QAction*> actions = menuBar->actions(); for (int i = 0; i < actions.count(); ++i) { QAction *action = actions.at(i); @@ -1261,7 +1263,7 @@ static int menuItemEntry(HMENU menu, int index, MENUITEMINFO item, QString &text QMenu *QAxClientSite::generatePopup(HMENU subMenu, QWidget *parent) { - QMenu *popup = 0; + QMenu *popup = nullptr; int count = GetMenuItemCount(subMenu); if (count) popup = new QMenu(parent); @@ -1272,15 +1274,15 @@ QMenu *QAxClientSite::generatePopup(HMENU subMenu, QWidget *parent) item.fMask = MIIM_ID | MIIM_TYPE | MIIM_SUBMENU; ::GetMenuItemInfo(subMenu, UINT(i), true, &item); - QAction *action = 0; - QMenu *popupMenu = 0; + QAction *action = nullptr; + QMenu *popupMenu = nullptr; if (item.fType == MFT_SEPARATOR) { action = popup->addSeparator(); } else { QString text; QPixmap icon; QKeySequence accel; - popupMenu = item.hSubMenu ? generatePopup(item.hSubMenu, popup) : 0; + popupMenu = item.hSubMenu ? generatePopup(item.hSubMenu, popup) : nullptr; int res = menuItemEntry(subMenu, i, item, text, icon); int lastSep = text.lastIndexOf(QRegularExpression(QLatin1String("[\\s]"))); @@ -1346,14 +1348,14 @@ HRESULT WINAPI QAxClientSite::SetMenu(HMENU hmenuShared, HOLEMENU holemenu, HWND item.fMask = MIIM_ID | MIIM_TYPE | MIIM_SUBMENU; ::GetMenuItemInfo(hmenuShared, UINT(i), true, &item); - QAction *action = 0; - QMenu *popupMenu = 0; + QAction *action = nullptr; + QMenu *popupMenu = nullptr; if (item.fType == MFT_SEPARATOR) { action = menuBar->addSeparator(); } else { QString text; QPixmap icon; - popupMenu = item.hSubMenu ? generatePopup(item.hSubMenu, menuBar) : 0; + popupMenu = item.hSubMenu ? generatePopup(item.hSubMenu, menuBar) : nullptr; int res = menuItemEntry(hmenuShared, i, item, text, icon); if (popupMenu) @@ -1392,14 +1394,14 @@ HRESULT WINAPI QAxClientSite::SetMenu(HMENU hmenuShared, HOLEMENU holemenu, HWND QMetaObject::connect(menuBar, index, host, index); } } else if (menuBar) { - m_menuOwner = 0; + m_menuOwner = nullptr; const MenuItemMap::Iterator mend = menuItemMap.end(); for (MenuItemMap::Iterator it = menuItemMap.begin(); it != mend; ++it) delete it.key(); menuItemMap.clear(); } - OleSetMenuDescriptor(holemenu, widget ? hwndForWidget(widget) : 0, m_menuOwner, this, m_spInPlaceActiveObject); + OleSetMenuDescriptor(holemenu, widget ? hwndForWidget(widget) : nullptr, m_menuOwner, this, m_spInPlaceActiveObject); return S_OK; } @@ -1572,15 +1574,15 @@ HRESULT WINAPI QAxClientSite::ActivateMe(IOleDocumentView *pViewToActivate) if (m_spActiveView) m_spActiveView->Release(); - m_spActiveView = 0; + m_spActiveView = nullptr; if (!pViewToActivate) { - IOleDocument *document = 0; + IOleDocument *document = nullptr; m_spOleObject->QueryInterface(IID_IOleDocument, reinterpret_cast<void **>(&document)); if (!document) return E_FAIL; - document->CreateView(this, 0, 0, &pViewToActivate); + document->CreateView(this, nullptr, 0, &pViewToActivate); document->Release(); if (!pViewToActivate) @@ -1595,7 +1597,7 @@ HRESULT WINAPI QAxClientSite::ActivateMe(IOleDocumentView *pViewToActivate) m_spActiveView->UIActivate(TRUE); RECT rect; - GetClientRect((HWND)widget->winId(), &rect); + GetClientRect(HWND(widget->winId()), &rect); m_spActiveView->SetRect(&rect); m_spActiveView->Show(TRUE); @@ -1636,7 +1638,7 @@ void QAxClientSite::windowActivationChange() QAxHostWidget::QAxHostWidget(QWidget *parent, QAxClientSite *ax) : QWidget(parent), setFocusTimer(0), hasFocus(false), axhost(ax) { - setAttribute(Qt::WA_NoBackground); + setAttribute(Qt::WA_OpaquePaintEvent); setAttribute(Qt::WA_NoSystemBackground); setAttribute(Qt::WA_OpaquePaintEvent); setAttribute(Qt::WA_PaintOnScreen); @@ -1659,7 +1661,7 @@ int QAxHostWidget::qt_metacall(QMetaObject::Call call, int isignal, void **argv) void* QAxHostWidget::qt_metacast(const char *clname) { - if (!clname) return 0; + if (!clname) return nullptr; if (!qstrcmp(clname,"QAxHostWidget")) return static_cast<void*>(const_cast< QAxHostWidget*>(this)); return QWidget::qt_metacast(clname); @@ -1671,7 +1673,7 @@ QWindow *QAxHostWidget::hostWindow() const return w; if (QWidget *parent = nativeParentWidget()) return parent->windowHandle(); - return 0; + return nullptr; } QSize QAxHostWidget::sizeHint() const @@ -1722,7 +1724,11 @@ void QAxHostWidget::showEvent(QShowEvent *) resizeObject(); } +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) +bool QAxHostWidget::nativeEvent(const QByteArray &eventType, void *message, qintptr *result) +#else bool QAxHostWidget::nativeEvent(const QByteArray &eventType, void *message, long *result) +#endif { if (axhost && axhost->inPlaceObjectWindowless && eventType == QByteArrayLiteral("windows_generic_MSG")) { @@ -1748,7 +1754,7 @@ bool QAxHostWidget::event(QEvent *e) killTimer(setFocusTimer); setFocusTimer = 0; RECT rcPos = qaxNativeWidgetRect(this); - axhost->m_spOleObject->DoVerb(OLEIVERB_UIACTIVATE, 0, static_cast<IOleClientSite *>(axhost), 0, + axhost->m_spOleObject->DoVerb(OLEIVERB_UIACTIVATE, nullptr, static_cast<IOleClientSite *>(axhost), 0, reinterpret_cast<HWND>(winId()), &rcPos); if (axhost->m_spActiveView) axhost->m_spActiveView->UIActivate(TRUE); @@ -1834,7 +1840,7 @@ void QAxHostWidget::paintEvent(QPaintEvent*) if (!redirected(&dummyOffset)) return; - IViewObject *view = 0; + IViewObject *view = nullptr; if (axhost) axhost->widget->queryInterface(IID_IViewObject, reinterpret_cast<void **>(&view)); if (!view) @@ -1844,7 +1850,7 @@ void QAxHostWidget::paintEvent(QPaintEvent*) pm.fill(); HBITMAP hBmp = qt_pixmapToWinHBITMAP(pm); - const HDC displayDc = GetDC(0); + const HDC displayDc = GetDC(nullptr); HDC hBmp_hdc = CreateCompatibleDC(displayDc); HGDIOBJ old_hBmp = SelectObject(hBmp_hdc, hBmp); @@ -1854,7 +1860,7 @@ void QAxHostWidget::paintEvent(QPaintEvent*) bounds.top = 0; bounds.bottom = pm.height(); - view->Draw(DVASPECT_CONTENT, -1, 0, 0, 0, hBmp_hdc, &bounds, 0, 0 /*fptr*/, 0); + view->Draw(DVASPECT_CONTENT, -1, nullptr, nullptr, nullptr, hBmp_hdc, &bounds, nullptr, nullptr /*fptr*/, 0); view->Release(); QPainter painter(this); @@ -1865,7 +1871,7 @@ void QAxHostWidget::paintEvent(QPaintEvent*) SelectObject(hBmp_hdc, old_hBmp); DeleteObject(hBmp); DeleteDC(hBmp_hdc); - ReleaseDC(0, displayDc); + ReleaseDC(nullptr, displayDc); } /*! @@ -1912,7 +1918,7 @@ void QAxHostWidget::paintEvent(QPaintEvent*) const QMetaObject QAxWidget::staticMetaObject = { { &QWidget::staticMetaObject, qt_meta_stringdata_QAxBase.data, - qt_meta_data_QAxBase, qt_static_metacall, 0, 0 } + qt_meta_data_QAxBase, qt_static_metacall, nullptr, nullptr } }; /*! @@ -1921,7 +1927,7 @@ const QMetaObject QAxWidget::staticMetaObject = { call setControl(). */ QAxWidget::QAxWidget(QWidget *parent, Qt::WindowFlags f) -: QWidget(parent, f), container(0) +: QWidget(parent, f) { } @@ -1932,7 +1938,7 @@ QAxWidget::QAxWidget(QWidget *parent, Qt::WindowFlags f) \sa setControl() */ QAxWidget::QAxWidget(const QString &c, QWidget *parent, Qt::WindowFlags f) -: QWidget(parent, f), container(0) +: QWidget(parent, f) { setControl(c); } @@ -1942,7 +1948,7 @@ QAxWidget::QAxWidget(const QString &c, QWidget *parent, Qt::WindowFlags f) \a parent and \a f are propagated to the QWidget contructor. */ QAxWidget::QAxWidget(IUnknown *iface, QWidget *parent, Qt::WindowFlags f) -: QWidget(parent, f), QAxBase(iface), container(0) +: QWidget(parent, f), QAxBase(iface) { } @@ -2034,7 +2040,7 @@ bool QAxWidget::createHostWindow(bool initialized, const QByteArray &data) */ QAxAggregated *QAxWidget::createAggregate() { - return 0; + return nullptr; } /*! @@ -2065,7 +2071,7 @@ void QAxWidget::clear() container->releaseAll(); container->Release(); } - container = 0; + container = nullptr; } /*! diff --git a/src/activeqt/container/qaxwidget.h b/src/activeqt/container/qaxwidget.h index 49caa22..14c4290 100644 --- a/src/activeqt/container/qaxwidget.h +++ b/src/activeqt/container/qaxwidget.h @@ -96,9 +96,9 @@ protected: const QMetaObject *fallbackMetaObject() const override; private: friend class QAxClientSite; - QAxClientSite *container; + QAxClientSite *container = nullptr; - QAxWidgetPrivate *d; + QAxWidgetPrivate *m_unused = nullptr; const QMetaObject *parentMetaObject() const override; }; diff --git a/src/activeqt/control/qaxaggregated.h b/src/activeqt/control/qaxaggregated.h index 61d1f7f..01938be 100644 --- a/src/activeqt/control/qaxaggregated.h +++ b/src/activeqt/control/qaxaggregated.h @@ -65,7 +65,7 @@ class QAxAggregated { friend class QAxServerBase; friend class QAxClientSite; - Q_DISABLE_COPY(QAxAggregated) + Q_DISABLE_COPY_MOVE(QAxAggregated) public: virtual long queryInterface(const QUuid &iid, void **iface) = 0; diff --git a/src/activeqt/control/qaxbindable.cpp b/src/activeqt/control/qaxbindable.cpp index 2bb1ffe..f74122d 100644 --- a/src/activeqt/control/qaxbindable.cpp +++ b/src/activeqt/control/qaxbindable.cpp @@ -94,10 +94,7 @@ QT_BEGIN_NAMESPACE /*! Constructs an empty QAxBindable object. */ -QAxBindable::QAxBindable() -:activex(0) -{ -} +QAxBindable::QAxBindable() = default; /*! Destroys the QAxBindable object. @@ -152,7 +149,7 @@ void QAxBindable::propertyChanged(const char *property) IUnknown *QAxBindable::clientSite() const { if (!activex) - return 0; + return nullptr; return activex->clientSite(); } @@ -167,7 +164,7 @@ IUnknown *QAxBindable::clientSite() const */ QAxAggregated *QAxBindable::createAggregate() { - return 0; + return nullptr; } /*! diff --git a/src/activeqt/control/qaxbindable.h b/src/activeqt/control/qaxbindable.h index c5d2630..5bbc463 100644 --- a/src/activeqt/control/qaxbindable.h +++ b/src/activeqt/control/qaxbindable.h @@ -63,7 +63,7 @@ struct IAxServerBase; class QAxBindable { - Q_DISABLE_COPY(QAxBindable) + Q_DISABLE_COPY_MOVE(QAxBindable) friend class QAxServerBase; public: QAxBindable(); @@ -82,7 +82,7 @@ protected: IUnknown *clientSite() const; private: - IAxServerBase *activex; + IAxServerBase *activex = nullptr; }; QT_END_NAMESPACE diff --git a/src/activeqt/control/qaxfactory.cpp b/src/activeqt/control/qaxfactory.cpp index 0dbbd25..2faf508 100644 --- a/src/activeqt/control/qaxfactory.cpp +++ b/src/activeqt/control/qaxfactory.cpp @@ -458,7 +458,7 @@ public: }; ActiveObject::ActiveObject(QObject *parent, QAxFactory *factory) -: QObject(parent), wrapper(0), cookie(0) +: QObject(parent), wrapper(nullptr), cookie(0) { QLatin1String key(parent->metaObject()->className()); @@ -470,7 +470,7 @@ ActiveObject::ActiveObject(QObject *parent, QAxFactory *factory) ActiveObject::~ActiveObject() { if (cookie) - RevokeActiveObject(cookie, 0); + RevokeActiveObject(cookie, nullptr); if (wrapper) wrapper->Release(); } @@ -506,6 +506,7 @@ bool QAxFactory::registerActiveObject(QObject *object) /*! \macro QAXFACTORY_DEFAULT(Class, ClassID, InterfaceID, EventID, LibID, AppID) \relates QAxFactory + \deprecated This macro can be used to export a single QObject subclass \a Class a this COM server through an implicitly declared QAxFactory implementation. @@ -519,7 +520,8 @@ bool QAxFactory::registerActiveObject(QObject *object) \snippet src_activeqt_control_qaxfactory.cpp 7 - \sa QAXFACTORY_EXPORT(), QAXFACTORY_BEGIN() + \note This class has been deprecated in favor of QAXFACTORY_BEGIN(). + \sa QAXFACTORY_EXPORT() */ /*! diff --git a/src/activeqt/control/qaxfactory.h b/src/activeqt/control/qaxfactory.h index 05df3c9..d11685a 100644 --- a/src/activeqt/control/qaxfactory.h +++ b/src/activeqt/control/qaxfactory.h @@ -74,7 +74,7 @@ class QSettings; class QAxFactory : public QObject { - Q_DISABLE_COPY(QAxFactory) + Q_DISABLE_COPY_MOVE(QAxFactory) public: QAxFactory(const QUuid &libId, const QUuid &appId); ~QAxFactory() override; diff --git a/src/activeqt/control/qaxserver.cpp b/src/activeqt/control/qaxserver.cpp index 8ae62a2..bc93ee3 100644 --- a/src/activeqt/control/qaxserver.cpp +++ b/src/activeqt/control/qaxserver.cpp @@ -64,6 +64,7 @@ #include <qtextstream.h> #include <qloggingcategory.h> #include <qdebug.h> +#include <QScopeGuard> #include <qt_windows.h> #include <olectl.h> @@ -74,13 +75,13 @@ QT_BEGIN_NAMESPACE // Some global variables to store module information bool qAxIsServer = false; -HANDLE qAxInstance = 0; -ITypeLib *qAxTypeLibrary = 0; +HANDLE qAxInstance = nullptr; +ITypeLib *qAxTypeLibrary = nullptr; wchar_t qAxModuleFilename[MAX_PATH]; bool qAxOutProcServer = false; // The QAxFactory instance -static QAxFactory* qax_factory = 0; +static QAxFactory* qax_factory = nullptr; extern CLSID CLSID_QRect; extern CLSID CLSID_QSize; extern CLSID CLSID_QPoint; @@ -93,7 +94,7 @@ extern QAxFactory *qax_instantiate(); QAxFactory *qAxFactory() { if (!qax_factory) { - bool hadQApp = qApp != 0; + bool hadQApp = qApp != nullptr; qax_factory = qax_instantiate(); // QAxFactory created a QApplication if (!hadQApp && qApp) @@ -163,11 +164,11 @@ void qAxCleanup() return; delete qax_factory; - qax_factory = 0; + qax_factory = nullptr; if (qAxTypeLibrary) { qAxTypeLibrary->Release(); - qAxTypeLibrary = 0; + qAxTypeLibrary = nullptr; } DeleteCriticalSection(&qAxModuleSection); @@ -221,11 +222,8 @@ QString qax_clean_type(const QString &type, const QMetaObject *mo) return alias; } -// (Un)Register the ActiveX server in the registry. -// The QAxFactory implementation provides the information. -HRESULT UpdateRegistry(BOOL bRegister) +static void UpdateRegistryKeys(bool bRegister, const QString keyPath, QScopedPointer<QSettings> & settings) { - qAxIsServer = false; const QChar dot(QLatin1Char('.')); const QChar slash(QLatin1Char('/')); QString file = QString::fromWCharArray(qAxModuleFilename); @@ -234,54 +232,6 @@ HRESULT UpdateRegistry(BOOL bRegister) const QString appId = qAxFactory()->appID().toString().toUpper(); const QString libId = qAxFactory()->typeLibID().toString().toUpper(); - const QString libFile = qAxInit(); - - TLIBATTR *libAttr = 0; - if (qAxTypeLibrary) - qAxTypeLibrary->GetLibAttr(&libAttr); - if (!libAttr) - return SELFREG_E_TYPELIB; - bool userFallback = false; - if (bRegister) { - if (RegisterTypeLib(qAxTypeLibrary, - reinterpret_cast<wchar_t *>(const_cast<ushort *>(libFile.utf16())), 0) == TYPE_E_REGISTRYACCESS) { -#ifndef Q_CC_MINGW - // MinGW does not have RegisterTypeLibForUser() implemented so we cannot fallback in this case - RegisterTypeLibForUser(qAxTypeLibrary, reinterpret_cast<wchar_t *>(const_cast<ushort *>(libFile.utf16())), 0); - userFallback = true; -#endif - } - } else { - if (UnRegisterTypeLib(libAttr->guid, libAttr->wMajorVerNum, libAttr->wMinorVerNum, libAttr->lcid, - libAttr->syskind) == TYPE_E_REGISTRYACCESS) { -#ifndef Q_CC_MINGW - // MinGW does not have RegisterTypeLibForUser() implemented so we cannot fallback in this case - UnRegisterTypeLibForUser(libAttr->guid, libAttr->wMajorVerNum, libAttr->wMinorVerNum, libAttr->lcid, libAttr->syskind); - userFallback = true; -#endif - } - } - if (userFallback) - qWarning("QAxServer: Falling back to registering as user for %s due to insufficient permission.", qPrintable(module)); - qAxTypeLibrary->ReleaseTLibAttr(libAttr); - - // check whether the user has permission to write to HKLM\Software\Classes - // if not, use HKCU\Software\Classes - QString keyPath(QLatin1String("HKEY_LOCAL_MACHINE\\Software\\Classes")); - QScopedPointer<QSettings> settings(new QSettings(keyPath, QSettings::NativeFormat)); - if (userFallback || !settings->isWritable()) { - keyPath = QLatin1String("HKEY_CURRENT_USER\\Software\\Classes"); - settings.reset(new QSettings(keyPath, QSettings::NativeFormat)); - } - - // we try to create the ActiveX widgets later on... - bool delete_qApp = false; - if (!qApp) { - 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; - } - if (bRegister) { settings->setValue(QLatin1String("/AppID/") + appId + QLatin1String("/."), module); if (qAxOutProcServer) @@ -473,11 +423,72 @@ HRESULT UpdateRegistry(BOOL bRegister) << keyPath << '"'; } } +} + +// (Un)Register the ActiveX server in the registry. +// The QAxFactory implementation provides the information. +HRESULT UpdateRegistry(bool bRegister, bool perUser) +{ + qAxIsServer = false; + QString file = QString::fromWCharArray(qAxModuleFilename); + const QString module = QFileInfo(file).baseName(); + + const QString libFile = qAxInit(); + auto libFile_cleanup = qScopeGuard([] { qAxCleanup(); }); + + TLIBATTR *libAttr = nullptr; + if (qAxTypeLibrary) + qAxTypeLibrary->GetLibAttr(&libAttr); + if (!libAttr) + return SELFREG_E_TYPELIB; + auto libAttr_cleanup = qScopeGuard([libAttr] { qAxTypeLibrary->ReleaseTLibAttr(libAttr); }); + + if (bRegister) { + if (!perUser) { + HRESULT hr = RegisterTypeLib(qAxTypeLibrary, reinterpret_cast<wchar_t *>(const_cast<ushort *>(libFile.utf16())), nullptr); + if (FAILED(hr)) { + qWarning("Failing to register %s due to insufficient permission.", qPrintable(module)); + return hr; + } + } else { +#ifndef Q_CC_MINGW + // MinGW does not have RegisterTypeLibForUser() implemented so we cannot fallback in this case + RegisterTypeLibForUser(qAxTypeLibrary, reinterpret_cast<wchar_t *>(const_cast<ushort *>(libFile.utf16())), nullptr); +#endif + } + } else { + if (!perUser) { + HRESULT hr = UnRegisterTypeLib(libAttr->guid, libAttr->wMajorVerNum, libAttr->wMinorVerNum, libAttr->lcid, libAttr->syskind); + if (FAILED(hr)) { + qWarning("Failing to register %s due to insufficient permission.", qPrintable(module)); + return hr; + } + } else { +#ifndef Q_CC_MINGW + // MinGW does not have RegisterTypeLibForUser() implemented so we cannot fallback in this case + UnRegisterTypeLibForUser(libAttr->guid, libAttr->wMajorVerNum, libAttr->wMinorVerNum, libAttr->lcid, libAttr->syskind); +#endif + } + } + + QString keyPath(QLatin1String("HKEY_LOCAL_MACHINE\\Software\\Classes")); + if (perUser) + keyPath = QLatin1String("HKEY_CURRENT_USER\\Software\\Classes"); + QScopedPointer<QSettings> settings(new QSettings(keyPath, QSettings::NativeFormat)); + + // we try to create the ActiveX widgets later on... + bool delete_qApp = false; + if (!qApp) { + 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, nullptr); + delete_qApp = true; + } + + UpdateRegistryKeys(bRegister, keyPath, settings); if (delete_qApp) delete qApp; - qAxCleanup(); if (settings->status() == QSettings::NoError) return S_OK; qWarning() << module << ": Error writing to " << keyPath; @@ -542,7 +553,7 @@ static const char* const type_map[][2] = { "IUnknown", "IUnknown*" }, { "IDispatch*", "IDispatch*" }, { "IUnknown*", "IUnknown*" }, - { 0, 0 } + { nullptr, nullptr } }; static QByteArray convertTypes(const QByteArray &qtype, bool *ok) @@ -614,7 +625,7 @@ static const char* const keyword_map[][2] = { "source", "source_" }, { "string", "string_" }, { "uuid", "uuid_" }, - { 0, 0 } + { nullptr, nullptr } }; static QByteArray replaceKeyword(const QByteArray &name) @@ -684,7 +695,7 @@ static const char* const ignore_props[] = "customWhatsThis", "shown", "windowOpacity", - 0 + nullptr }; // filter out some slots @@ -707,7 +718,7 @@ static const char* const ignore_slots[] = "move_1", "resize_1", "setGeometry_1", - 0 + nullptr }; static bool ignore(const char *test, const char *const *table) @@ -750,7 +761,7 @@ static QByteArray prototype(const QList<QByteArray> ¶meterTypes, const QList for (int p = 0; p < parameterTypes.count() && *ok; ++p) { bool out = false; QByteArray type(parameterTypes.at(p)); - QByteArray name(parameterNames.at(p)); + const QByteArray &name = parameterNames.at(p); if (type.endsWith('&')) { out = true; @@ -1174,7 +1185,7 @@ extern "C" HRESULT __stdcall DumpIDL(const QString &outfile, const QString &ver) bool delete_qApp = false; if (!qApp) { 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); + (void)new QApplication(argc, nullptr); delete_qApp = true; } @@ -1257,7 +1268,7 @@ extern "C" HRESULT __stdcall DumpIDL(const QString &outfile, const QString &ver) QObject *o = qAxFactory()->createObject(className); // It's not a control class, so it is actually a subtype. Define it. if (!o) - res = classIDL(0, mo, className, false, out); + res = classIDL(nullptr, mo, className, false, out); delete o; } } @@ -1272,7 +1283,7 @@ extern "C" HRESULT __stdcall DumpIDL(const QString &outfile, const QString &ver) continue; const QMetaObject *mo = o->metaObject(); QAxBindable *bind = static_cast<QAxBindable *>(o->qt_metacast("QAxBindable")); - bool isBindable = bind != 0; + bool isBindable = bind != nullptr; const QByteArray cleanType = qax_clean_type(className, mo).toLatin1(); subtypes.append(cleanType); diff --git a/src/activeqt/control/qaxserver.def b/src/activeqt/control/qaxserver.def index bc82a03..00725e6 100644 --- a/src/activeqt/control/qaxserver.def +++ b/src/activeqt/control/qaxserver.def @@ -3,4 +3,5 @@ EXPORTS DllGetClassObject PRIVATE DllRegisterServer PRIVATE DllUnregisterServer PRIVATE + DllInstall PRIVATE DumpIDL PRIVATE diff --git a/src/activeqt/control/qaxserver.rc b/src/activeqt/control/qaxserver.rc index 390e481..a472365 100644 --- a/src/activeqt/control/qaxserver.rc +++ b/src/activeqt/control/qaxserver.rc @@ -1,2 +1,2 @@ 1 TYPELIB "qaxserver.rc" -1 ICON DISCARDABLE "qaxserver.ico" +1 ICON "qaxserver.ico" diff --git a/src/activeqt/control/qaxserverbase.cpp b/src/activeqt/control/qaxserverbase.cpp index e0ad0eb..4fb5ef3 100644 --- a/src/activeqt/control/qaxserverbase.cpp +++ b/src/activeqt/control/qaxserverbase.cpp @@ -106,7 +106,6 @@ extern HHOOK qax_hhook; // in qaxserver.cpp extern ITypeLib *qAxTypeLibrary; -extern QAxFactory *qAxFactory(); extern unsigned long qAxLock(); extern unsigned long qAxUnlock(); extern HANDLE qAxInstance; @@ -167,8 +166,7 @@ class QAxServerBase : public IDataObject { public: - typedef QMap<QUuid,IConnectionPoint*> ConnectionPoints; - typedef QMap<QUuid,IConnectionPoint*>::Iterator ConnectionPointsIterator; + using ConnectionPoints = QMap<QUuid,IConnectionPoint*>; QAxServerBase(const QString &classname, IUnknown *outerUnknown); QAxServerBase(QObject *o); @@ -179,7 +177,7 @@ public: // Window creation HWND create(HWND hWndParent, RECT& rcPos); - HMENU createPopup(QMenu *popup, HMENU oldMenu = 0); + HMENU createPopup(QMenu *popup, HMENU oldMenu = nullptr); void createMenu(QMenuBar *menuBar); void removeMenu(); @@ -379,8 +377,7 @@ private: friend class QAxBindable; friend class QAxPropertyPage; - - QAxAggregated *aggregatedObject; + QAxAggregated *aggregatedObject = nullptr; ConnectionPoints points; union { @@ -399,13 +396,13 @@ private: unsigned wasUIActive :1; unsigned inDesignMode :1; unsigned canTakeFocus :1; - short freezeEvents; + short freezeEvents = 0; - HWND m_hWnd; + HWND m_hWnd = nullptr; - HMENU hmenuShared; - HOLEMENU holemenu; - HWND hwndMenuOwner; + HMENU hmenuShared = nullptr; + HOLEMENU holemenu = nullptr; + HWND hwndMenuOwner = nullptr; QMap<HMENU, QMenu*> menuMap; QMap<UINT, QAction*> actionMap; QPointer<QMenuBar> menuBar; @@ -416,8 +413,8 @@ private: CRITICAL_SECTION refCountSection; CRITICAL_SECTION createWindowSection; - LONG ref; - unsigned long ole_ref; + LONG ref = 0; + unsigned long ole_ref = 0; QString class_name; QString currentFileName; @@ -425,15 +422,15 @@ private: QHash<long, int> indexCache; QHash<int,DISPID> signalCache; - IUnknown *m_outerUnknown; - IAdviseSink *m_spAdviseSink; + IUnknown *m_outerUnknown = nullptr; + IAdviseSink *m_spAdviseSink = nullptr; QList<STATDATA> adviseSinks; - IOleClientSite *m_spClientSite; - IOleInPlaceSite *m_spInPlaceSite; - IOleInPlaceSiteWindowless *m_spInPlaceSiteWindowless; - IOleInPlaceFrame *m_spInPlaceFrame; - ITypeInfo *m_spTypeInfo; - IStorage *m_spStorage; + IOleClientSite *m_spClientSite = nullptr; + IOleInPlaceSite *m_spInPlaceSite = nullptr; + IOleInPlaceSiteWindowless *m_spInPlaceSiteWindowless = nullptr; + IOleInPlaceFrame *m_spInPlaceFrame = nullptr; + ITypeInfo *m_spTypeInfo = nullptr; + IStorage *m_spStorage = nullptr; QSize m_currentExtent; // device independent pixels. }; @@ -448,10 +445,9 @@ static inline QAxServerBase *axServerBaseFromWindow(HWND hWnd) class QAxServerAggregate : public IUnknown { - Q_DISABLE_COPY(QAxServerAggregate) + Q_DISABLE_COPY_MOVE(QAxServerAggregate) public: QAxServerAggregate(const QString &className, IUnknown *outerUnknown) - : ref(0) { object = new QAxServerBase(className, outerUnknown); object->registerActiveObject(this); @@ -482,7 +478,7 @@ public: } HRESULT WINAPI QueryInterface(REFIID iid, void **iface) override { - *iface = 0; + *iface = nullptr; if (iid == IID_IUnknown) { *iface = static_cast<IUnknown *>(this); @@ -494,7 +490,7 @@ public: private: QAxServerBase *object; - LONG ref; + LONG ref = 0; CRITICAL_SECTION refCountSection; CRITICAL_SECTION createWindowSection; @@ -502,7 +498,7 @@ private: bool QAxFactory::createObjectWrapper(QObject *object, IDispatch **wrapper) { - *wrapper = 0; + *wrapper = nullptr; QAxServerBase *obj = new QAxServerBase(object); obj->QueryInterface(IID_IDispatch, reinterpret_cast<void **>(wrapper)); if (*wrapper) @@ -525,8 +521,6 @@ public: QAxSignalVec(const QAxServerBase::ConnectionPoints &points) : cpoints(points.values()) - , current(0) - , ref(0) { InitializeCriticalSection(&refCountSection); const int count = cpoints.count(); @@ -552,11 +546,11 @@ public: DeleteCriticalSection(&refCountSection); } - unsigned long __stdcall AddRef() + unsigned long __stdcall AddRef() override { return InterlockedIncrement(&ref); } - unsigned long __stdcall Release() + unsigned long __stdcall Release() override { LONG refCount = InterlockedDecrement(&ref); if (!refCount) @@ -568,7 +562,7 @@ public: { if (!iface) return E_POINTER; - *iface = 0; + *iface = nullptr; if (iid == IID_IUnknown) *iface = this; else if (iid == IID_IEnumConnectionPoints) @@ -628,12 +622,12 @@ public: } QList<IConnectionPoint*> cpoints; - int current; + int current = 0; private: CRITICAL_SECTION refCountSection; - LONG ref; + LONG ref = 0; }; /* @@ -647,11 +641,10 @@ public: QAxConnection(QAxConnection &&) = delete; QAxConnection &operator=(QAxConnection &&) = delete; - typedef QList<CONNECTDATA> Connections; - typedef QList<CONNECTDATA>::Iterator Iterator; + using Connections = QList<CONNECTDATA>; QAxConnection(QAxServerBase *parent, const QUuid &uuid) - : that(parent), iid(uuid), current(0), ref(1) + : that(parent), iid(uuid) { InitializeCriticalSection(&refCountSection); } @@ -687,7 +680,7 @@ public: { if (!iface) return E_POINTER; - *iface = 0; + *iface = nullptr; if (iid == IID_IUnknown) *iface = static_cast<IConnectionPoint *>(this); else if (iid == IID_IConnectionPoint) @@ -717,7 +710,7 @@ public: return E_POINTER; { - IDispatch *checkImpl = 0; + IDispatch *checkImpl = nullptr; pUnk->QueryInterface(iid, reinterpret_cast<void **>(&checkImpl)); if (!checkImpl) return CONNECT_E_CANNOTCONNECT; @@ -807,10 +800,10 @@ private: QAxServerBase *that; QUuid iid; Connections connections; - int current; + int current = 0; CRITICAL_SECTION refCountSection; - LONG ref; + LONG ref = 1; }; // callback for DLL server to hook into non-Qt eventloop @@ -827,10 +820,18 @@ LRESULT QT_WIN_CALLBACK axs_FilterProc(int nCode, WPARAM wParam, LPARAM lParam) class QAxWinEventFilter : public QAbstractNativeEventFilter { public: +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + bool nativeEventFilter(const QByteArray &, void *message, qintptr *) override; +#else bool nativeEventFilter(const QByteArray &, void *message, long *) override; +#endif }; +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) +bool QAxWinEventFilter::nativeEventFilter(const QByteArray &, void *message, qintptr *) +#else bool QAxWinEventFilter::nativeEventFilter(const QByteArray &, void *message, long *) +#endif { MSG *pMsg = static_cast<MSG *>(message); if (pMsg->message < WM_KEYFIRST || pMsg->message > WM_KEYLAST) @@ -843,7 +844,7 @@ bool QAxWinEventFilter::nativeEventFilter(const QByteArray &, void *message, lon // FIXME: 4.10.211: was '::GetParent(hwndForWidget(aqt));' HWND baseHwnd = hwndForWidget(aqt); - QAxServerBase *axbase = 0; + QAxServerBase *axbase = nullptr; while (!axbase && baseHwnd) { axbase = axServerBaseFromWindow(baseHwnd); baseHwnd = ::GetParent(baseHwnd); @@ -860,7 +861,6 @@ Q_GLOBAL_STATIC(QAxWinEventFilter, qax_winEventFilter); // COM Factory class, mapping COM requests to ActiveQt requests. // One instance of this class for each ActiveX the server can provide. QClassFactory::QClassFactory(CLSID clsid) - : ref(0), licensed(false) { InitializeCriticalSection(&refCountSection); @@ -902,7 +902,7 @@ unsigned long QClassFactory::Release() HRESULT QClassFactory::QueryInterface(REFIID iid, LPVOID *iface) { - *iface = 0; + *iface = nullptr; if (iid == IID_IUnknown) *iface = static_cast<IUnknown *>(this); else if (iid == IID_IClassFactory) @@ -930,7 +930,7 @@ HRESULT QClassFactory::CreateInstanceHelper(IUnknown *pUnkOuter, REFIID iid, voi if (!qApp) { qax_ownQApp = true; static int argc = 0; // static lifetime, since it's passed as reference to QApplication, which has a lifetime exceeding the stack frame - new QApplication(argc, 0); + new QApplication(argc, nullptr); } QGuiApplication::setQuitOnLastWindowClosed(false); @@ -941,7 +941,7 @@ HRESULT QClassFactory::CreateInstanceHelper(IUnknown *pUnkOuter, REFIID iid, voi // hook into eventloop; this allows a server to create his own QApplication object if (!qax_hhook && qax_ownQApp) { - qax_hhook = SetWindowsHookEx(WH_GETMESSAGE, axs_FilterProc, 0, GetCurrentThreadId()); + qax_hhook = SetWindowsHookEx(WH_GETMESSAGE, axs_FilterProc, nullptr, GetCurrentThreadId()); } // If we created QApplication instance, ensure native event loop starts properly @@ -992,7 +992,7 @@ HRESULT QClassFactory::RequestLicKey(DWORD, BSTR *pKey) { if (!pKey) return E_POINTER; - *pKey = 0; + *pKey = nullptr; // This of course works only on fully licensed machines if (!qAxFactory()->validateLicenseKey(className, QString())) @@ -1059,10 +1059,7 @@ HRESULT GetClassObject(REFIID clsid, REFIID iid, void **ppUnk) the COM server for the respective CLSID. */ QAxServerBase::QAxServerBase(const QString &classname, IUnknown *outerUnknown) -: aggregatedObject(0), - m_hWnd(0), hmenuShared(0), hwndMenuOwner(0), - ref(0), ole_ref(0), class_name(classname), - m_outerUnknown(outerUnknown) + : class_name(classname), m_outerUnknown(outerUnknown) { init(); @@ -1073,13 +1070,6 @@ QAxServerBase::QAxServerBase(const QString &classname, IUnknown *outerUnknown) Constructs a QAxServerBase object wrapping \a o. */ QAxServerBase::QAxServerBase(QObject *o) - : aggregatedObject(0) - , m_hWnd(0) - , hmenuShared(0) - , hwndMenuOwner(0) - , ref(0) - , ole_ref(0) - , m_outerUnknown(0) { init(); @@ -1098,7 +1088,7 @@ QAxServerBase::QAxServerBase(QObject *o) */ void QAxServerBase::init() { - qt.object = 0; + qt.object = nullptr; isWidget = false; ownObject = false; initNewCalled = false; @@ -1110,16 +1100,6 @@ void QAxServerBase::init() wasUIActive = false; inDesignMode = false; canTakeFocus = false; - freezeEvents = 0; - exception = 0; - - m_spAdviseSink = 0; - m_spClientSite = 0; - m_spInPlaceSiteWindowless = 0; - m_spInPlaceSite = 0; - m_spInPlaceFrame = 0; - m_spTypeInfo = 0; - m_spStorage = 0; InitializeCriticalSection(&refCountSection); InitializeCriticalSection(&createWindowSection); @@ -1153,33 +1133,33 @@ QAxServerBase::~QAxServerBase() point->Release(); } delete aggregatedObject; - aggregatedObject = 0; + aggregatedObject = nullptr; if (theObject) { qt.object->disconnect(this); QObject *aqt = qt.object; - qt.object = 0; + qt.object = nullptr; if (ownObject) delete aqt; } if (m_spAdviseSink) m_spAdviseSink->Release(); - m_spAdviseSink = 0; + m_spAdviseSink = nullptr; for (int i = 0; i < adviseSinks.count(); ++i) { adviseSinks.at(i).pAdvSink->Release(); } if (m_spClientSite) m_spClientSite->Release(); - m_spClientSite = 0; + m_spClientSite = nullptr; if (m_spInPlaceFrame) m_spInPlaceFrame->Release(); - m_spInPlaceFrame = 0; + m_spInPlaceFrame = nullptr; if (m_spInPlaceSiteWindowless) m_spInPlaceSiteWindowless->Release(); - m_spInPlaceSiteWindowless = 0; + m_spInPlaceSiteWindowless = nullptr; if (m_spInPlaceSite) m_spInPlaceSite->Release(); - m_spInPlaceSite = 0; + m_spInPlaceSite = nullptr; if (m_spTypeInfo) m_spTypeInfo->Release(); - m_spTypeInfo = 0; + m_spTypeInfo = nullptr; if (m_spStorage) m_spStorage->Release(); - m_spStorage = 0; + m_spStorage = nullptr; DeleteCriticalSection(&refCountSection); DeleteCriticalSection(&createWindowSection); @@ -1205,7 +1185,7 @@ void QAxServerBase::revokeActiveObject() if (!ole_ref) return; - RevokeActiveObject(ole_ref, 0); + RevokeActiveObject(ole_ref, nullptr); ole_ref = 0; } @@ -1222,7 +1202,7 @@ HRESULT WINAPI QAxServerBase::QueryInterface(REFIID iid, void **iface) HRESULT QAxServerBase::InternalQueryInterface(REFIID iid, void **iface) { - *iface = 0; + *iface = nullptr; if (iid == IID_IUnknown) { *iface = static_cast<IUnknown *>(static_cast<IDispatch *>(this)); @@ -1421,7 +1401,7 @@ LRESULT QT_WIN_CALLBACK QAxServerBase::ActiveXProc(HWND hWnd, UINT uMsg, WPARAM switch (uMsg) { case WM_NCDESTROY: if (QAxServerBase *that = axServerBaseFromWindow(hWnd)) - that->m_hWnd = 0; + that->m_hWnd = nullptr; break; case WM_QUERYENDSESSION: @@ -1431,7 +1411,7 @@ LRESULT QT_WIN_CALLBACK QAxServerBase::ActiveXProc(HWND hWnd, UINT uMsg, WPARAM that->qt.widget->hide(); if (QWindow *widgetWindow = that->qt.widget->windowHandle()) { if (HWND h = reinterpret_cast<HWND>(widgetWindow->winId())) - ::SetParent(h, 0); + ::SetParent(h, nullptr); } } } @@ -1491,9 +1471,9 @@ LRESULT QT_WIN_CALLBACK QAxServerBase::ActiveXProc(HWND hWnd, UINT uMsg, WPARAM if (QAxServerBase *that = axServerBaseFromWindow(hWnd)) { if (that->isInPlaceActive && that->m_spClientSite && !that->inDesignMode && that->canTakeFocus) { RECT rcPos = that->rcPosRect(); - that->DoVerb(OLEIVERB_UIACTIVATE, NULL, that->m_spClientSite, 0, that->m_hWnd, &rcPos); + that->DoVerb(OLEIVERB_UIACTIVATE, nullptr, that->m_spClientSite, 0, that->m_hWnd, &rcPos); if (that->isUIActive) { - IOleControlSite *spSite = 0; + IOleControlSite *spSite = nullptr; that->m_spClientSite->QueryInterface(IID_IOleControlSite, reinterpret_cast<void **>(&spSite)); if (spSite) { spSite->OnFocus(true); @@ -1503,7 +1483,7 @@ LRESULT QT_WIN_CALLBACK QAxServerBase::ActiveXProc(HWND hWnd, UINT uMsg, WPARAM while (!(candidate->focusPolicy() & Qt::TabFocus)) { candidate = candidate->nextInFocusChain(); if (candidate == that->qt.widget) { - candidate = 0; + candidate = nullptr; break; } } @@ -1520,7 +1500,7 @@ LRESULT QT_WIN_CALLBACK QAxServerBase::ActiveXProc(HWND hWnd, UINT uMsg, WPARAM case WM_KILLFOCUS: if (QAxServerBase *that = axServerBaseFromWindow(hWnd)) { if (that->isInPlaceActive && that->isUIActive && that->m_spClientSite) { - IOleControlSite *spSite = 0; + IOleControlSite *spSite = nullptr; that->m_spClientSite->QueryInterface(IID_IOleControlSite, reinterpret_cast<void **>(&spSite)); if (spSite) { if (!::IsChild(that->m_hWnd, ::GetFocus())) @@ -1534,7 +1514,7 @@ LRESULT QT_WIN_CALLBACK QAxServerBase::ActiveXProc(HWND hWnd, UINT uMsg, WPARAM case WM_MOUSEACTIVATE: if (QAxServerBase *that = axServerBaseFromWindow(hWnd)) { RECT rcPos = that->rcPosRect(); - that->DoVerb(OLEIVERB_UIACTIVATE, NULL, that->m_spClientSite, 0, that->m_hWnd, &rcPos); + that->DoVerb(OLEIVERB_UIACTIVATE, nullptr, that->m_spClientSite, 0, that->m_hWnd, &rcPos); } break; @@ -1549,7 +1529,7 @@ LRESULT QT_WIN_CALLBACK QAxServerBase::ActiveXProc(HWND hWnd, UINT uMsg, WPARAM if (index < 0) break; - that->currentPopup->qt_metacall(QMetaObject::InvokeMetaMethod, index, 0); + that->currentPopup->qt_metacall(QMetaObject::InvokeMetaMethod, index, nullptr); that->createPopup(that->currentPopup, reinterpret_cast<HMENU>(wParam)); return 0; } @@ -1564,7 +1544,7 @@ LRESULT QT_WIN_CALLBACK QAxServerBase::ActiveXProc(HWND hWnd, UINT uMsg, WPARAM if (!menuBar) break; - QObject *menuObject = 0; + QObject *menuObject = nullptr; bool menuClosed = false; if (uMsg == WM_COMMAND) { @@ -1590,9 +1570,9 @@ LRESULT QT_WIN_CALLBACK QAxServerBase::ActiveXProc(HWND hWnd, UINT uMsg, WPARAM if (index < 0) break; - menuObject->qt_metacall(QMetaObject::InvokeMetaMethod, index, 0); + menuObject->qt_metacall(QMetaObject::InvokeMetaMethod, index, nullptr); if (menuClosed || uMsg == WM_COMMAND) - that->currentPopup = 0; + that->currentPopup = nullptr; return 0; } } @@ -1617,7 +1597,7 @@ HWND QAxServerBase::create(HWND hWndParent, RECT& rcPos) Q_ASSERT(isWidget && qt.widget); static ATOM atom = 0; - HINSTANCE hInst = (HINSTANCE)qAxInstance; + HINSTANCE hInst = reinterpret_cast<HINSTANCE>(qAxInstance); EnterCriticalSection(&createWindowSection); QString cn(QLatin1String("QAxControl")); cn += QString::number(quintptr(ActiveXProc)); @@ -1626,12 +1606,12 @@ HWND QAxServerBase::create(HWND hWndParent, RECT& rcPos) wcTemp.style = CS_DBLCLKS; wcTemp.cbClsExtra = 0; wcTemp.cbWndExtra = 0; - wcTemp.hbrBackground = 0; - wcTemp.hCursor = 0; - wcTemp.hIcon = 0; + wcTemp.hbrBackground = nullptr; + wcTemp.hCursor = nullptr; + wcTemp.hIcon = nullptr; wcTemp.hInstance = hInst; wcTemp.lpszClassName = reinterpret_cast<const wchar_t *>(cn.utf16()); - wcTemp.lpszMenuName = 0; + wcTemp.lpszMenuName = nullptr; wcTemp.lpfnWndProc = ActiveXProc; atom = RegisterClass(&wcTemp); @@ -1647,20 +1627,20 @@ HWND QAxServerBase::create(HWND hWndParent, RECT& rcPos) Q_ASSERT(!m_hWnd); // will fail if parent window belongs to a higher integrity level process - HWND hWnd = ::CreateWindow(reinterpret_cast<const wchar_t *>(cn.utf16()), 0, + HWND hWnd = ::CreateWindow(reinterpret_cast<const wchar_t *>(cn.utf16()), nullptr, WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS, rcPos.left, rcPos.top, rcPos.right - rcPos.left, - rcPos.bottom - rcPos.top, hWndParent, 0, hInst, this); + rcPos.bottom - rcPos.top, hWndParent, nullptr, hInst, this); // m_hWnd is assigned in reponse to WM_CREATE if (!hWnd) { DWORD err = GetLastError(); if (err == ERROR_ACCESS_DENIED) { // retry without parent window // the window will now need to be re-parented in the container process - hWnd = ::CreateWindow(reinterpret_cast<const wchar_t *>(cn.utf16()), 0, + hWnd = ::CreateWindow(reinterpret_cast<const wchar_t *>(cn.utf16()), nullptr, WS_CLIPCHILDREN | WS_CLIPSIBLINGS, rcPos.left, rcPos.top, rcPos.right - rcPos.left, - rcPos.bottom - rcPos.top, nullptr, 0, hInst, this); + rcPos.bottom - rcPos.top, nullptr, nullptr, hInst, this); } } @@ -1766,7 +1746,7 @@ void QAxServerBase::createMenu(QMenuBar *menuBar) HRESULT hres = m_spInPlaceFrame->InsertMenus(hmenuShared, &menuWidths); if (FAILED(hres)) { ::DestroyMenu(hmenuShared); - hmenuShared = 0; + hmenuShared = nullptr; return; } @@ -1776,7 +1756,7 @@ void QAxServerBase::createMenu(QMenuBar *menuBar) hres = m_spInPlaceFrame->SetMenu(hmenuShared, holemenu, m_hWnd); if (FAILED(hres)) { ::DestroyMenu(hmenuShared); - hmenuShared = 0; + hmenuShared = nullptr; OleDestroyMenuDescriptor(holemenu); } } @@ -1788,14 +1768,14 @@ void QAxServerBase::removeMenu() { if (hmenuShared) m_spInPlaceFrame->RemoveMenus(hmenuShared); - holemenu = 0; - m_spInPlaceFrame->SetMenu(0, 0, m_hWnd); + holemenu = nullptr; + m_spInPlaceFrame->SetMenu(nullptr, nullptr, m_hWnd); if (hmenuShared) { DestroyMenu(hmenuShared); - hmenuShared = 0; + hmenuShared = nullptr; menuMap.clear(); } - hwndMenuOwner = 0; + hwndMenuOwner = nullptr; } extern bool ignoreSlots(const char *test); @@ -1850,9 +1830,9 @@ void QAxServerBase::update() { if (isInPlaceActive) { if (m_hWnd) - ::InvalidateRect(m_hWnd, 0, true); + ::InvalidateRect(m_hWnd, nullptr, true); else if (m_spInPlaceSiteWindowless) - m_spInPlaceSiteWindowless->InvalidateRect(NULL, true); + m_spInPlaceSiteWindowless->InvalidateRect(nullptr, true); } else if (m_spAdviseSink) { m_spAdviseSink->OnViewChange(DVASPECT_CONTENT, -1); for (int i = 0; i < adviseSinks.count(); ++i) { @@ -1934,7 +1914,7 @@ void QAxServerBase::updateMask() // Since SetWindowRegion takes ownership HRGN wr = CreateRectRgn(0,0,0,0); - CombineRgn(wr, hrgn, 0, RGN_COPY); + CombineRgn(wr, hrgn, nullptr, RGN_COPY); SetWindowRgn(m_hWnd, wr, true); DeleteObject(hrgn); } @@ -2021,7 +2001,7 @@ int QAxServerBase::qt_metacall(QMetaObject::Call call, int index, void **argv) eventId = signalCache.value(index, -1); if (eventId == -1) { - ITypeInfo *eventInfo = 0; + ITypeInfo *eventInfo = nullptr; qAxTypeLibrary->GetTypeInfoOfGuid(qAxFactory()->eventsID(class_name), &eventInfo); if (eventInfo) { QString uni_name = QLatin1String(name); @@ -2049,11 +2029,11 @@ int QAxServerBase::qt_metacall(QMetaObject::Call call, int index, void **argv) return false; // For all connected event sinks... - IConnectionPoint *cpoint = 0; + IConnectionPoint *cpoint = nullptr; GUID IID_QAxEvents = qAxFactory()->eventsID(class_name); FindConnectionPoint(IID_QAxEvents, &cpoint); if (cpoint) { - IEnumConnections *clist = 0; + IEnumConnections *clist = nullptr; cpoint->EnumConnections(&clist); if (clist) { clist->Reset(); @@ -2066,8 +2046,8 @@ int QAxServerBase::qt_metacall(QMetaObject::Call call, int index, void **argv) DISPPARAMS dispParams; dispParams.cArgs = UINT(pcount); dispParams.cNamedArgs = 0; - dispParams.rgdispidNamedArgs = 0; - dispParams.rgvarg = 0; + dispParams.rgdispidNamedArgs = nullptr; + dispParams.rgvarg = nullptr; if (pcount) // Use malloc/free for eval package compatibility dispParams.rgvarg = static_cast<VARIANTARG *>(malloc(size_t(pcount) * sizeof(VARIANTARG))); @@ -2102,17 +2082,17 @@ int QAxServerBase::qt_metacall(QMetaObject::Call call, int index, void **argv) VARIANT retval; VariantInit(&retval); - VARIANT *pretval = 0; + VARIANT *pretval = nullptr; if (!type.isEmpty() && type != "void") pretval = &retval; // call listeners (through IDispatch) while (cc) { if (c->pUnk) { - IDispatch *disp = 0; + IDispatch *disp = nullptr; c->pUnk->QueryInterface(IID_QAxEvents, reinterpret_cast<void **>(&disp)); if (disp) { - disp->Invoke(eventId, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &dispParams, pretval, 0, &argErr); + disp->Invoke(eventId, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &dispParams, pretval, nullptr, &argErr); // update out-parameters and return value if (index > 0) { @@ -2153,10 +2133,10 @@ bool QAxServerBase::emitRequestPropertyChange(const char *property) { long dispId = -1; - IConnectionPoint *cpoint = 0; + IConnectionPoint *cpoint = nullptr; FindConnectionPoint(IID_IPropertyNotifySink, &cpoint); if (cpoint) { - IEnumConnections *clist = 0; + IEnumConnections *clist = nullptr; cpoint->EnumConnections(&clist); if (clist) { clist->Reset(); @@ -2171,7 +2151,7 @@ bool QAxServerBase::emitRequestPropertyChange(const char *property) } if (dispId != -1) while (cc) { if (c->pUnk) { - IPropertyNotifySink *sink = 0; + IPropertyNotifySink *sink = nullptr; c->pUnk->QueryInterface(IID_IPropertyNotifySink, reinterpret_cast<void **>(&sink)); bool disallows = sink && sink->OnRequestEdit(dispId) == S_FALSE; sink->Release(); @@ -2201,10 +2181,10 @@ void QAxServerBase::emitPropertyChanged(const char *property) { long dispId = -1; - IConnectionPoint *cpoint = 0; + IConnectionPoint *cpoint = nullptr; FindConnectionPoint(IID_IPropertyNotifySink, &cpoint); if (cpoint) { - IEnumConnections *clist = 0; + IEnumConnections *clist = nullptr; cpoint->EnumConnections(&clist); if (clist) { clist->Reset(); @@ -2219,7 +2199,7 @@ void QAxServerBase::emitPropertyChanged(const char *property) } if (dispId != -1) while (cc) { if (c->pUnk) { - IPropertyNotifySink *sink = 0; + IPropertyNotifySink *sink = nullptr; c->pUnk->QueryInterface(IID_IPropertyNotifySink, reinterpret_cast<void **>(&sink)); if (sink) { sink->OnChanged(dispId); @@ -2246,7 +2226,7 @@ HRESULT WINAPI QAxServerBase::GetClassInfo(ITypeInfo** pptinfo) if (!pptinfo) return E_POINTER; - *pptinfo = 0; + *pptinfo = nullptr; if (!qAxTypeLibrary) return DISP_E_BADINDEX; @@ -2488,9 +2468,9 @@ HRESULT WINAPI QAxServerBase::Invoke(DISPID dispidMember, REFIID riid, if (!type.isEmpty()) ++totalParam; - void **argv = 0; // the actual array passed into qt_metacall - void **argv_pointer = 0; // in case we need an additional level of indirection - QVariant *varp = 0; // QVariants to hold the temporary Qt data object for us + void **argv = nullptr; // the actual array passed into qt_metacall + void **argv_pointer = nullptr; // in case we need an additional level of indirection + QVariant *varp = nullptr; // QVariants to hold the temporary Qt data object for us if (totalParam) { if (totalParam <= QAX_NUM_PARAMS) { @@ -2503,7 +2483,7 @@ HRESULT WINAPI QAxServerBase::Invoke(DISPID dispidMember, REFIID riid, varp = new QVariant[pcount + 1]; } - argv_pointer[0] = 0; + argv_pointer[0] = nullptr; } for (UINT p = 0; p < pcount; ++p) { @@ -2511,7 +2491,7 @@ HRESULT WINAPI QAxServerBase::Invoke(DISPID dispidMember, REFIID riid, bool out; QByteArray ptype = paramType(ptypes.at(int(p)), &out); varp[p + 1] = VARIANTToQVariant(pDispParams->rgvarg[pcount - p - 1], ptype); - argv_pointer[p + 1] = 0; + argv_pointer[p + 1] = nullptr; if (varp[p + 1].isValid()) { if (varp[p + 1].type() == QVariant::UserType) { argv[p + 1] = varp[p + 1].data(); @@ -2639,15 +2619,15 @@ HRESULT WINAPI QAxServerBase::Invoke(DISPID dispidMember, REFIID riid, if (m_spAdviseSink || adviseSinks.count()) { FORMATETC fmt; fmt.cfFormat = 0; - fmt.ptd = 0; + fmt.ptd = nullptr; fmt.dwAspect = DVASPECT_CONTENT; fmt.lindex = -1; fmt.tymed = TYMED_NULL; STGMEDIUM stg; stg.tymed = TYMED_NULL; - stg.pUnkForRelease = 0; - stg.hBitmap = 0; // initializes the whole union + stg.pUnkForRelease = nullptr; + stg.hBitmap = nullptr; // initializes the whole union if (m_spAdviseSink) { m_spAdviseSink->OnViewChange(DVASPECT_CONTENT, -1); @@ -2689,9 +2669,10 @@ HRESULT WINAPI QAxServerBase::Invoke(DISPID dispidMember, REFIID riid, } } delete exception; - exception = 0; + exception = nullptr; return DISP_E_EXCEPTION; - } else if (isWidget) { + } + if (isWidget) { if (oldSizeHint != qt.widget->sizeHint()) { updateGeometry(); if (m_spInPlaceSite) { @@ -2897,7 +2878,7 @@ HRESULT WINAPI QAxServerBase::Load(IStorage *pStg) if (InitNew(pStg) != S_OK) return CO_E_ALREADYINITIALIZED; - IStream *spStream = 0; + IStream *spStream = nullptr; QString streamName = QLatin1String(qt.object->metaObject()->className()); streamName.replace(QLatin1Char(':'), QLatin1Char('.')); /* Also invalid, but not relevant @@ -2906,9 +2887,9 @@ HRESULT WINAPI QAxServerBase::Load(IStorage *pStg) */ streamName += QLatin1String("_Stream4.2"); - pStg->OpenStream(reinterpret_cast<const wchar_t *>(streamName.utf16()), 0, STGM_READ | STGM_SHARE_EXCLUSIVE, 0, &spStream); + pStg->OpenStream(reinterpret_cast<const wchar_t *>(streamName.utf16()), nullptr, STGM_READ | STGM_SHARE_EXCLUSIVE, 0, &spStream); if (!spStream) // support for streams saved with 4.1 and earlier - pStg->OpenStream(L"SomeStreamName", 0, STGM_READ | STGM_SHARE_EXCLUSIVE, 0, &spStream); + pStg->OpenStream(L"SomeStreamName", nullptr, STGM_READ | STGM_SHARE_EXCLUSIVE, 0, &spStream); if (!spStream) return E_FAIL; @@ -2920,7 +2901,7 @@ HRESULT WINAPI QAxServerBase::Load(IStorage *pStg) HRESULT WINAPI QAxServerBase::Save(IStorage *pStg, BOOL /* fSameAsLoad */) { - IStream *spStream = 0; + IStream *spStream = nullptr; QString streamName = QLatin1String(qt.object->metaObject()->className()); streamName.replace(QLatin1Char(':'), QLatin1Char('.')); /* Also invalid, but not relevant @@ -2953,7 +2934,7 @@ HRESULT WINAPI QAxServerBase::SaveCompleted(IStorage *pStgNew) HRESULT WINAPI QAxServerBase::HandsOffStorage() { if (m_spStorage) m_spStorage->Release(); - m_spStorage = 0; + m_spStorage = nullptr; return S_OK; } @@ -2993,7 +2974,7 @@ HRESULT WINAPI QAxServerBase::Load(IPropertyBag *bag, IErrorLog * /*log*/) BSTR bstr = QStringToBSTR(QLatin1String(pname)); VARIANT var; var.vt = VT_EMPTY; - HRESULT res = bag->Read(bstr, &var, 0); + HRESULT res = bag->Read(bstr, &var, nullptr); if (property.isWritable() && var.vt != VT_EMPTY) { if (res != S_OK || !qt.object->setProperty(pname, VARIANTToQVariant(var, property.typeName(), property.type()))) error = true; @@ -3057,10 +3038,10 @@ HRESULT WINAPI QAxServerBase::GetCurFile(LPOLESTR *currentFile) return E_NOTIMPL; if (currentFileName.isEmpty()) { - *currentFile = 0; + *currentFile = nullptr; return S_FALSE; } - IMalloc *malloc = 0; + IMalloc *malloc = nullptr; CoGetMalloc(1, &malloc); if (!malloc) return E_OUTOFMEMORY; @@ -3186,22 +3167,22 @@ HRESULT WINAPI QAxServerBase::Draw(DWORD dwAspect, LONG /* lindex */, void * /* return DV_E_DVASPECT; } if (!ptd) - hicTargetDev = 0; + hicTargetDev = nullptr; bool bDeleteDC = false; if (!hicTargetDev) { - hicTargetDev = ::CreateDC(L"DISPLAY", NULL, NULL, NULL); + hicTargetDev = ::CreateDC(L"DISPLAY", nullptr, nullptr, nullptr); bDeleteDC = (hicTargetDev != hdcDraw); } RECTL rc = *lprcBounds; bool bMetaFile = GetDeviceCaps(hdcDraw, TECHNOLOGY) == DT_METAFILE; if (!bMetaFile) - ::LPtoDP(hicTargetDev, (LPPOINT)&rc, 2); + ::LPtoDP(hicTargetDev, reinterpret_cast<LPPOINT>(&rc), 2); const QPixmap pm = qt.widget->grab(); HBITMAP hbm = qt_pixmapToWinHBITMAP(pm); - HDC hdc = CreateCompatibleDC(0); + HDC hdc = CreateCompatibleDC(nullptr); SelectObject(hdc, hbm); ::StretchBlt(hdcDraw, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, hdc, 0, 0,pm.width(), pm.height(), SRCCOPY); DeleteDC(hdc); @@ -3315,17 +3296,17 @@ HRESULT WINAPI QAxServerBase::OnAmbientPropertyChange(DISPID dispID) if (!m_spClientSite || !theObject) return S_OK; - IDispatch *disp = 0; + IDispatch *disp = nullptr; m_spClientSite->QueryInterface(IID_IDispatch, reinterpret_cast<void **>(&disp)); if (!disp) return S_OK; VARIANT var; VariantInit(&var); - DISPPARAMS params = { 0, 0, 0, 0 }; - disp->Invoke(dispID, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_PROPERTYGET, ¶ms, &var, 0, 0); + DISPPARAMS params = { nullptr, nullptr, 0, 0 }; + disp->Invoke(dispID, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_PROPERTYGET, ¶ms, &var, nullptr, nullptr); disp->Release(); - disp = 0; + disp = nullptr; switch(dispID) { case DISPID_AMBIENT_APPEARANCE: @@ -3446,7 +3427,7 @@ HRESULT WINAPI QAxServerBase::InPlaceDeactivate() if (m_hWnd) { if (::IsWindow(m_hWnd)) ::DestroyWindow(m_hWnd); - m_hWnd = 0; + m_hWnd = nullptr; } if (m_spInPlaceSite) @@ -3470,32 +3451,32 @@ HRESULT WINAPI QAxServerBase::UIDeactivate() HWND hwndParent; if (m_spInPlaceSite->GetWindow(&hwndParent) == S_OK) { if (m_spInPlaceFrame) m_spInPlaceFrame->Release(); - m_spInPlaceFrame = 0; - IOleInPlaceUIWindow *spInPlaceUIWindow = 0; + m_spInPlaceFrame = nullptr; + IOleInPlaceUIWindow *spInPlaceUIWindow = nullptr; RECT rcPos, rcClip; OLEINPLACEFRAMEINFO frameInfo; frameInfo.cb = sizeof(OLEINPLACEFRAMEINFO); m_spInPlaceSite->GetWindowContext(&m_spInPlaceFrame, &spInPlaceUIWindow, &rcPos, &rcClip, &frameInfo); if (spInPlaceUIWindow) { - spInPlaceUIWindow->SetActiveObject(0, 0); + spInPlaceUIWindow->SetActiveObject(nullptr, nullptr); spInPlaceUIWindow->Release(); } if (m_spInPlaceFrame) { removeMenu(); if (menuBar) { menuBar->removeEventFilter(this); - menuBar = 0; + menuBar = nullptr; } if (statusBar) { statusBar->removeEventFilter(this); const int index = statusBar->metaObject()->indexOfSignal("messageChanged(QString)"); QMetaObject::disconnect(statusBar, index, this, STATUSBAR_MESSAGE_CHANGED_SLOT_INDEX); - statusBar = 0; + statusBar = nullptr; } - m_spInPlaceFrame->SetActiveObject(0, 0); + m_spInPlaceFrame->SetActiveObject(nullptr, nullptr); m_spInPlaceFrame->Release(); - m_spInPlaceFrame = 0; + m_spInPlaceFrame = nullptr; } } // we don't need to explicitly release the focus here since somebody @@ -3510,21 +3491,21 @@ HRESULT WINAPI QAxServerBase::UIDeactivate() */ HRESULT WINAPI QAxServerBase::SetObjectRects(LPCRECT prcPos, LPCRECT prcClip) { - if (prcPos == 0 || prcClip == 0) + if (prcPos == nullptr || prcClip == nullptr) return E_POINTER; if (m_hWnd) { // the container wants us to clip, so figure out if we really need to RECT rcIXect; BOOL b = IntersectRect(&rcIXect, prcPos, prcClip); - HRGN tempRgn = 0; + HRGN tempRgn = nullptr; if (b && !EqualRect(&rcIXect, prcPos)) { OffsetRect(&rcIXect, -(prcPos->left), -(prcPos->top)); tempRgn = CreateRectRgnIndirect(&rcIXect); } ::SetWindowRgn(m_hWnd, tempRgn, true); - ::SetWindowPos(m_hWnd, 0, prcPos->left, prcPos->top, + ::SetWindowPos(m_hWnd, nullptr, prcPos->left, prcPos->top, prcPos->right - prcPos->left, prcPos->bottom - prcPos->top, SWP_NOZORDER | SWP_NOACTIVATE); } @@ -3572,10 +3553,10 @@ HRESULT WINAPI QAxServerBase::TranslateAcceleratorW(MSG *pMsg) if (shift) { if (!curFocus->isWindow()) { QWidget *nextFocus = curFocus->nextInFocusChain(); - QWidget *topLevel = 0; + QWidget *topLevel = nullptr; while (nextFocus != curFocus) { if (nextFocus->focusPolicy() & Qt::TabFocus) { - topLevel = 0; + topLevel = nullptr; } else if (nextFocus->isWindow()) { topLevel = nextFocus; } @@ -3648,7 +3629,7 @@ HRESULT WINAPI QAxServerBase::TranslateAcceleratorW(MSG *pMsg) if (!m_spClientSite) return S_FALSE; - IOleControlSite *controlSite = 0; + IOleControlSite *controlSite = nullptr; m_spClientSite->QueryInterface(IID_IOleControlSite, reinterpret_cast<void **>(&controlSite)); if (!controlSite) return S_FALSE; @@ -3764,7 +3745,7 @@ HRESULT WINAPI QAxServerBase::GetMiscStatus(DWORD dwAspect, DWORD *pdwStatus) HRESULT WINAPI QAxServerBase::Advise(IAdviseSink* pAdvSink, DWORD* pdwConnection) { *pdwConnection = DWORD(adviseSinks.count()) + 1; - STATDATA data = { {0, 0, DVASPECT_CONTENT, -1, TYMED_NULL} , 0, pAdvSink, *pdwConnection }; + STATDATA data = { {0, nullptr, DVASPECT_CONTENT, -1, TYMED_NULL} , 0, pAdvSink, *pdwConnection }; adviseSinks.append(data); pAdvSink->AddRef(); return S_OK; @@ -3785,16 +3766,16 @@ HRESULT WINAPI QAxServerBase::Close(DWORD dwSaveOption) if (m_hWnd) { if (IsWindow(m_hWnd)) DestroyWindow(m_hWnd); - m_hWnd = 0; + m_hWnd = nullptr; if (m_spClientSite) m_spClientSite->OnShowWindow(false); } if (m_spInPlaceSiteWindowless) m_spInPlaceSiteWindowless->Release(); - m_spInPlaceSiteWindowless = 0; + m_spInPlaceSiteWindowless = nullptr; if (m_spInPlaceSite) m_spInPlaceSite->Release(); - m_spInPlaceSite = 0; + m_spInPlaceSite = nullptr; if (m_spAdviseSink) m_spAdviseSink->OnClose(); @@ -3833,12 +3814,12 @@ HRESULT QAxServerBase::internalActivate() OnAmbientPropertyChange(DISPID_AMBIENT_USERMODE); if (isWidget) { - IOleInPlaceUIWindow *spInPlaceUIWindow = 0; + IOleInPlaceUIWindow *spInPlaceUIWindow = nullptr; HWND hwndParent; if (m_spInPlaceSite->GetWindow(&hwndParent) == S_OK) { // get location in the parent window, as well as some information about the parent if (m_spInPlaceFrame) m_spInPlaceFrame->Release(); - m_spInPlaceFrame = 0; + m_spInPlaceFrame = nullptr; RECT rcPos, rcClip; OLEINPLACEFRAMEINFO frameInfo; frameInfo.cb = sizeof(OLEINPLACEFRAMEINFO); @@ -3871,7 +3852,7 @@ HRESULT QAxServerBase::internalActivate() hr = m_spInPlaceSite->OnUIActivate(); if (FAILED(hr)) { if (m_spInPlaceFrame) m_spInPlaceFrame->Release(); - m_spInPlaceFrame = 0; + m_spInPlaceFrame = nullptr; if (spInPlaceUIWindow) spInPlaceUIWindow->Release(); return hr; } @@ -3901,7 +3882,7 @@ HRESULT QAxServerBase::internalActivate() } if (spInPlaceUIWindow) { spInPlaceUIWindow->SetActiveObject(this, reinterpret_cast<const wchar_t *>(class_name.utf16())); - spInPlaceUIWindow->SetBorderSpace(0); + spInPlaceUIWindow->SetBorderSpace(nullptr); } } if (spInPlaceUIWindow) spInPlaceUIWindow->Release(); @@ -4055,11 +4036,11 @@ HRESULT WINAPI QAxServerBase::SetClientSite(IOleClientSite* pClientSite) if (m_spClientSite) m_spClientSite->Release(); if (m_spInPlaceSiteWindowless) m_spInPlaceSiteWindowless->Release(); - m_spInPlaceSiteWindowless = 0; + m_spInPlaceSiteWindowless = nullptr; if (m_spInPlaceSite) m_spInPlaceSite->Release(); - m_spInPlaceSite = 0; + m_spInPlaceSite = nullptr; if (m_spInPlaceFrame) m_spInPlaceFrame->Release(); - m_spInPlaceFrame = 0; + m_spInPlaceFrame = nullptr; m_spClientSite = pClientSite; if (m_spClientSite) { @@ -4171,7 +4152,7 @@ HRESULT WINAPI QAxServerBase::GetData(FORMATETC *pformatetcIn, STGMEDIUM *pmediu // Container wants to draw, but the size is not defined yet - ask container if (m_spInPlaceSite && !qt.widget->testAttribute(Qt::WA_Resized)) { - IOleInPlaceUIWindow *spInPlaceUIWindow = 0; + IOleInPlaceUIWindow *spInPlaceUIWindow = nullptr; RECT rcPos, rcClip; OLEINPLACEFRAMEINFO frameInfo; frameInfo.cb = sizeof(OLEINPLACEFRAMEINFO); @@ -4189,12 +4170,12 @@ HRESULT WINAPI QAxServerBase::GetData(FORMATETC *pformatetcIn, STGMEDIUM *pmediu int height = qt.widget->height(); RECTL rectl = {0, 0, width, height}; - HDC hdc = CreateMetaFile(0); + HDC hdc = CreateMetaFile(nullptr); SaveDC(hdc); - SetWindowOrgEx(hdc, 0, 0, 0); - SetWindowExtEx(hdc, rectl.right, rectl.bottom, 0); + SetWindowOrgEx(hdc, 0, 0, nullptr); + SetWindowExtEx(hdc, rectl.right, rectl.bottom, nullptr); - Draw(pformatetcIn->dwAspect, pformatetcIn->lindex, 0, pformatetcIn->ptd, 0, hdc, &rectl, &rectl, 0, 0); + Draw(pformatetcIn->dwAspect, pformatetcIn->lindex, nullptr, pformatetcIn->ptd, nullptr, hdc, &rectl, &rectl, nullptr, 0); RestoreDC(hdc, -1); HMETAFILE hMF = CloseMetaFile(hdc); @@ -4218,7 +4199,7 @@ HRESULT WINAPI QAxServerBase::GetData(FORMATETC *pformatetcIn, STGMEDIUM *pmediu memset(pmedium, 0, sizeof(STGMEDIUM)); pmedium->tymed = TYMED_MFPICT; pmedium->hGlobal = hMem; - pmedium->pUnkForRelease = 0; + pmedium->pUnkForRelease = nullptr; return S_OK; } @@ -4350,7 +4331,7 @@ bool QAxServerBase::eventFilter(QObject *o, QEvent *e) int key = ke->key(); int state = ke->modifiers(); void *argv[] = { - 0, + nullptr, &key, &state }; @@ -4365,7 +4346,7 @@ bool QAxServerBase::eventFilter(QObject *o, QEvent *e) int key = ke->key(); int state = ke->modifiers(); void *argv[] = { - 0, + nullptr, &key, &state }; @@ -4380,7 +4361,7 @@ bool QAxServerBase::eventFilter(QObject *o, QEvent *e) int x = me->x(); int y = me->y(); void *argv[] = { - 0, + nullptr, &button, &state, &x, @@ -4397,19 +4378,19 @@ bool QAxServerBase::eventFilter(QObject *o, QEvent *e) int x = me->x(); int y = me->y(); void *argv[] = { - 0, + nullptr, &button, &state, &x, &y }; qt_metacall(QMetaObject::InvokeMetaMethod, DISPID_MOUSEUP, argv); - qt_metacall(QMetaObject::InvokeMetaMethod, DISPID_CLICK, 0); + qt_metacall(QMetaObject::InvokeMetaMethod, DISPID_CLICK, nullptr); } break; case QEvent::MouseButtonDblClick: if (o == qt.object && hasStockEvents) { - qt_metacall(QMetaObject::InvokeMetaMethod, DISPID_DBLCLICK, 0); + qt_metacall(QMetaObject::InvokeMetaMethod, DISPID_DBLCLICK, nullptr); } break; case QEvent::MouseButtonPress: @@ -4423,7 +4404,7 @@ bool QAxServerBase::eventFilter(QObject *o, QEvent *e) int x = me->x(); int y = me->y(); void *argv[] = { - 0, + nullptr, &button, &state, &x, @@ -4462,7 +4443,7 @@ bool QAxServerBase::eventFilter(QObject *o, QEvent *e) // Visual Basic 6.0 posts the message WM_USER+3078 from the EnableModeless(). // While handling this message, VB will disable all current top-levels. After // this we have to re-enable the Qt modal widget to receive input events. - if (PeekMessage(&msg, 0, WM_USER+3078, WM_USER+3078, PM_REMOVE)) { + if (PeekMessage(&msg, nullptr, WM_USER+3078, WM_USER+3078, PM_REMOVE)) { TranslateMessage(&msg); DispatchMessage(&msg); // FIXME: 4.10.2011 Does this work with the parent's HWND? diff --git a/src/activeqt/control/qaxserverdll.cpp b/src/activeqt/control/qaxserverdll.cpp index 06fe6b9..c1e6767 100644 --- a/src/activeqt/control/qaxserverdll.cpp +++ b/src/activeqt/control/qaxserverdll.cpp @@ -60,7 +60,7 @@ QT_BEGIN_NAMESPACE bool qax_ownQApp = false; -HHOOK qax_hhook = 0; +HHOOK qax_hhook = nullptr; // in qaxserver.cpp extern wchar_t qAxModuleFilename[MAX_PATH]; @@ -72,17 +72,34 @@ extern void qAxCleanup(); extern HANDLE qAxInstance; static uint qAxThreadId = 0; -extern HRESULT UpdateRegistry(int bRegister); +extern HRESULT UpdateRegistry(bool bRegister, bool perUser); extern HRESULT GetClassObject(const GUID &clsid, const GUID &iid, void **ppUnk); STDAPI DllRegisterServer() { - return UpdateRegistry(true); + return UpdateRegistry(true, false); } STDAPI DllUnregisterServer() { - return UpdateRegistry(false); + return UpdateRegistry(false, false); +} + +STDAPI DllInstall(BOOL bInstall, LPCWSTR pszCmdLine) { + bool perUser = false; // per-user (un)registration + if (pszCmdLine) { + if (QStringView(pszCmdLine).compare(u"user", Qt::CaseInsensitive) == 0) + perUser = true; + } + + if (bInstall) { + HRESULT hr = UpdateRegistry(true, perUser); + if (FAILED(hr)) + UpdateRegistry(false, perUser); + return hr; + } else { + return UpdateRegistry(false, perUser); + } } STDAPI DllGetClassObject(const GUID &clsid, const GUID &iid, void** ppv) diff --git a/src/activeqt/control/qaxservermain.cpp b/src/activeqt/control/qaxservermain.cpp index 5ad97d8..764899d 100644 --- a/src/activeqt/control/qaxservermain.cpp +++ b/src/activeqt/control/qaxservermain.cpp @@ -59,7 +59,7 @@ QT_BEGIN_NAMESPACE -static DWORD *classRegistration = 0; +static DWORD *classRegistration = nullptr; static DWORD dwThreadID; static bool qAxActivity = false; static HANDLE hEventShutdown; @@ -72,15 +72,13 @@ static const DWORD dwTimeOut = 5000; // time for EXE to be idle before shutting static const DWORD dwPause = 1000; // time to wait for threads to finish up #endif -extern HANDLE hEventShutdown; -extern bool qAxActivity; extern HANDLE qAxInstance; extern bool qAxIsServer; extern bool qAxOutProcServer; extern wchar_t qAxModuleFilename[MAX_PATH]; extern QString qAxInit(); extern void qAxCleanup(); -extern HRESULT UpdateRegistry(BOOL bRegister); +extern HRESULT UpdateRegistry(bool bRegister, bool perUser); extern HRESULT GetClassObject(const GUID &clsid, const GUID &iid, void **ppUnk); extern ulong qAxLockCount(); extern bool qax_winEventFilter(void *message); @@ -90,7 +88,7 @@ STDAPI DumpIDL(const QString &outfile, const QString &ver); // Monitors the shutdown event static DWORD WINAPI MonitorProc(void* /* pv */) { - while (1) { + while (true) { WaitForSingleObject(hEventShutdown, INFINITE); DWORD dwWait=0; do { @@ -112,12 +110,12 @@ static DWORD WINAPI MonitorProc(void* /* pv */) static bool StartMonitor() { dwThreadID = GetCurrentThreadId(); - hEventShutdown = CreateEvent(0, false, false, 0); - if (hEventShutdown == 0) + hEventShutdown = CreateEvent(nullptr, false, false, nullptr); + if (hEventShutdown == nullptr) return false; DWORD dwThreadID; - HANDLE h = CreateThread(0, 0, MonitorProc, 0, 0, &dwThreadID); - return (h != NULL); + HANDLE h = CreateThread(nullptr, 0, MonitorProc, nullptr, 0, &dwThreadID); + return (h != nullptr); } void qax_shutDown() @@ -146,7 +144,7 @@ bool qax_startServer(QAxFactory::ServerType type) classRegistration = new DWORD[keyCount]; int object = 0; for (object = 0; object < keyCount; ++object) { - IUnknown* p = 0; + IUnknown* p = nullptr; CLSID clsid = qAxFactory()->classID(keys.at(object)); // Create a QClassFactory (implemented in qaxserverbase.cpp) @@ -178,7 +176,7 @@ bool qax_stopServer() CoRevokeClassObject(classRegistration[object]); delete []classRegistration; - classRegistration = 0; + classRegistration = nullptr; Sleep(dwPause); //wait for any threads to finish @@ -239,7 +237,7 @@ EXTERN_C int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE /* hPrevInstance */, QT_USE_NAMESPACE qAxOutProcServer = true; - GetModuleFileName(0, qAxModuleFilename, MAX_PATH); + GetModuleFileName(nullptr, qAxModuleFilename, MAX_PATH); qAxInstance = hInstance; const QStringList cmds = commandLineArguments(); @@ -254,11 +252,19 @@ EXTERN_C int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE /* hPrevInstance */, if (matchesOption(cmd, "activex") || matchesOption(cmd, "embedding")) { runServer = true; } else if (matchesOption(cmd, "unregserver")) { - nRet = UpdateRegistry(false); + nRet = UpdateRegistry(false, false); run = false; break; } else if (matchesOption(cmd, "regserver")) { - nRet = UpdateRegistry(true); + nRet = UpdateRegistry(true, false); + run = false; + break; + } else if (matchesOption(cmd, "unregserverperuser")) { + nRet = UpdateRegistry(false, true); + run = false; + break; + } else if (matchesOption(cmd, "regserverperuser")) { + nRet = UpdateRegistry(true, true); run = false; break; } else if (matchesOption(cmd, "dumpidl")) { @@ -287,7 +293,7 @@ EXTERN_C int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE /* hPrevInstance */, } if (run) { - if (SUCCEEDED(CoInitializeEx(0, COINIT_APARTMENTTHREADED))) { + if (SUCCEEDED(CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED))) { #ifdef Q_CC_MINGW // define GlobalOptions class ID locally for MinGW, since it's missing from the distribution static const CLSID CLSID_GlobalOptions = @@ -296,7 +302,7 @@ EXTERN_C int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE /* hPrevInstance */, // Disable C++ & SEH exception handling by the COM runtime for out-of-process COM controls. // Done to prevent silent crashes and enable crash dump generation. IGlobalOptions *globalOptions = nullptr; - if (SUCCEEDED(CoCreateInstance(CLSID_GlobalOptions, NULL, CLSCTX_INPROC_SERVER, + if (SUCCEEDED(CoCreateInstance(CLSID_GlobalOptions, nullptr, CLSCTX_INPROC_SERVER, IID_IGlobalOptions, reinterpret_cast<void **>(&globalOptions)))) { globalOptions->Set(COMGLB_EXCEPTION_HANDLING, COMGLB_EXCEPTION_DONOT_HANDLE_ANY); globalOptions->Release(); diff --git a/src/activeqt/control/qclassfactory_p.h b/src/activeqt/control/qclassfactory_p.h index 86fea60..7133dfc 100644 --- a/src/activeqt/control/qclassfactory_p.h +++ b/src/activeqt/control/qclassfactory_p.h @@ -71,7 +71,7 @@ QT_BEGIN_NAMESPACE // One instance of this class for each ActiveX the server can provide. class QClassFactory : public IClassFactory2 { - Q_DISABLE_COPY(QClassFactory) + Q_DISABLE_COPY_MOVE(QClassFactory) public: QClassFactory(CLSID clsid); @@ -102,8 +102,8 @@ public: protected: CRITICAL_SECTION refCountSection; - LONG ref; - bool licensed; + LONG ref = 0; + bool licensed = false; QString classKey; }; diff --git a/src/activeqt/doc/src/qtaxserver.qdoc b/src/activeqt/doc/src/qtaxserver.qdoc index c9f4adc..f73f41d 100644 --- a/src/activeqt/doc/src/qtaxserver.qdoc +++ b/src/activeqt/doc/src/qtaxserver.qdoc @@ -497,7 +497,11 @@ \table \header \li Option \li Result \row \li \c -regserver \li Registers the server in the system registry + \row \li \c -regserverperuser \li Registers the server in the system + registry for the current user (since 5.14) \row \li \c -unregserver \li Unregisters the server from the system registry + \row \li \c -unregserverperuser \li Unregisters the server from the + system registry for the current user (since 5.14) \row \li \c -activex \li Starts the application as an ActiveX server \row \li \c{-dumpidl <file> -version x.y} \li Writes the server's IDL to the specified file. The type library will have version x.y @@ -513,9 +517,9 @@ \section3 "No overloaded function takes 2 parameters" - When the error occurs in code that uses the QAXFACTORY_DEFAULT() - macro, the widget class had no constructor that can be used by the - default factory. Either add a standard widget constructor or + When the error occurs in code that uses the QAXCLASS() or + QAXFACTORY_DEFAULT() macro, the widget class had no constructor that can be + used by the default factory. Either add a standard widget constructor or implement a custom factory that doesn't require one. When the error occurs in code that uses the QAXFACTORY_EXPORT() @@ -529,21 +533,21 @@ \section3 "Syntax error: bad suffix on number" The unique identifiers have not been passed as strings into the - QAXFACTORY_EXPORT() or QAXFACTORY_DEFAULT() macro. + QAXFACTORY_EXPORT(), QAXFACTORY_BEGIN() or QAXFACTORY_DEFAULT() macro. \section3 "Unresolved external symbol _ucm_instantiate" The server does not export an implementation of a QAxFactory. Use the QAXFACTORY_EXPORT() macro in one of the project's implementation files to instantiate and export a factory, or use - the QAXFACTORY_DEFAULT() macro to use the default factory. + the QAXCLASS() or QAXFACTORY_DEFAULT() macro to use the default factory. \section3 "_ucm_initialize already defined in ..." The server exports more than one implementation of a QAxFactory, or exports the same implementation twice. If you use the default - factory, the QAXFACTORY_DEFAULT() macro must only be used once in - the project. Use a custom QAxFactory implementation and the + factory, the QAXFACTORY_BEGIN() or QAXFACTORY_DEFAULT() macro must only be + used once in the project. Use a custom QAxFactory implementation and the QAXFACTORY_EXPORT() macro if the server provides multiple ActiveX controls. diff --git a/src/activeqt/shared/qaxtypes.cpp b/src/activeqt/shared/qaxtypes.cpp index 6146c83..b3d422b 100644 --- a/src/activeqt/shared/qaxtypes.cpp +++ b/src/activeqt/shared/qaxtypes.cpp @@ -100,10 +100,10 @@ static IFontDisp *QFontToIFont(const QFont &font) fdesc.sWeight = font.weight() * 10; IFontDisp *f; - HRESULT res = OleCreateFontIndirect(&fdesc, IID_IFontDisp, (void**)&f); + HRESULT res = OleCreateFontIndirect(&fdesc, IID_IFontDisp, reinterpret_cast<void**>(&f)); if (res != S_OK) { if (f) f->Release(); - f = 0; + f = nullptr; #if defined(QT_CHECK_STATE) qWarning("QFontToIFont: Failed to create IFont"); #endif @@ -143,24 +143,24 @@ Q_GUI_EXPORT QPixmap qt_pixmapFromWinHBITMAP(HBITMAP bitmap, int hbitmapFormat = static IPictureDisp *QPixmapToIPicture(const QPixmap &pixmap) { - IPictureDisp *pic = 0; + IPictureDisp *pic = nullptr; PICTDESC desc; desc.cbSizeofstruct = sizeof(PICTDESC); desc.picType = PICTYPE_BITMAP; - desc.bmp.hbitmap = 0; - desc.bmp.hpal = 0; + desc.bmp.hbitmap = nullptr; + desc.bmp.hpal = nullptr; if (!pixmap.isNull()) { desc.bmp.hbitmap = qt_pixmapToWinHBITMAP(pixmap); Q_ASSERT(desc.bmp.hbitmap); } - HRESULT res = OleCreatePictureIndirect(&desc, IID_IPictureDisp, true, (void**)&pic); + HRESULT res = OleCreatePictureIndirect(&desc, IID_IPictureDisp, true, reinterpret_cast<void**>(&pic)); if (res != S_OK) { if (pic) pic->Release(); - pic = 0; + pic = nullptr; #if defined(QT_CHECK_STATE) qWarning("QPixmapToIPicture: Failed to create IPicture"); #endif @@ -175,8 +175,8 @@ static QPixmap IPictureToQPixmap(IPicture *ipic) if (type != PICTYPE_BITMAP) return QPixmap(); - HBITMAP hbm = 0; - ipic->get_Handle((OLE_HANDLE*)&hbm); + HBITMAP hbm = nullptr; + ipic->get_Handle(reinterpret_cast<OLE_HANDLE*>(&hbm)); if (!hbm) return QPixmap(); @@ -186,7 +186,7 @@ static QPixmap IPictureToQPixmap(IPicture *ipic) static QDateTime DATEToQDateTime(DATE ole) { SYSTEMTIME stime; - if (ole >= 949998 || VariantTimeToSystemTime(ole, &stime) == false) + if (ole >= 949998 || !VariantTimeToSystemTime(ole, &stime)) return QDateTime(); QDate date(stime.wYear, stime.wMonth, stime.wDay); @@ -475,7 +475,7 @@ bool QVariantToVARIANT(const QVariant &var, VARIANT &arg, const QByteArray &type default: break; } - SAFEARRAY *array = 0; + SAFEARRAY *array = nullptr; bool is2D = false; // If the first element in the array is a list the whole list is // treated as a 2D array. The column count is taken from the 1st element. @@ -494,7 +494,7 @@ bool QVariantToVARIANT(const QVariant &var, VARIANT &arg, const QByteArray &type QVariantList columns = list.at(i).toList(); int columnCount = qMin(maxColumns, columns.count()); for (LONG j = 0; j < columnCount; ++j) { - QVariant elem = columns.at(j); + const QVariant &elem = columns.at(j); VariantInit(&variant); QVariantToVARIANT(elem, variant, elem.typeName()); rgIndices[1] = j; @@ -567,7 +567,7 @@ bool QVariantToVARIANT(const QVariant &var, VARIANT &arg, const QByteArray &type if (count) { const char *data = bytes.constData(); char *dest; - SafeArrayAccessData(array, (void **)&dest); + SafeArrayAccessData(array, reinterpret_cast<void**>(&dest)); memcpy(dest, data, count); SafeArrayUnaccessData(array); } @@ -667,12 +667,12 @@ bool QVariantToVARIANT(const QVariant &var, VARIANT &arg, const QByteArray &type return false; } arg.vt = VT_DISPATCH; - arg.pdispVal = *(IDispatch**)qvar.data(); + arg.pdispVal = *static_cast<IDispatch**>(qvar.data()); if (arg.pdispVal) arg.pdispVal->AddRef(); } else if (!qstrcmp(qvar.typeName(), "IDispatch**")) { arg.vt = VT_DISPATCH; - arg.ppdispVal = *(IDispatch***)qvar.data(); + arg.ppdispVal = *static_cast<IDispatch***>(qvar.data()); if (out) arg.vt |= VT_BYREF; } else if (!qstrcmp(qvar.typeName(), "IUnknown*")) { @@ -683,7 +683,7 @@ bool QVariantToVARIANT(const QVariant &var, VARIANT &arg, const QByteArray &type return false; } arg.vt = VT_UNKNOWN; - arg.punkVal = *(IUnknown**)qvar.data(); + arg.punkVal = *static_cast<IUnknown**>(qvar.data()); if (arg.punkVal) arg.punkVal->AddRef(); #ifdef QAX_SERVER @@ -710,10 +710,10 @@ bool QVariantToVARIANT(const QVariant &var, VARIANT &arg, const QByteArray &type arg.byref = nullptr; return false; } - QAxObject *object = *(QAxObject**)qvar.constData(); + QAxObject *object = *static_cast<QAxObject**>(qvar.data()); // qVariantGet(qvar, object, subType); arg.vt = VT_DISPATCH; - object->queryInterface(IID_IDispatch, (void**)&arg.pdispVal); + object->queryInterface(IID_IDispatch, reinterpret_cast<void**>(&arg.pdispVal)); #endif } else { return false; @@ -917,15 +917,15 @@ QVariant VARIANTToQVariant(const VARIANT &arg, const QByteArray &typeName, uint case VT_DISPATCH|VT_BYREF: { // pdispVal and ppdispVal are a union - IDispatch *disp = 0; + IDispatch *disp = nullptr; if (arg.vt & VT_BYREF) disp = *arg.ppdispVal; else disp = arg.pdispVal; if (type == QVariant::Font || (!type && (typeName == "QFont" || typeName == "QFont*"))) { - IFont *ifont = 0; + IFont *ifont = nullptr; if (disp) - disp->QueryInterface(IID_IFont, (void**)&ifont); + disp->QueryInterface(IID_IFont, reinterpret_cast<void**>(&ifont)); if (ifont) { var = QVariant::fromValue(IFontToQFont(ifont)); ifont->Release(); @@ -933,9 +933,9 @@ QVariant VARIANTToQVariant(const VARIANT &arg, const QByteArray &typeName, uint var = QVariant::fromValue(QFont()); } } else if (type == QVariant::Pixmap || (!type && (typeName == "QPixmap" || typeName == "QPixmap*"))) { - IPicture *ipic = 0; + IPicture *ipic = nullptr; if (disp) - disp->QueryInterface(IID_IPicture, (void**)&ipic); + disp->QueryInterface(IID_IPicture, reinterpret_cast<void**>(&ipic)); if (ipic) { var = QVariant::fromValue(IPictureToQPixmap(ipic)); ipic->Release(); @@ -946,7 +946,7 @@ QVariant VARIANTToQVariant(const VARIANT &arg, const QByteArray &typeName, uint #ifdef QAX_SERVER IAxServerBase *iface = 0; if (disp && typeName != "IDispatch*") - disp->QueryInterface(IID_IAxServerBase, (void**)&iface); + disp->QueryInterface(IID_IAxServerBase, reinterpret_cast<void**>(&iface)); if (iface) { QObject *qObj = iface->qObject(); iface->Release(); @@ -973,7 +973,7 @@ QVariant VARIANTToQVariant(const VARIANT &arg, const QByteArray &typeName, uint typeNameStr = typeName.left(pIndex); int metaType = QMetaType::type(typeNameStr); Q_ASSERT(metaType != 0); - QAxObject *object = (QAxObject*)qax_createObjectWrapper(metaType, disp); + auto object = static_cast<QAxObject*>(qax_createObjectWrapper(metaType, disp)); var = QVariant(QMetaType::type(typeName), &object); } else #endif @@ -987,7 +987,7 @@ QVariant VARIANTToQVariant(const VARIANT &arg, const QByteArray &typeName, uint case VT_UNKNOWN: case VT_UNKNOWN|VT_BYREF: { - IUnknown *unkn = 0; + IUnknown *unkn = nullptr; if (arg.vt & VT_BYREF) unkn = *arg.ppunkVal; else @@ -998,7 +998,7 @@ QVariant VARIANTToQVariant(const VARIANT &arg, const QByteArray &typeName, uint case VT_ARRAY|VT_VARIANT: case VT_ARRAY|VT_VARIANT|VT_BYREF: { - SAFEARRAY *array = 0; + SAFEARRAY *array = nullptr; if ( arg.vt & VT_BYREF ) array = *arg.pparray; else @@ -1019,7 +1019,7 @@ QVariant VARIANTToQVariant(const VARIANT &arg, const QByteArray &typeName, uint VariantInit( &var ); SafeArrayGetElement( array, &i, &var ); - QVariant qvar = VARIANTToQVariant( var, 0 ); + QVariant qvar = VARIANTToQVariant( var, nullptr ); clearVARIANT( &var ); list << qvar; } @@ -1049,7 +1049,7 @@ QVariant VARIANTToQVariant(const VARIANT &arg, const QByteArray &typeName, uint dimIndices[1] = y; SafeArrayGetElement(array, dimIndices, &var); - QVariant qvar = VARIANTToQVariant(var, 0); + QVariant qvar = VARIANTToQVariant(var, nullptr); clearVARIANT(&var); list << qvar; } @@ -1069,7 +1069,7 @@ QVariant VARIANTToQVariant(const VARIANT &arg, const QByteArray &typeName, uint case VT_ARRAY|VT_BSTR: case VT_ARRAY|VT_BSTR|VT_BYREF: { - SAFEARRAY *array = 0; + SAFEARRAY *array = nullptr; if (arg.vt & VT_BYREF) array = *arg.pparray; else @@ -1099,7 +1099,7 @@ QVariant VARIANTToQVariant(const VARIANT &arg, const QByteArray &typeName, uint case VT_ARRAY|VT_UI1: case VT_ARRAY|VT_UI1|VT_BYREF: { - SAFEARRAY *array = 0; + SAFEARRAY *array = nullptr; if (arg.vt & VT_BYREF) array = *arg.pparray; else @@ -1119,7 +1119,7 @@ QVariant VARIANTToQVariant(const VARIANT &arg, const QByteArray &typeName, uint bytes.resize(uBound - lBound + 1); char *data = bytes.data(); char *src; - SafeArrayAccessData(array, (void**)&src); + SafeArrayAccessData(array, reinterpret_cast<void**>(&src)); memcpy(data, src, bytes.size()); SafeArrayUnaccessData(array); } @@ -1157,7 +1157,7 @@ QVariant VARIANTToQVariant(const VARIANT &arg, const QByteArray &typeName, uint // support for any SAFEARRAY(Type) where Type can be converted to a QVariant // -> QVariantList if (arg.vt & VT_ARRAY) { - SAFEARRAY *array = 0; + SAFEARRAY *array = nullptr; if (arg.vt & VT_BYREF) array = *arg.pparray; else @@ -1174,7 +1174,7 @@ QVariant VARIANTToQVariant(const VARIANT &arg, const QByteArray &typeName, uint VARIANT variant; SafeArrayGetVartype(array, &vt); - void *pElement = 0; + void *pElement = nullptr; switch(vt) { case VT_BSTR: Q_ASSERT(false); break; // already covered case VT_BOOL: pElement = &variant.boolVal; break; @@ -1208,7 +1208,7 @@ QVariant VARIANTToQVariant(const VARIANT &arg, const QByteArray &typeName, uint for ( long i = lBound; i <= uBound; ++i ) { variant.vt = vt; SafeArrayGetElement(array, &i, pElement); - QVariant qvar = VARIANTToQVariant(variant, 0); + QVariant qvar = VARIANTToQVariant(variant, nullptr); clearVARIANT(&variant); list << qvar; } diff --git a/src/activeqt/shared/qaxutils.cpp b/src/activeqt/shared/qaxutils.cpp index c1f1e74..3514558 100644 --- a/src/activeqt/shared/qaxutils.cpp +++ b/src/activeqt/shared/qaxutils.cpp @@ -72,14 +72,14 @@ static inline QWindow *windowForWidget(QWidget *widget) return window; if (QWidget *nativeParent = widget->nativeParentWidget()) return nativeParent->windowHandle(); - return 0; + return nullptr; } HWND hwndForWidget(QWidget *widget) { if (QWindow *window = windowForWidget(widget)) return static_cast<HWND> (QGuiApplication::platformNativeInterface()->nativeResourceForWindow("handle", window)); - return 0; + return nullptr; } // Code courtesy of QWindowsXPStyle @@ -149,9 +149,9 @@ void qaxClearCachedSystemLogicalDpi() // Call from WM_DISPLAYCHANGE static inline QDpi systemLogicalDpi() { if (cachedSystemLogicalDpi.first < 0) { - const HDC displayDC = GetDC(0); + const HDC displayDC = GetDC(nullptr); cachedSystemLogicalDpi = QDpi(GetDeviceCaps(displayDC, LOGPIXELSX), GetDeviceCaps(displayDC, LOGPIXELSY)); - ReleaseDC(0, displayDC); + ReleaseDC(nullptr, displayDC); } return cachedSystemLogicalDpi; } diff --git a/src/activeqt/shared/qaxutils_p.h b/src/activeqt/shared/qaxutils_p.h index 8c86980..f56644b 100644 --- a/src/activeqt/shared/qaxutils_p.h +++ b/src/activeqt/shared/qaxutils_p.h @@ -78,7 +78,7 @@ class QWindow; HWND hwndForWidget(QWidget *widget); HRGN qaxHrgnFromQRegion(const QRegion ®ion, const QWindow *window); -typedef QPair<qreal, qreal> QDpi; +using QDpi = QPair<qreal, qreal>; extern SIZEL qaxMapPixToLogHiMetrics(const QSize &s, const QDpi &d, const QWindow *w); extern QSize qaxMapLogHiMetricsToPix(const SIZEL &s, const QDpi &d, const QWindow *w); diff --git a/src/tools/idc/main.cpp b/src/tools/idc/main.cpp index dddfeda..f38a51e 100644 --- a/src/tools/idc/main.cpp +++ b/src/tools/idc/main.cpp @@ -62,7 +62,7 @@ static bool prependPath() { enum { maxEnvironmentSize = 32767 }; wchar_t buffer[maxEnvironmentSize]; - if (!GetModuleFileName(NULL, buffer, maxEnvironmentSize)) + if (!GetModuleFileName(nullptr, buffer, maxEnvironmentSize)) return false; wchar_t *ptr = wcsrchr(buffer, L'\\'); if (!ptr) @@ -75,10 +75,10 @@ static bool prependPath() static QString errorString(DWORD errorCode) { - wchar_t *resultW = 0; + wchar_t *resultW = nullptr; FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER|FORMAT_MESSAGE_FROM_SYSTEM, - NULL, errorCode, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), - reinterpret_cast<LPWSTR>(&resultW), 0, NULL); + nullptr, errorCode, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), + reinterpret_cast<LPWSTR>(&resultW), 0, nullptr); const QString result = QString::fromWCharArray(resultW); LocalFree(resultW); return result; @@ -107,7 +107,7 @@ static bool runWithQtInEnvironment(const QString &cmd) QScopedArrayPointer<wchar_t> commandLineW(new wchar_t[cmd.size() + 1]); cmd.toWCharArray(commandLineW.data()); commandLineW[cmd.size()] = 0; - if (!CreateProcessW(0, commandLineW.data(), 0, 0, /* InheritHandles */ TRUE, 0, 0, 0, &si, &pi)) { + if (!CreateProcessW(nullptr, commandLineW.data(), nullptr, nullptr, /* InheritHandles */ TRUE, 0, nullptr, nullptr, &si, &pi)) { fprintf(stderr, "Unable to execute \"%s\": %s\n", qPrintable(cmd), qPrintable(errorString(GetLastError()))); return false; @@ -139,7 +139,7 @@ static bool runWithQtInEnvironment(const QString &cmd) static bool attachTypeLibrary(const QString &applicationName, int resource, const QByteArray &data, QString *errorMessage) { HANDLE hExe = BeginUpdateResource(reinterpret_cast<const wchar_t *>(applicationName.utf16()), false); - if (hExe == 0) { + if (hExe == nullptr) { if (errorMessage) *errorMessage = QString::fromLatin1("Failed to attach type library to binary %1 - could not open file.").arg(applicationName); return false; @@ -177,10 +177,10 @@ static HMODULE loadLibraryQt(const QString &input) // Load DLL with the folder containing the DLL temporarily added to the search path when loading dependencies const UINT oldErrorMode = SetErrorMode(SEM_FAILCRITICALERRORS); HMODULE result = - LoadLibraryEx(inputC, NULL, LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR | LOAD_LIBRARY_SEARCH_DEFAULT_DIRS); + LoadLibraryEx(inputC, nullptr, LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR | LOAD_LIBRARY_SEARCH_DEFAULT_DIRS); // If that fails, call with flags=0 to get LoadLibrary() behavior (search %PATH%). if (!result) - result = LoadLibraryEx(inputC, NULL, 0); + result = LoadLibraryEx(inputC, nullptr, 0); SetErrorMode(oldErrorMode); return result; } diff --git a/tests/manual/testcontrol/testcontrol.rc b/tests/manual/testcontrol/testcontrol.rc index 7fa8736..b1c86a4 100644 --- a/tests/manual/testcontrol/testcontrol.rc +++ b/tests/manual/testcontrol/testcontrol.rc @@ -1,2 +1,2 @@ 1 TYPELIB "testcontrol.rc" -1 ICON DISCARDABLE "testcontrol.ico" +1 ICON "testcontrol.ico" diff --git a/tools/dumpcpp/main.cpp b/tools/dumpcpp/main.cpp index eb6f70a..86699eb 100644 --- a/tools/dumpcpp/main.cpp +++ b/tools/dumpcpp/main.cpp @@ -45,7 +45,7 @@ #include <private/qmetaobject_p.h> QT_BEGIN_NAMESPACE -static ITypeInfo *currentTypeInfo = 0; +static ITypeInfo *currentTypeInfo = nullptr; enum ProgramMode { GenerateMode, @@ -152,7 +152,65 @@ QByteArray constRefify(const QByteArray &type) return ctype; } -void generateClassDecl(QTextStream &out, const QString &controlID, const QMetaObject *mo, +static void formatConstructorSignature(QTextStream &out, ObjectCategories category, + bool declaration) +{ + out << '('; + if (category & Licensed) { + out << "const QString &licenseKey, "; + if (declaration) + out << " = QString()"; + out << ", "; + } + if (category & ActiveX) { + out << "QWidget *parent"; + if (declaration) + out << " = nullptr"; + out << ", Qt::WindowFlags f"; + if (declaration) + out << " = {}"; + } else if (category & SubObject) { + out << "IDispatch *subobject"; + if (declaration) + out << " = nullptr"; + out << ", QAxObject *parent"; + if (declaration) + out << " = nullptr"; + } else { + out << "QObject *parent"; + if (declaration) + out << " = nullptr"; + } + out << ')'; +} + +static void formatConstructorBody(QTextStream &out, const QByteArray &className, + const QString &controlID, ObjectCategories category) +{ + out << className << "::" << className; + formatConstructorSignature(out, category, false); + out << " :" << endl << " "; + if (category & ActiveX) + out << "QAxWidget(parent, f"; + else if (category & SubObject) + out << "QAxObject(subobject, parent"; + else + out << "QAxObject(parent"; + out << ')' << endl << '{' << endl; + if (category & SubObject) { + out << " internalRelease();" << endl; + } else if (category & Licensed) { + out << " if (licenseKey.isEmpty())" << endl; + out << " setControl(QStringLiteral(\"" << controlID << "\"));" << endl; + out << " else" << endl; + out << " setControl(QStringLiteral(\"" << controlID << ":\") + licenseKey);" << endl; + } else { + out << " setControl(QStringLiteral(\"" << controlID << "\"));" << endl; + } + out << '}' << endl << endl; +} + +void generateClassDecl(QTextStream &out, const QMetaObject *mo, const QByteArray &className, const QByteArray &nameSpace, ObjectCategories category) { @@ -172,39 +230,9 @@ void generateClassDecl(QTextStream &out, const QString &controlID, const QMetaOb out << endl; out << '{' << endl; - out << "public:" << endl; - out << " " << className << '('; - if (category & Licensed) - out << "const QString &licenseKey = QString(), "; - if (category & ActiveX) - out << "QWidget *parent = 0, Qt::WindowFlags f"; - else if (category & SubObject) - out << "IDispatch *subobject = 0, QAxObject *parent"; - else - out << "QObject *parent"; - out << " = 0)" << endl; - out << " : "; - if (category & ActiveX) - out << "QAxWidget(parent, f"; - else if (category & SubObject) - out << "QAxObject((IUnknown*)subobject, parent"; - else - out << "QAxObject(parent"; - out << ')' << endl; - out << " {" << endl; - if (category & SubObject) - out << " internalRelease();" << endl; - else if (category & Licensed) { - out << " if (licenseKey.isEmpty())" << endl; - out << " setControl(QStringLiteral(\"" << controlID << "\"));" << endl; - out << " else" << endl; - out << " setControl(QStringLiteral(\"" << controlID << ":\") + licenseKey);" << endl; - } else { - out << " setControl(QStringLiteral(\"" << controlID << "\"));" << endl; - } - out << " }" << endl; - out << endl; - + out << "public:" << endl << " explicit " << className; + formatConstructorSignature(out, category, true); + out << ';' << endl; for (int ci = mo->classInfoOffset(); ci < mo->classInfoCount(); ++ci) { QMetaClassInfo info = mo->classInfo(ci); QByteArray iface_name = info.name(); @@ -522,8 +550,8 @@ void generateClassDecl(QTextStream &out, const QString &controlID, const QMetaOb if (!(category & NoMetaObject)) { out << "// meta object functions" << endl; out << " static const QMetaObject staticMetaObject;" << endl; - out << " virtual const QMetaObject *metaObject() const { return &staticMetaObject; }" << endl; - out << " virtual void *qt_metacast(const char *);" << endl; + out << " const QMetaObject *metaObject() const override { return &staticMetaObject; }" << endl; + out << " void *qt_metacast(const char *) override;" << endl; } out << "};" << endl; @@ -564,7 +592,7 @@ const char *metaTypeEnumValueString(int type) QT_FOR_EACH_STATIC_TYPE(RETURN_METATYPENAME_STRING) } #undef RETURN_METATYPENAME_STRING - return 0; + return nullptr; } int nameToBuiltinType(const QByteArray &name) @@ -690,6 +718,7 @@ void generateMethodParameters(QTextStream &out, const QMetaObject *mo, const QMe } void generateClassImpl(QTextStream &out, const QMetaObject *mo, const QByteArray &className, + const QString &controlID, const QByteArray &nameSpace, ObjectCategories category) { Q_STATIC_ASSERT_X(QMetaObjectPrivate::OutputRevision == 8, "dumpcpp should generate the same version as moc"); @@ -816,9 +845,9 @@ void generateClassImpl(QTextStream &out, const QMetaObject *mo, const QByteArray out << ", "; uint flags = 0; - uint vartype = property.type(); + const auto vartype = property.type(); if (vartype != QVariant::Invalid && vartype != QVariant::UserType) - flags = vartype << 24; + flags = uint(vartype) << 24; if (property.isReadable()) flags |= Readable; @@ -873,6 +902,7 @@ void generateClassImpl(QTextStream &out, const QMetaObject *mo, const QByteArray out << "};" << endl; out << endl; + formatConstructorBody(out, className, controlID, category); out << "const QMetaObject " << className << "::staticMetaObject = {" << endl; if (category & ActiveX) @@ -880,13 +910,13 @@ void generateClassImpl(QTextStream &out, const QMetaObject *mo, const QByteArray else out << "{ &QObject::staticMetaObject," << endl; out << "qt_meta_stringdata_all.data," << endl; - out << "qt_meta_data_" << qualifiedClassNameIdentifier << ", 0, 0, 0 }" << endl; + out << "qt_meta_data_" << qualifiedClassNameIdentifier << ", nullptr, nullptr, nullptr }" << endl; out << "};" << endl; out << endl; out << "void *" << className << "::qt_metacast(const char *_clname)" << endl; out << '{' << endl; - out << " if (!_clname) return 0;" << endl; + out << " if (!_clname) return nullptr;" << endl; out << " if (!strcmp(_clname, \"" << qualifiedClassName << "\"))" << endl; out << " return static_cast<void*>(const_cast<" << className << "*>(this));" << endl; if (category & ActiveX) @@ -910,7 +940,7 @@ static QByteArray classNameFromTypeInfo(ITypeInfo *typeinfo) { BSTR bstr; QByteArray result; - if (SUCCEEDED(typeinfo->GetDocumentation(-1, &bstr, 0, 0, 0))) { + if (SUCCEEDED(typeinfo->GetDocumentation(-1, &bstr, nullptr, nullptr, nullptr))) { result = QString::fromWCharArray(bstr).toLatin1(); SysFreeString(bstr); } @@ -963,16 +993,17 @@ bool generateTypeLibrary(QString typeLibFile, QString outname, QString libName = nameSpace; if (libName.isEmpty()) { BSTR nameString = nullptr; - if (SUCCEEDED(typelib->GetDocumentation(-1, &nameString, 0, 0, 0))) { + if (SUCCEEDED(typelib->GetDocumentation(-1, &nameString, nullptr, nullptr, nullptr))) { libName = QString::fromWCharArray(nameString); SysFreeString(nameString); } } + const QByteArray libNameBa = libName.toLatin1(); vTableOnlyStubs = vTableOnlyStubsFromTypeLib(typelib, libName); QString libVersion(QLatin1String("1.0")); - TLIBATTR *tlibattr = 0; + TLIBATTR *tlibattr = nullptr; typelib->GetLibAttr(&tlibattr); if (tlibattr) { libVersion = QString::fromLatin1("%1.%2").arg(tlibattr->wMajorVerNum).arg(tlibattr->wMinorVerNum); @@ -987,7 +1018,7 @@ bool generateTypeLibrary(QString typeLibFile, QString outname, return false; } - QMetaObject *namespaceObject = qax_readEnumInfo(typelib, 0); + QMetaObject *namespaceObject = qax_readEnumInfo(typelib, nullptr); QTemporaryFile classImplFile; if (!classImplFile.open()) { @@ -1010,6 +1041,7 @@ bool generateTypeLibrary(QString typeLibFile, QString outname, implOut << "#define QAX_DUMPCPP_" << libName.toUpper() << "_NOINLINES" << endl; implOut << "#include \"" << outname << ".h\"" << endl; + implOut << "#include <OAIdl.h>" << endl; // For IDispatch implOut << endl; implOut << "using namespace " << libName << ';' << endl; implOut << endl; @@ -1043,7 +1075,7 @@ bool generateTypeLibrary(QString typeLibFile, QString outname, declOut << endl; declOut << "// Referenced namespace" << endl; for (UINT index = 0; index < typeCount; ++index) { - ITypeInfo *typeinfo = 0; + ITypeInfo *typeinfo = nullptr; typelib->GetTypeInfo(index, &typeinfo); if (!typeinfo) continue; @@ -1058,7 +1090,7 @@ bool generateTypeLibrary(QString typeLibFile, QString outname, TYPEKIND typekind; typelib->GetTypeInfoType(index, &typekind); - QMetaObject *metaObject = 0; + QMetaObject *metaObject = nullptr; // trigger meta object to collect references to other type libraries switch (typekind) { @@ -1089,7 +1121,7 @@ bool generateTypeLibrary(QString typeLibFile, QString outname, default: break; } - namespaces[libName.toLatin1()].append(className); + namespaces[libNameBa].append(className); if (!qax_qualified_usertypes.contains(className)) qax_qualified_usertypes << className; } @@ -1116,18 +1148,15 @@ bool generateTypeLibrary(QString typeLibFile, QString outname, refTypeLib.remove(0, refTypeLib.lastIndexOf(' ') + 1); namespaces[refTypeLib].append(refType); } else { - namespaces[libName.toLatin1()].append(refType); + namespaces[libNameBa].append(refType); } } - QList<QByteArray> keys = namespaces.keys(); - for (int n = 0; n < keys.count(); ++n) { - QByteArray nspace = keys.at(n); - if (QString::fromLatin1(nspace.constData()) != libName) { + for (auto it = namespaces.cbegin(), end = namespaces.cend(); it != end; ++it) { + const QByteArray &nspace = it.key(); + if (libName != QLatin1String(nspace)) { declOut << "namespace " << nspace << " {" << endl; - QList<QByteArray> classList = namespaces.value(nspace); - for (int c = 0; c < classList.count(); ++c) { - QByteArray className = classList.at(c); + for (const auto &className : it.value()) { if (className.contains(' ')) { writeForwardDeclaration(declOut, className); namespaceForType.insert(className.mid(className.indexOf(' ') + 1), nspace); @@ -1146,21 +1175,21 @@ bool generateTypeLibrary(QString typeLibFile, QString outname, declOut << "Q_DECLARE_OPAQUE_POINTER(" << opaquePointerType << "*)" << endl; declOut << endl; } - generateNameSpace(declOut, namespaceObject, libName.toLatin1()); + generateNameSpace(declOut, namespaceObject, libNameBa); - QList<QByteArray> classList = namespaces.value(libName.toLatin1()); - if (classList.count()) + auto nspIt = namespaces.constFind(libNameBa); + if (nspIt != namespaces.constEnd() && !nspIt.value().isEmpty()) { declOut << "// forward declarations" << endl; - for (int c = 0; c < classList.count(); ++c) { - QByteArray className = classList.at(c); - if (className.contains(' ')) { - declOut << " " << className << ';' << endl; - namespaceForType.insert(className.mid(className.indexOf(' ') + 1), libName.toLatin1()); - } else { - declOut << " class " << className << ';' << endl; - namespaceForType.insert(className, libName.toLatin1()); - namespaceForType.insert(className + '*', libName.toLatin1()); - namespaceForType.insert(className + "**", libName.toLatin1()); + for (const auto &className : nspIt.value()) { + if (className.contains(' ')) { + declOut << " " << className << ';' << endl; + namespaceForType.insert(className.mid(className.indexOf(' ') + 1), libNameBa); + } else { + declOut << " class " << className << ';' << endl; + namespaceForType.insert(className, libNameBa); + namespaceForType.insert(className + '*', libNameBa); + namespaceForType.insert(className + "**", libNameBa); + } } } @@ -1171,7 +1200,7 @@ bool generateTypeLibrary(QString typeLibFile, QString outname, UINT typeCount = typelib->GetTypeInfoCount(); for (UINT index = 0; index < typeCount; ++index) { - ITypeInfo *typeinfo = 0; + ITypeInfo *typeinfo = nullptr; typelib->GetTypeInfo(index, &typeinfo); if (!typeinfo) continue; @@ -1192,7 +1221,7 @@ bool generateTypeLibrary(QString typeLibFile, QString outname, else if (typeattr->wTypeFlags & TYPEFLAG_FCONTROL) object_category |= ActiveX; - QMetaObject *metaObject = 0; + QMetaObject *metaObject = nullptr; QUuid guid(typeattr->guid); if (!(object_category & ActiveX)) { @@ -1220,7 +1249,7 @@ bool generateTypeLibrary(QString typeLibFile, QString outname, // class to make related error messages clearer const QByteArray className = classNameFromTypeInfo(typeinfo); declOut << "// stub for vtable-only interface\n" - << "class " << className << " : public QAxObject { Q_DISABLE_COPY(" + << "class " << className << " : public QAxObject { Q_DISABLE_COPY_MOVE(" << className << ") };\n\n"; } break; @@ -1240,24 +1269,24 @@ 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(), + generateClassDecl(classesOut, metaObject, className, libNameBa, object_category | NoInlines); classesOut << endl; } else { - generateClassDecl(declOut, guid.toString(), metaObject, className, libName.toLatin1(), + generateClassDecl(declOut, metaObject, className, libNameBa, object_category | NoInlines); declOut << endl; } subtypes << className; - generateClassDecl(inlinesOut, guid.toString(), metaObject, className, libName.toLatin1(), + generateClassDecl(inlinesOut, metaObject, className, libNameBa, object_category | OnlyInlines); inlinesOut << endl; } if (implFile.isOpen()) - generateClassImpl(classImplOut, metaObject, className, libName.toLatin1(), + generateClassImpl(classImplOut, metaObject, className, guid.toString(), libNameBa, object_category); } - currentTypeInfo = 0; + currentTypeInfo = nullptr; } qax_deleteMetaObject(metaObject); @@ -1279,9 +1308,9 @@ bool generateTypeLibrary(QString typeLibFile, QString outname, QList<QByteArray> currentList; int currentTableLen = 0; - for (int i = 0; i < strings.size(); ++i) { - currentTableLen += strings.at(i).length() + 1; - currentList.append(strings.at(i)); + for (const auto &s : strings) { + currentTableLen += s.length() + 1; + currentList.append(s); // Split strings into chunks less than 64k to work around compiler limits. if (currentTableLen > 60000) { implOut << " char stringdata" << listVector.size() << '[' << currentTableLen + 1 << "];" << endl; @@ -1324,13 +1353,12 @@ bool generateTypeLibrary(QString typeLibFile, QString outname, // // Build stringdata arrays // - for (int i = 0; i < listVector.size(); ++i) { + for (const auto &l : listVector) { int col = 0; int len = 0; implOut << ',' << endl; implOut << " \""; - for (int j = 0; j < listVector[i].size(); ++j) { - QByteArray s = listVector[i].at(j); + for (const auto &s : l) { len = s.length(); if (col && col + len >= 150) { implOut << '"' << endl << " \""; @@ -1433,11 +1461,11 @@ QT_USE_NAMESPACE struct Options { - Options() : mode(GenerateMode), category(DefaultObject), dispatchEqualsIDispatch(false) {} + Options() = default; - ProgramMode mode; - ObjectCategories category; - bool dispatchEqualsIDispatch; + ProgramMode mode = GenerateMode; + ObjectCategories category = DefaultObject; + bool dispatchEqualsIDispatch = false; QString outname; QString typeLib; @@ -1532,7 +1560,7 @@ static void parseOptions(Options *options) int main(int argc, char **argv) { - if (FAILED(CoInitializeEx(0, COINIT_APARTMENTTHREADED))) { + if (FAILED(CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED))) { qErrnoWarning("CoInitializeEx() failed."); return -1; } diff --git a/tools/dumpdoc/main.cpp b/tools/dumpdoc/main.cpp index 3f3dbd7..6e14ee6 100644 --- a/tools/dumpdoc/main.cpp +++ b/tools/dumpdoc/main.cpp @@ -35,7 +35,7 @@ QT_USE_NAMESPACE int main(int argc, char **argv) { - if (FAILED(CoInitializeEx(0, COINIT_APARTMENTTHREADED))) { + if (FAILED(CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED))) { qErrnoWarning("CoInitializeEx() failed."); return -1; } diff --git a/tools/testcon/ambientproperties.cpp b/tools/testcon/ambientproperties.cpp index ec1311d..ae759f5 100644 --- a/tools/testcon/ambientproperties.cpp +++ b/tools/testcon/ambientproperties.cpp @@ -36,7 +36,7 @@ QT_BEGIN_NAMESPACE AmbientProperties::AmbientProperties(QWidget *parent) -: QDialog(parent), container(0) +: QDialog(parent), container(nullptr) { setupUi(this); diff --git a/tools/testcon/changeproperties.cpp b/tools/testcon/changeproperties.cpp index 9b5cca2..4ec1332 100644 --- a/tools/testcon/changeproperties.cpp +++ b/tools/testcon/changeproperties.cpp @@ -39,7 +39,7 @@ QT_BEGIN_NAMESPACE ChangeProperties::ChangeProperties(QWidget *parent) -: QDialog(parent), activex(0) +: QDialog(parent), activex(nullptr) { setupUi(this); @@ -60,9 +60,9 @@ void ChangeProperties::setControl(QAxWidget *ax) void ChangeProperties::on_listProperties_currentItemChanged(QTreeWidgetItem *current) { - editValue->setEnabled(current != 0); - buttonSet->setEnabled(current != 0); - valueLabel->setEnabled(current != 0); + editValue->setEnabled(current != nullptr); + buttonSet->setEnabled(current != nullptr); + valueLabel->setEnabled(current != nullptr); if (!current) return; diff --git a/tools/testcon/controlinfo.cpp b/tools/testcon/controlinfo.cpp index 4c19fd1..2339895 100644 --- a/tools/testcon/controlinfo.cpp +++ b/tools/testcon/controlinfo.cpp @@ -51,7 +51,7 @@ void ControlInfo::setControl(QWidget *activex) group->setText(0, tr("Class Info")); group->setText(1, QString::number(mo->classInfoCount())); - QTreeWidgetItem *item = 0; + QTreeWidgetItem *item = nullptr; int i; int count; for (i = mo->classInfoOffset(); i < mo->classInfoCount(); ++i) { diff --git a/tools/testcon/docuwindow.h b/tools/testcon/docuwindow.h index bd133b7..a2849e5 100644 --- a/tools/testcon/docuwindow.h +++ b/tools/testcon/docuwindow.h @@ -39,7 +39,7 @@ class DocuWindow : public QMainWindow { Q_OBJECT public: - DocuWindow(const QString& docu, QWidget *parent = 0); + DocuWindow(const QString& docu, QWidget *parent = nullptr); public slots: void save(); diff --git a/tools/testcon/invokemethod.cpp b/tools/testcon/invokemethod.cpp index 92c7a91..796f0e7 100644 --- a/tools/testcon/invokemethod.cpp +++ b/tools/testcon/invokemethod.cpp @@ -30,13 +30,18 @@ #include <qt_windows.h> #include <ActiveQt/ActiveQt> +#include <QtWidgets/QCompleter> QT_BEGIN_NAMESPACE InvokeMethod::InvokeMethod(QWidget *parent) -: QDialog(parent), activex(0) +: QDialog(parent), activex(nullptr) { setupUi(this); + auto completer = new QCompleter(comboMethods->model(), comboMethods); + completer->setCaseSensitivity(Qt::CaseInsensitive); + completer->setCompletionMode(QCompleter::InlineCompletion); + comboMethods->setCompleter(completer); listParameters->setColumnCount(3); listParameters->headerItem()->setText(0, tr("Parameter")); @@ -136,8 +141,8 @@ void InvokeMethod::on_listParameters_currentItemChanged(QTreeWidgetItem *item) { if (!activex) return; - editValue->setEnabled(item != 0); - buttonSet->setEnabled(item != 0); + editValue->setEnabled(item != nullptr); + buttonSet->setEnabled(item != nullptr); if (!item) return; editValue->setText(item->text(2)); diff --git a/tools/testcon/invokemethod.ui b/tools/testcon/invokemethod.ui index 588819c..88ef34e 100644 --- a/tools/testcon/invokemethod.ui +++ b/tools/testcon/invokemethod.ui @@ -136,9 +136,6 @@ <property name="insertPolicy" > <enum>QComboBox::NoInsert</enum> </property> - <property name="autoCompletion" > - <bool>true</bool> - </property> <property name="duplicatesEnabled" > <bool>false</bool> </property> diff --git a/tools/testcon/mainwindow.cpp b/tools/testcon/mainwindow.cpp index 0c3d3e8..14db741 100644 --- a/tools/testcon/mainwindow.cpp +++ b/tools/testcon/mainwindow.cpp @@ -70,10 +70,6 @@ MainWindow *MainWindow::m_instance = nullptr; MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) - , m_dlgInvoke(nullptr) - , m_dlgProperties(nullptr) - , m_dlgAmbient(nullptr) - , m_scripts(nullptr) { setupUi(this); MainWindow::m_instance = this; // Logging handler needs the UI @@ -106,7 +102,7 @@ QAxWidget *MainWindow::activeAxWidget() const { if (const QMdiSubWindow *activeSubWindow = m_mdiArea->currentSubWindow()) return qobject_cast<QAxWidget*>(activeSubWindow->widget()); - return 0; + return nullptr; } QList<QAxWidget *> MainWindow::axWidgets() const @@ -130,7 +126,7 @@ struct LowIntegrity { if (!OpenProcessToken(GetCurrentProcess(), TOKEN_DUPLICATE | TOKEN_ADJUST_DEFAULT | TOKEN_QUERY | TOKEN_ASSIGN_PRIMARY, &cur_token)) abort(); - if (!DuplicateTokenEx(cur_token, 0, NULL, SecurityImpersonation, TokenPrimary, &m_token)) + if (!DuplicateTokenEx(cur_token, 0, nullptr, SecurityImpersonation, TokenPrimary, &m_token)) abort(); CloseHandle(cur_token); @@ -425,7 +421,7 @@ void MainWindow::on_actionScriptingRun_triggered() QVariant result = m_scripts->call(macro); if (result.isValid()) - logMacros->append(tr("Return value of %1: %2").arg(macro).arg(result.toString())); + logMacros->append(tr("Return value of %1: %2").arg(macro, result.toString())); #endif } @@ -538,7 +534,7 @@ void MainWindow::updateGUI() actionFileNew->setEnabled(true); actionFileLoad->setEnabled(true); actionFileSave->setEnabled(hasControl); - actionContainerSet->setEnabled(container != 0); + actionContainerSet->setEnabled(container != nullptr); actionContainerClear->setEnabled(hasControl); actionControlProperties->setEnabled(hasControl); actionControlMethods->setEnabled(hasControl); @@ -547,9 +543,9 @@ void MainWindow::updateGUI() actionControlPixmap->setEnabled(hasControl); VerbMenu->setEnabled(hasControl); if (m_dlgInvoke) - m_dlgInvoke->setControl(hasControl ? container : 0); + m_dlgInvoke->setControl(hasControl ? container : nullptr); if (m_dlgProperties) - m_dlgProperties->setControl(hasControl ? container : 0); + m_dlgProperties->setControl(hasControl ? container : nullptr); const QList<QAxWidget *> axw = axWidgets(); for (QAxWidget *container : axw) { @@ -585,10 +581,10 @@ void MainWindow::logSignal(const QString &signal, int argc, void *argv) return; QString paramlist = QLatin1String(" - {"); - VARIANT *params = (VARIANT*)argv; + auto params = static_cast<const VARIANT *>(argv); for (int a = argc-1; a >= 0; --a) { paramlist += QLatin1Char(' '); - paramlist += VARIANTToQVariant(params[a], 0).toString(); + paramlist += VARIANTToQVariant(params[a], nullptr).toString(); paramlist += a > 0 ? QLatin1Char(',') : QLatin1Char(' '); } if (argc) diff --git a/tools/testcon/mainwindow.h b/tools/testcon/mainwindow.h index e980d06..b3be5c0 100644 --- a/tools/testcon/mainwindow.h +++ b/tools/testcon/mainwindow.h @@ -56,7 +56,7 @@ class MainWindow : public QMainWindow, public Ui::MainWindow Q_CLASSINFO("EventsID", "{02a268cd-24b4-4fd9-88ff-b01b683ef39d}") public: - MainWindow(QWidget *parent = 0); + MainWindow(QWidget *parent = nullptr); ~MainWindow(); static MainWindow *instance() { return m_instance; } @@ -100,13 +100,11 @@ private: static MainWindow *m_instance; - InvokeMethod *m_dlgInvoke; - ChangeProperties *m_dlgProperties; - AmbientProperties *m_dlgAmbient; - QAxScriptManager *m_scripts; - QMdiArea *m_mdiArea; - - QtMessageHandler m_oldDebugHandler; + InvokeMethod *m_dlgInvoke = nullptr; + ChangeProperties *m_dlgProperties = nullptr; + AmbientProperties *m_dlgAmbient = nullptr; + QAxScriptManager *m_scripts = nullptr; + QMdiArea *m_mdiArea = nullptr; private slots: void updateGUI(); |