summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@theqtcompany.com>2016-04-08 10:28:24 +0200
committerLiang Qi <liang.qi@theqtcompany.com>2016-04-08 10:28:24 +0200
commitb5440b50f23982e7459a66b46ad41f176f67e308 (patch)
treed4e4e50e5a5ae84df442c1e4d2345539943692aa
parent7477c86107ac0f5d344b380b38118c3a90f994a7 (diff)
parenta4b8485cd38a9c33cdcf1b97633fa65b7230643b (diff)
Merge remote-tracking branch 'origin/5.6' into 5.7v5.7.0-beta1
Conflicts: src/activeqt/container/qaxwidget.h Change-Id: Ic6e7267fc71e3ace14e75b392ad3f7cac0df41a1
-rw-r--r--examples/activeqt/webbrowser/doc/images/activeqt-webbrowser-example.pngbin59163 -> 45199 bytes
-rw-r--r--src/activeqt/container/qaxbase.cpp232
-rw-r--r--src/activeqt/container/qaxbase.h10
-rw-r--r--src/activeqt/container/qaxdump.cpp11
-rw-r--r--src/activeqt/container/qaxobject.cpp6
-rw-r--r--src/activeqt/container/qaxobject.h14
-rw-r--r--src/activeqt/container/qaxscript.cpp32
-rw-r--r--src/activeqt/container/qaxscript.h4
-rw-r--r--src/activeqt/container/qaxselect.cpp8
-rw-r--r--src/activeqt/container/qaxselect.h2
-rw-r--r--src/activeqt/container/qaxwidget.cpp122
-rw-r--r--src/activeqt/container/qaxwidget.h16
-rw-r--r--src/activeqt/control/qaxfactory.h20
-rw-r--r--src/activeqt/control/qaxserver.cpp16
-rw-r--r--src/activeqt/control/qaxserverbase.cpp208
-rw-r--r--src/activeqt/control/qaxservermain.cpp2
-rw-r--r--src/activeqt/shared/qaxtypefunctions.cpp47
-rw-r--r--src/activeqt/shared/qaxtypefunctions.h2
-rw-r--r--src/tools/idc/main.cpp21
-rw-r--r--tools/dumpcpp/main.cpp16
20 files changed, 399 insertions, 390 deletions
diff --git a/examples/activeqt/webbrowser/doc/images/activeqt-webbrowser-example.png b/examples/activeqt/webbrowser/doc/images/activeqt-webbrowser-example.png
index 4913594..0bb451a 100644
--- a/examples/activeqt/webbrowser/doc/images/activeqt-webbrowser-example.png
+++ b/examples/activeqt/webbrowser/doc/images/activeqt-webbrowser-example.png
Binary files differ
diff --git a/src/activeqt/container/qaxbase.cpp b/src/activeqt/container/qaxbase.cpp
index 472e041..f2deedb 100644
--- a/src/activeqt/container/qaxbase.cpp
+++ b/src/activeqt/container/qaxbase.cpp
@@ -93,14 +93,15 @@ static inline HRESULT Invoke(IDispatch *disp,
VARTYPE vt = pDispParams->rgvarg->vt;
if (vt == VT_UNKNOWN || vt == VT_DISPATCH || (vt & VT_ARRAY) || (vt & VT_BYREF)) {
- HRESULT hr = disp->Invoke(dispIdMember, riid, lcid, (wFlags & ~DISPATCH_PROPERTYPUT) | DISPATCH_PROPERTYPUTREF,
- pDispParams, pVarResult, pExcepInfo, puArgErr);
+ const HRESULT hr =
+ disp->Invoke(dispIdMember, riid, lcid, (WORD(wFlags) & ~DISPATCH_PROPERTYPUT) | DISPATCH_PROPERTYPUTREF,
+ pDispParams, pVarResult, pExcepInfo, puArgErr);
if (SUCCEEDED(hr))
return hr;
}
}
- return disp->Invoke(dispIdMember, riid, lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
+ return disp->Invoke(dispIdMember, riid, lcid, WORD(wFlags), pDispParams, pVarResult, pExcepInfo, puArgErr);
}
/*
@@ -118,8 +119,8 @@ struct QAxMetaObject : public QMetaObject
}
~QAxMetaObject()
{
- delete [] (int*)d.data;
- delete [] (char*)d.stringdata;
+ delete [] d.data;
+ delete [] reinterpret_cast<char *>(const_cast<QByteArrayData *>(d.stringdata));
}
int numParameter(const QByteArray &prototype);
@@ -206,7 +207,7 @@ inline DISPID QAxMetaObject::dispIDofName(const QByteArray &name, IDispatch *dis
if (dispid == DISPID_UNKNOWN) {
// get the Dispatch ID from the object
QString unicodeName = QLatin1String(name);
- OLECHAR *names = (wchar_t*)unicodeName.utf16();
+ OLECHAR *names = reinterpret_cast<wchar_t *>(const_cast<ushort *>(unicodeName.utf16()));
disp->GetIDsOfNames(IID_NULL, &names, 1, LOCALE_USER_DEFAULT, &dispid);
if (dispid != DISPID_UNKNOWN)
dispIDs.insert(name, dispid);
@@ -277,7 +278,7 @@ public:
cpoint = cp;
cpoint->AddRef();
ciid = iid;
- cpoint->Advise((IUnknown*)(IDispatch*)this, &cookie);
+ cpoint->Advise(static_cast<IUnknown *>(static_cast<IDispatch *>(this)), &cookie);
}
// disconnect from all connection points
@@ -332,13 +333,11 @@ public:
{
*ppvObject = 0;
if (riid == IID_IUnknown)
- *ppvObject = (IUnknown*)(IDispatch*)this;
- else if (riid == IID_IDispatch)
- *ppvObject = (IDispatch*)this;
+ *ppvObject = static_cast<IUnknown *>(static_cast<IDispatch *>(this));
+ else if (riid == IID_IDispatch || ciid == riid)
+ *ppvObject = static_cast<IDispatch *>(this);
else if (riid == IID_IPropertyNotifySink)
- *ppvObject = (IPropertyNotifySink*)this;
- else if (ciid == riid)
- *ppvObject = (IDispatch*)this;
+ *ppvObject = static_cast<IPropertyNotifySink *>(this);
else
return E_NOINTERFACE;
@@ -402,8 +401,8 @@ public:
Q_ASSERT(signal.methodType() == QMetaMethod::Signal);
Q_ASSERT(signame == signal.methodSignature());
// verify parameter count
- int pcount = axmeta->numParameter(signame);
- int argcount = pDispParams->cArgs;
+ const int pcount = axmeta->numParameter(signame);
+ const int argcount = int(pDispParams->cArgs);
if (pcount > argcount)
return DISP_E_PARAMNOTOPTIONAL;
else if (pcount < argcount)
@@ -557,7 +556,7 @@ public:
static bool signalHasReceivers(QObject *qobject, const char *signalName)
{
Q_ASSERT(qobject);
- return ((QAxObject*)qobject)->receivers(QByteArray::number(QSIGNAL_CODE) + signalName);
+ return static_cast<QAxObject *>(qobject)->receivers(QByteArray::number(QSIGNAL_CODE) + signalName);
}
IConnectionPoint *cpoint;
@@ -616,7 +615,7 @@ public:
return disp;
if (ptr)
- ptr->QueryInterface(IID_IDispatch, (void**)&disp);
+ ptr->QueryInterface(IID_IDispatch, reinterpret_cast<void **>(&disp));
return disp;
}
@@ -992,7 +991,7 @@ bool QAxBase::setControl(const QString &c)
QUuid uuid(search);
if (uuid.isNull()) {
CLSID clsid;
- HRESULT res = CLSIDFromProgID((wchar_t*)c.utf16(), &clsid);
+ HRESULT res = CLSIDFromProgID(reinterpret_cast<const wchar_t *>(c.utf16()), &clsid);
if (res == S_OK)
search = QUuid(clsid).toString();
else {
@@ -1142,7 +1141,7 @@ QStringList QAxBase::verbs() const
if (d->verbs.isEmpty()) {
IOleObject *ole = 0;
- d->ptr->QueryInterface(IID_IOleObject, (void**)&ole);
+ d->ptr->QueryInterface(IID_IOleObject, reinterpret_cast<void **>(&ole));
if (ole) {
IEnumOLEVERB *enumVerbs = 0;
ole->EnumVerbs(&enumVerbs);
@@ -1227,7 +1226,8 @@ bool QAxBase::initialize(IUnknown **ptr)
res = initializeFromFile(ptr);
if (!res) { // standard
- HRESULT hres = CoCreateInstance(QUuid(ctrl), 0, CLSCTX_SERVER, IID_IUnknown, (void**)ptr);
+ HRESULT hres = CoCreateInstance(QUuid(ctrl), 0, CLSCTX_SERVER, IID_IUnknown,
+ reinterpret_cast<void **>(ptr));
res = S_OK == hres;
#ifndef QT_NO_DEBUG
if (!res)
@@ -1256,7 +1256,8 @@ bool QAxBase::initializeLicensed(IUnknown** ptr)
QString key(control().mid(at+2));
IClassFactory *factory = 0;
- CoGetClassObject(QUuid(clsid), CLSCTX_SERVER, 0, IID_IClassFactory, (void**)&factory);
+ CoGetClassObject(QUuid(clsid), CLSCTX_SERVER, 0, IID_IClassFactory,
+ reinterpret_cast<void **>(&factory));
if (!factory)
return false;
initializeLicensedHelper(factory, key, ptr);
@@ -1271,12 +1272,13 @@ bool QAxBase::initializeLicensed(IUnknown** ptr)
*/
bool QAxBase::initializeLicensedHelper(void *f, const QString &key, IUnknown **ptr)
{
- IClassFactory *factory = (IClassFactory*)f;
+ IClassFactory *factory = reinterpret_cast<IClassFactory *>(f);
IClassFactory2 *factory2 = 0;
- factory->QueryInterface(IID_IClassFactory2, (void**)&factory2);
+ factory->QueryInterface(IID_IClassFactory2, reinterpret_cast<void **>(&factory2));
if (factory2) {
BSTR bkey = QStringToBSTR(key);
- HRESULT hres = factory2->CreateInstanceLic(0, 0, IID_IUnknown, bkey, (void**)ptr);
+ HRESULT hres = factory2->CreateInstanceLic(0, 0, IID_IUnknown, bkey,
+ reinterpret_cast<void **>(ptr));
SysFreeString(bkey);
#ifdef QT_DEBUG
LICINFO licinfo;
@@ -1284,7 +1286,7 @@ bool QAxBase::initializeLicensedHelper(void *f, const QString &key, IUnknown **p
factory2->GetLicInfo(&licinfo);
if (hres != S_OK) {
- SetLastError(hres);
+ SetLastError(DWORD(hres));
qErrnoWarning("CreateInstanceLic failed");
if (!licinfo.fLicVerified) {
qWarning("Wrong license key specified, and machine is not fully licensed.");
@@ -1313,7 +1315,7 @@ 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, (void**)ptr);
+ factory->CreateInstance(0, IID_IUnknown, reinterpret_cast<void **>(ptr));
}
return *ptr != 0;
}
@@ -1362,7 +1364,9 @@ bool QAxBase::initializeFromFile(IUnknown** ptr)
HRESULT hres = ::CreateILockBytesOnHGlobal(0, 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, (void**)ptr);
+ hres = OleCreateFromFile(CLSID_NULL, reinterpret_cast<const wchar_t*>(control().utf16()),
+ IID_IUnknown, OLERENDER_NONE, 0, 0, storage,
+ reinterpret_cast<void **>(ptr));
storage->Release();
bytes->Release();
@@ -1428,12 +1432,15 @@ bool QAxBase::initializeRemote(IUnknown** ptr)
d->ctrl = d->ctrl + QChar::fromLatin1(':') + key;
COAUTHIDENTITY authIdentity;
- authIdentity.UserLength = user.length();
- authIdentity.User = authIdentity.UserLength ? (ushort*)user.utf16() : 0;
- authIdentity.DomainLength = domain.length();
- authIdentity.Domain = authIdentity.DomainLength ? (ushort*)domain.utf16() : 0;
- authIdentity.PasswordLength = passwd.length();
- authIdentity.Password = authIdentity.PasswordLength ? (ushort*)passwd.utf16() : 0;
+ authIdentity.UserLength = ULONG(user.length());
+ authIdentity.User = authIdentity.UserLength
+ ? const_cast<ushort *>(user.utf16()) : Q_NULLPTR;
+ authIdentity.DomainLength = ULONG(domain.length());
+ authIdentity.Domain = authIdentity.DomainLength
+ ? const_cast<ushort *>(domain.utf16()) : Q_NULLPTR;
+ authIdentity.PasswordLength = ULONG(passwd.length());
+ authIdentity.Password = authIdentity.PasswordLength
+ ? const_cast<ushort *>(passwd.utf16()) : Q_NULLPTR;
authIdentity.Flags = SEC_WINNT_AUTH_IDENTITY_UNICODE;
COAUTHINFO authInfo;
@@ -1449,15 +1456,16 @@ bool QAxBase::initializeRemote(IUnknown** ptr)
serverInfo.dwReserved1 = 0;
serverInfo.dwReserved2 = 0;
serverInfo.pAuthInfo = &authInfo;
- serverInfo.pwszName = (wchar_t*)server.utf16();
+ serverInfo.pwszName = reinterpret_cast<wchar_t *>(const_cast<ushort *>(server.utf16()));
IClassFactory *factory = 0;
- HRESULT res = CoGetClassObject(QUuid(clsid), CLSCTX_REMOTE_SERVER, &serverInfo, IID_IClassFactory, (void**)&factory);
+ 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, (void**)ptr);
+ res = factory->CreateInstance(0, IID_IUnknown, reinterpret_cast<void **>(ptr));
factory->Release();
}
#ifndef QT_NO_DEBUG
@@ -1481,7 +1489,7 @@ long QAxBase::queryInterface(const QUuid &uuid, void **iface) const
{
*iface = 0;
if (!d->ptr) {
- ((QAxBase*)this)->initialize(&d->ptr);
+ const_cast<QAxBase *>(this)->initialize(&d->ptr);
d->initialized = true;
}
@@ -1578,7 +1586,8 @@ private:
while (type_conversion[type][0]) {
int paren = proto.indexOf('(');
while ((paren = proto.indexOf(type_conversion[type][0])) != -1) {
- proto.replace(paren, qstrlen(type_conversion[type][0]), type_conversion[type][1]);
+ proto.replace(paren, int(qstrlen(type_conversion[type][0])),
+ type_conversion[type][1]);
}
++type;
}
@@ -1758,10 +1767,10 @@ QMetaObject *qax_readClassInfo(ITypeLib *typeLib, ITypeInfo *classInfo, const QM
TYPEATTR *typeattr;
classInfo->GetTypeAttr(&typeattr);
if (typeattr) {
- int nInterfaces = typeattr->cImplTypes;
+ const UINT nInterfaces = typeattr->cImplTypes;
classInfo->ReleaseTypeAttr(typeattr);
- for (int index = 0; index < nInterfaces; ++index) {
+ for (UINT index = 0; index < nInterfaces; ++index) {
HREFTYPE refType;
if (S_OK != classInfo->GetRefTypeOfImplType(index, &refType))
continue;
@@ -1883,7 +1892,7 @@ QByteArray MetaObjectGenerator::usertypeToString(const TYPEDESC &tdesc, ITypeInf
// get type name
BSTR usertypename = 0;
- usertypelib->GetDocumentation(index, &usertypename, 0, 0, 0);
+ usertypelib->GetDocumentation(INT(index), &usertypename, 0, 0, 0);
QByteArray userTypeName = QString::fromWCharArray(usertypename).toLatin1();
SysFreeString(usertypename);
@@ -2086,7 +2095,7 @@ QByteArray MetaObjectGenerator::guessTypes(const TYPEDESC &tdesc, ITypeInfo *inf
str = guessTypes(tdesc.lpadesc->tdescElem, info, function);
if (!str.isEmpty()) {
for (int index = 0; index < tdesc.lpadesc->cDims; ++index)
- str += '[' + QByteArray::number((int)tdesc.lpadesc->rgbounds[index].cElements) + ']';
+ str += '[' + QByteArray::number(int(tdesc.lpadesc->rgbounds[index].cElements)) + ']';
}
break;
case VT_USERDEFINED:
@@ -2114,7 +2123,7 @@ void MetaObjectGenerator::readClassInfo()
// Read class information
IProvideClassInfo *provideClassInfo = 0;
if (d)
- d->ptr->QueryInterface(IID_IProvideClassInfo, (void**)&provideClassInfo);
+ d->ptr->QueryInterface(IID_IProvideClassInfo, reinterpret_cast<void **>(&provideClassInfo));
if (provideClassInfo) {
provideClassInfo->GetClassInfo(&classInfo);
TYPEATTR *typeattr = 0;
@@ -2142,7 +2151,7 @@ void MetaObjectGenerator::readClassInfo()
if (d->tryCache && !coClassID.isEmpty())
cacheKey = QString::fromLatin1("%1$%2$%3$%4").arg(coClassID)
- .arg((int)d->useEventSink).arg((int)d->useClassInfo).arg((int)qax_dispatchEqualsIDispatch);
+ .arg(d->useEventSink).arg(d->useClassInfo).arg(int(qax_dispatchEqualsIDispatch));
}
UINT index = 0;
@@ -2171,16 +2180,16 @@ void MetaObjectGenerator::readClassInfo()
tlfile = controls.value(QLatin1String("/Classes/CLSID/") + that->control() + QLatin1String("/LocalServer32/.")).toString();
}
if (!tlfile.isEmpty()) {
- LoadTypeLib((OLECHAR*)tlfile.utf16(), &typelib);
+ LoadTypeLib(reinterpret_cast<const OLECHAR *>(tlfile.utf16()), &typelib);
if (!typelib) {
tlfile.truncate(tlfile.lastIndexOf(QLatin1Char('.')));
tlfile += QLatin1String(".tlb");
- LoadTypeLib((OLECHAR*)tlfile.utf16(), &typelib);
+ LoadTypeLib(reinterpret_cast<const OLECHAR *>(tlfile.utf16()), &typelib);
}
if (!typelib) {
tlfile.truncate(tlfile.lastIndexOf(QLatin1Char('.')));
tlfile.append(QLatin1String(".olb"));
- LoadTypeLib((OLECHAR*)tlfile.utf16(), &typelib);
+ LoadTypeLib(reinterpret_cast<const OLECHAR *>(tlfile.utf16()), &typelib);
}
}
}
@@ -2192,7 +2201,7 @@ void MetaObjectGenerator::readClassInfo()
TYPEATTR *classAttr;
classInfo->GetTypeAttr(&classAttr);
if (classAttr) {
- for (int i = 0; i < classAttr->cImplTypes; ++i) {
+ for (UINT i = 0; i < classAttr->cImplTypes; ++i) {
int typeFlags = 0;
classInfo->GetImplTypeFlags(i, &typeFlags);
if (typeFlags & IMPLTYPEFLAG_FSOURCE)
@@ -2234,7 +2243,7 @@ void MetaObjectGenerator::readClassInfo()
// ### event interfaces!!
if (!interfaceID.isEmpty())
cacheKey = QString::fromLatin1("%1$%2$%3$%4").arg(interfaceID)
- .arg((int)d->useEventSink).arg((int)d->useClassInfo).arg((int)qax_dispatchEqualsIDispatch);
+ .arg(d->useEventSink).arg(d->useClassInfo).arg(int(qax_dispatchEqualsIDispatch));
}
}
@@ -2276,7 +2285,7 @@ void MetaObjectGenerator::readEnumInfo()
// Get the name of the enumeration
BSTR enumname;
QByteArray enumName;
- if (typelib->GetDocumentation(i, &enumname, 0, 0, 0) == S_OK) {
+ if (typelib->GetDocumentation(INT(i), &enumname, 0, 0, 0) == S_OK) {
enumName = QString::fromWCharArray(enumname).toLatin1();
SysFreeString(enumname);
} else {
@@ -2288,7 +2297,7 @@ void MetaObjectGenerator::readEnumInfo()
enuminfo->GetTypeAttr(&typeattr);
if (typeattr) {
// Get all values of the enumeration
- for (UINT vd = 0; vd < (UINT)typeattr->cVars; ++vd) {
+ for (UINT vd = 0; vd < typeattr->cVars; ++vd) {
VARDESC *vardesc = 0;
enuminfo->GetVarDesc(vd, &vardesc);
if (vardesc && vardesc->varkind == VAR_CONST) {
@@ -2342,7 +2351,7 @@ void MetaObjectGenerator::addSetterSlot(const QByteArray &property)
if (isupper(prototype.at(0))) {
prototype.insert(0, "Set");
} else {
- prototype[0] = toupper(prototype[0]);
+ prototype[0] = char(toupper(prototype[0]));
prototype.insert(0, "set");
}
const QByteArray type = propertyType(property);
@@ -2541,7 +2550,7 @@ void MetaObjectGenerator::readFuncsInfo(ITypeInfo *typeinfo, ushort nFuncs)
set = "Set";
} else {
set = "set";
- prototype[0] = toupper(prototype[0]);
+ prototype[0] = char(toupper(prototype[0]));
}
prototype = set + prototype;
@@ -2759,7 +2768,7 @@ void MetaObjectGenerator::readEventInterface(ITypeInfo *eventinfo, IConnectionPo
}
// get information about all event functions
- for (UINT fd = 0; fd < (UINT)eventattr->cFuncs; ++fd) {
+ for (UINT fd = 0; fd < eventattr->cFuncs; ++fd) {
FUNCDESC *funcdesc;
eventinfo->GetFuncDesc(fd, &funcdesc);
if (!funcdesc)
@@ -2810,7 +2819,7 @@ void MetaObjectGenerator::readEventInfo()
int event_serial = 0;
IConnectionPointContainer *cpoints = 0;
if (d && d->useEventSink)
- d->ptr->QueryInterface(IID_IConnectionPointContainer, (void**)&cpoints);
+ d->ptr->QueryInterface(IID_IConnectionPointContainer, reinterpret_cast<void **>(&cpoints));
if (cpoints) {
// Get connection point enumerator
IEnumConnectionPoints *epoints = 0;
@@ -2869,7 +2878,7 @@ void MetaObjectGenerator::readEventInfo()
TYPEATTR *typeattr = 0;
classInfo->GetTypeAttr(&typeattr);
if (typeattr) {
- for (int i = 0; i < typeattr->cImplTypes; ++i) {
+ for (UINT i = 0; i < typeattr->cImplTypes; ++i) {
int flags = 0;
classInfo->GetImplTypeFlags(i, &flags);
if (!(flags & IMPLTYPEFLAG_FSOURCE))
@@ -2917,7 +2926,7 @@ QMetaObject *MetaObjectGenerator::tryCache()
d->cachedMetaObject = true;
IConnectionPointContainer *cpoints = 0;
- d->ptr->QueryInterface(IID_IConnectionPointContainer, (void**)&cpoints);
+ d->ptr->QueryInterface(IID_IConnectionPointContainer, reinterpret_cast<void **>(&cpoints));
if (cpoints) {
foreach (const QUuid &iid, d->metaobj->connectionInterfaces) {
IConnectionPoint *cpoint = 0;
@@ -2951,9 +2960,9 @@ static uint nameToTypeInfo(const QByteArray &typeName, QMetaStringTable &strings
{
int id = nameToBuiltinType(typeName);
if (id != QMetaType::UnknownType)
- return id;
+ return uint(id);
else
- return IsUnresolvedType | strings.enter(typeName);
+ return IsUnresolvedType | uint(strings.enter(typeName));
}
// Returns the sum of all parameters (including return type) for the given
@@ -3000,7 +3009,7 @@ QMetaObject *MetaObjectGenerator::metaObject(const QMetaObject *parentObject, co
- signal_list.count() // return "parameters" don't have names
- slot_list.count(); // ditto
- uint int_data_size = MetaObjectPrivateFieldCount;
+ int int_data_size = MetaObjectPrivateFieldCount;
int_data_size += classinfo_list.count() * 2;
int_data_size += (signal_list.count() + slot_list.count()) * 5 + paramsDataSize;
int_data_size += property_list.count() * 3;
@@ -3033,7 +3042,7 @@ QMetaObject *MetaObjectGenerator::metaObject(const QMetaObject *parentObject, co
classNameForMetaObject = that->className();
QMetaStringTable strings(classNameForMetaObject);
- uint offset = header->classInfoData;
+ int offset = header->classInfoData;
// each class info in form key\0value\0
typedef QMap<QByteArray, QByteArray>::ConstIterator ClassInfoConstIterator;
@@ -3041,12 +3050,12 @@ QMetaObject *MetaObjectGenerator::metaObject(const QMetaObject *parentObject, co
for (ClassInfoConstIterator it = classinfo_list.begin(); it != cend; ++it) {
QByteArray key(it.key());
QByteArray value(it.value());
- int_data[offset++] = strings.enter(key);
- int_data[offset++] = strings.enter(value);
+ int_data[offset++] = uint(strings.enter(key));
+ int_data[offset++] = uint(strings.enter(value));
}
- Q_ASSERT(offset == uint(header->methodData));
+ Q_ASSERT(offset == header->methodData);
- uint paramsOffset = offset + header->methodCount * 5;
+ int paramsOffset = offset + header->methodCount * 5;
// add each method:
for (int x = 0; x < 2; ++x) {
// Signals must be added before other methods, to match moc.
@@ -3062,12 +3071,11 @@ QMetaObject *MetaObjectGenerator::metaObject(const QMetaObject *parentObject, co
metaobj->realPrototype.insert(prototype, it.value().realPrototype);
int argc = paramTypeNames.size();
QByteArray tag;
- int flags = it.value().flags;
- int_data[offset++] = strings.enter(name);
- int_data[offset++] = argc;
- int_data[offset++] = paramsOffset;
- int_data[offset++] = strings.enter(tag);
- int_data[offset++] = flags;
+ int_data[offset++] = uint(strings.enter(name));
+ int_data[offset++] = uint(argc);
+ int_data[offset++] = uint(paramsOffset);
+ int_data[offset++] = uint(strings.enter(tag));
+ int_data[offset++] = uint(it.value().flags);
// Parameter types
for (int i = -1; i < argc; ++i) {
@@ -3076,13 +3084,13 @@ QMetaObject *MetaObjectGenerator::metaObject(const QMetaObject *parentObject, co
}
// Parameter names
for (int i = 0; i < argc; ++i)
- int_data[paramsOffset++] = strings.enter(paramNames.at(i));
+ int_data[paramsOffset++] = uint(strings.enter(paramNames.at(i)));
}
}
- Q_ASSERT(offset == uint(header->methodData + header->methodCount * 5));
+ Q_ASSERT(offset == header->methodData + header->methodCount * 5);
Q_ASSERT(paramsOffset = header->propertyData);
offset += paramsDataSize;
- Q_ASSERT(offset == uint(header->propertyData));
+ Q_ASSERT(offset == header->propertyData);
// each property in form name\0type\0
typedef QMap<QByteArray, Property>::ConstIterator PropertyMapConstIterator;
@@ -3094,37 +3102,33 @@ QMetaObject *MetaObjectGenerator::metaObject(const QMetaObject *parentObject, co
QByteArray realType(it.value().realType);
if (!realType.isEmpty() && realType != type)
metaobj->realPrototype.insert(name, realType);
- uint flags = it.value().flags;
-
- int_data[offset++] = strings.enter(name);
+ int_data[offset++] = uint(strings.enter(name));
int_data[offset++] = nameToTypeInfo(type, strings);
- int_data[offset++] = flags;
+ int_data[offset++] = uint(it.value().flags);
}
- Q_ASSERT(offset == uint(header->enumeratorData));
+ Q_ASSERT(offset == header->enumeratorData);
int value_offset = offset + enum_list.count() * 4;
// each enum in form name\0
for (EnumListMapConstIterator it = enum_list.begin(); it != ecend; ++it) {
QByteArray name(it.key());
- int flags = 0x0; // 0x1 for flag?
int count = it.value().count();
- int_data[offset++] = strings.enter(name);
- int_data[offset++] = flags;
- int_data[offset++] = count;
- int_data[offset++] = value_offset;
+ int_data[offset++] = uint(strings.enter(name));
+ int_data[offset++] = 0x0; // 0x1 for flag?
+ int_data[offset++] = uint(count);
+ int_data[offset++] = uint(value_offset);
value_offset += count * 2;
}
- Q_ASSERT(offset == uint(header->enumeratorData + enum_list.count() * 4));
+ Q_ASSERT(offset == header->enumeratorData + enum_list.count() * 4);
// 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 value = (*it2).second;
- int_data[offset++] = strings.enter(key);
- int_data[offset++] = value;
+ int_data[offset++] = uint(strings.enter(key));
+ int_data[offset++] = uint((*it2).second);
}
}
Q_ASSERT(offset == int_data_size-1);
@@ -3255,7 +3259,7 @@ const QMetaObject *QAxBase::metaObject() const
if (!d->ptr || !d->useMetaObject)
return fallbackMetaObject();
- MetaObjectGenerator generator((QAxBase*)this, d);
+ MetaObjectGenerator generator(const_cast<QAxBase *>(this), d);
return generator.metaObject(parentObject);
}
@@ -3275,7 +3279,7 @@ void QAxBase::connectNotify()
IEnumConnectionPoints *epoints = 0;
if (d->ptr && d->useEventSink) {
IConnectionPointContainer *cpoints = 0;
- d->ptr->QueryInterface(IID_IConnectionPointContainer, (void**)&cpoints);
+ d->ptr->QueryInterface(IID_IConnectionPointContainer, reinterpret_cast<void **>(&cpoints));
if (!cpoints)
return;
@@ -3392,7 +3396,7 @@ static bool checkHRESULT(HRESULT hres, EXCEPINFO *exc, QAxBase *that, const QStr
case DISP_E_EXCEPTION:
{
bool printWarning = true;
- unsigned short code = -1;
+ unsigned short code = ushort(-1);
QString source, desc, help;
const QMetaObject *mo = that->metaObject();
int exceptionSignal = mo->indexOfSignal("exception(int,QString,QString,QString)");
@@ -3541,12 +3545,12 @@ int QAxBase::internalProperty(QMetaObject::Call call, int index, void **v)
// map void* to VARIANTARG via QVariant
QVariant qvar;
if (prop.isEnumType()) {
- qvar = *(int*)v[0];
+ qvar = *reinterpret_cast<const int *>(v[0]);
proptype = 0;
} else {
int typeId = prop.userType();
if (typeId == int(QMetaType::QVariant)) {
- qvar = *(QVariant*)v[0];
+ qvar = *reinterpret_cast<const QVariant *>(v[0]);
proptype = 0;
} else {
qvar = QVariant(typeId, v[0]);
@@ -3613,7 +3617,7 @@ int QAxBase::internalInvoke(QMetaObject::Call call, int index, void **v)
// setup the parameters
DISPPARAMS params;
DISPID dispidNamed = DISPID_PROPERTYPUT;
- params.cArgs = d->metaobj->numParameter(signature);
+ params.cArgs = UINT(d->metaobj->numParameter(signature));
params.cNamedArgs = isProperty ? 1 : 0;
params.rgdispidNamedArgs = isProperty ? &dispidNamed : 0;
params.rgvarg = 0;
@@ -3628,7 +3632,7 @@ int QAxBase::internalInvoke(QMetaObject::Call call, int index, void **v)
VariantInit(vp);
int p;
- for (p = 0; p < (int)params.cArgs; ++p) {
+ for (p = 0; p < int(params.cArgs); ++p) {
bool out;
QByteArray type = d->metaobj->paramType(signature, p, &out);
QVariant::Type vt = QVariant::nameToType(type);
@@ -3639,21 +3643,21 @@ int QAxBase::internalInvoke(QMetaObject::Call call, int index, void **v)
if (!qvar.isValid()) {
if (type == "IDispatch*") {
if (out)
- qvar.setValue(*(IDispatch***)v[p+1]);
+ qvar.setValue(*reinterpret_cast<IDispatch ***>(v[p+1]));
else
- qvar.setValue(*(IDispatch**)v[p+1]);
+ qvar.setValue(*reinterpret_cast<IDispatch **>(v[p+1]));
} else if (type == "IUnknown*") {
- qvar.setValue(*(IUnknown**)v[p+1]);
+ qvar.setValue(*reinterpret_cast<IUnknown **>(v[p+1]));
} else if (type == "QVariant") {
- qvar = *(QVariant*)v[p + 1];
+ qvar = *reinterpret_cast<const QVariant *>(v[p + 1]);
} else if (mo->indexOfEnumerator(type) != -1) {
- qvar = *(int*)v[p + 1];
+ qvar = *reinterpret_cast<const int *>(v[p + 1]);
} else {
qvar = QVariant(QMetaType::type(type), v[p + 1]);
}
}
- QVariantToVARIANT(qvar, params.rgvarg[params.cArgs - p - 1], type, out);
+ QVariantToVARIANT(qvar, params.rgvarg[int(params.cArgs) - p - 1], type, out);
}
// call the method
@@ -3672,18 +3676,18 @@ int QAxBase::internalInvoke(QMetaObject::Call call, int index, void **v)
QVariantToVoidStar(VARIANTToQVariant(ret, slot.typeName()), v[0], slot.typeName());
// update out parameters
- for (p = 0; p < (int)params.cArgs; ++p) {
+ for (p = 0; p < int(params.cArgs); ++p) {
bool out;
QByteArray ptype = d->metaobj->paramType(signature, p, &out);
if (out) {
- VARIANTARG &var = params.rgvarg[params.cArgs - p - 1];
+ VARIANTARG &var = params.rgvarg[int(params.cArgs) - p - 1];
QVariantToVoidStar(VARIANTToQVariant(var, ptype), v[p+1], ptype);
if (var.vt == (VT_DISPATCH | VT_BYREF))
VariantInit(&var); // Prevent clearVARIANT() from releasing returned IDispatch* out parameters.
}
}
// clean up
- for (p = 0; p < (int)params.cArgs; ++p)
+ for (p = 0; p < int(params.cArgs); ++p)
clearVARIANT(params.rgvarg+p);
if (params.rgvarg != static_rgvarg)
delete [] params.rgvarg;
@@ -3809,7 +3813,7 @@ bool QAxBase::dynamicCallHelper(const char *name, void *inout, QList<QVariant> &
QByteArray function(normFunction);
VARIANT staticarg[QAX_NUM_PARAMS];
VARIANT *arg = 0;
- VARIANTARG *res = (VARIANTARG*)inout;
+ VARIANTARG *res = reinterpret_cast<VARIANTARG *>(inout);
unsigned short disptype;
@@ -3839,7 +3843,7 @@ bool QAxBase::dynamicCallHelper(const char *name, void *inout, QList<QVariant> &
int index = 0;
bool inString = false;
bool inEscape = false;
- while (index < (int)args.length()) {
+ while (index < args.length()) {
QChar cc = *c;
++c;
++index;
@@ -3975,7 +3979,7 @@ bool QAxBase::dynamicCallHelper(const char *name, void *inout, QList<QVariant> &
DISPPARAMS params;
DISPID dispidNamed = DISPID_PROPERTYPUT;
- params.cArgs = varc;
+ params.cArgs = UINT(varc);
params.cNamedArgs = (disptype == DISPATCH_PROPERTYPUT) ? 1 : 0;
params.rgdispidNamedArgs = (disptype == DISPATCH_PROPERTYPUT) ? &dispidNamed : 0;
params.rgvarg = arg;
@@ -3997,7 +4001,7 @@ bool QAxBase::dynamicCallHelper(const char *name, void *inout, QList<QVariant> &
if (arg && arg != staticarg)
delete[] arg;
- return checkHRESULT(hres, &excepinfo, this, QLatin1String(function), varc-argerr-1);
+ return checkHRESULT(hres, &excepinfo, this, QLatin1String(function), uint(varc) - argerr - 1);
}
/*!
@@ -4324,14 +4328,14 @@ QAxBase::PropertyBag QAxBase::propertyBag() const
PropertyBag result;
if (!d->ptr && !d->initialized) {
- ((QAxBase*)this)->initialize(&d->ptr);
+ const_cast<QAxBase *>(this)->initialize(&d->ptr);
d->initialized = true;
}
if (isNull())
return result;
IPersistPropertyBag *persist = 0;
- d->ptr->QueryInterface(IID_IPersistPropertyBag, (void**)&persist);
+ d->ptr->QueryInterface(IID_IPersistPropertyBag, reinterpret_cast<void **>(&persist));
if (persist) {
QtPropertyBag *pbag = new QtPropertyBag();
pbag->AddRef();
@@ -4373,7 +4377,7 @@ void QAxBase::setPropertyBag(const PropertyBag &bag)
if (isNull())
return;
IPersistPropertyBag *persist = 0;
- d->ptr->QueryInterface(IID_IPersistPropertyBag, (void**)&persist);
+ d->ptr->QueryInterface(IID_IPersistPropertyBag, reinterpret_cast<void **>(&persist));
if (persist) {
QtPropertyBag *pbag = new QtPropertyBag();
pbag->map = bag;
@@ -4440,7 +4444,7 @@ bool QAxBase::isNull() const
QVariant QAxBase::asVariant() const
{
if (!d->ptr && !d->initialized) {
- ((QAxBase*)this)->initialize(&d->ptr);
+ const_cast<QAxBase *>(this)->initialize(&d->ptr);
d->initialized = true;
}
@@ -4471,8 +4475,8 @@ void *qax_createObjectWrapper(int metaType, IUnknown *iface)
if (!iface)
return 0;
- QAxObject *object = (QAxObject*)QMetaType::create(metaType, 0);
- QAxBasePrivate *d = object->d;
+ void *object = QMetaType::create(metaType, 0);
+ QAxBasePrivate *d = reinterpret_cast<const QAxObject *>(object)->d;
d->ptr = iface;
d->initialized = true;
diff --git a/src/activeqt/container/qaxbase.h b/src/activeqt/container/qaxbase.h
index 7b667af..f83c920 100644
--- a/src/activeqt/container/qaxbase.h
+++ b/src/activeqt/container/qaxbase.h
@@ -64,7 +64,7 @@ class QAxBase
public:
typedef QMap<QString, QVariant> PropertyBag;
- QAxBase(IUnknown *iface = 0);
+ explicit QAxBase(IUnknown *iface = Q_NULLPTR);
virtual ~QAxBase();
QString control() const;
@@ -173,14 +173,14 @@ private:
template <> inline QAxBase *qobject_cast<QAxBase*>(const QObject *o)
{
- void *result = o ? const_cast<QObject *>(o)->qt_metacast("QAxBase") : 0;
- return (QAxBase*)(result);
+ void *result = o ? const_cast<QObject *>(o)->qt_metacast("QAxBase") : Q_NULLPTR;
+ return static_cast<QAxBase *>(result);
}
template <> inline QAxBase *qobject_cast<QAxBase*>(QObject *o)
{
- void *result = o ? o->qt_metacast("QAxBase") : 0;
- return (QAxBase*)(result);
+ void *result = o ? o->qt_metacast("QAxBase") : Q_NULLPTR;
+ return static_cast<QAxBase *>(result);
}
extern QString qax_generateDocumentation(QAxBase *);
diff --git a/src/activeqt/container/qaxdump.cpp b/src/activeqt/container/qaxdump.cpp
index be22892..2d519e1 100644
--- a/src/activeqt/container/qaxdump.cpp
+++ b/src/activeqt/container/qaxdump.cpp
@@ -59,7 +59,7 @@ QString qax_docuFromName(ITypeInfo *typeInfo, const QString &name)
MEMBERID memId;
BSTR names = QStringToBSTR(name);
- typeInfo->GetIDsOfNames((BSTR*)&names, 1, &memId);
+ typeInfo->GetIDsOfNames(&names, 1, &memId);
SysFreeString(names);
if (memId != DISPID_UNKNOWN) {
BSTR docStringBstr, helpFileBstr;
@@ -73,7 +73,8 @@ QString qax_docuFromName(ITypeInfo *typeInfo, const QString &name)
if (!docString.isEmpty())
docu += docString + QLatin1String("\n");
if (!helpFile.isEmpty())
- docu += QString::fromLatin1("For more information, see help context %1 in %2.").arg((uint)helpContext).arg(helpFile);
+ docu += QString::fromLatin1("For more information, see help context %1 in %2.")
+ .arg(uint(helpContext)).arg(helpFile);
}
}
@@ -134,7 +135,7 @@ QString qax_generateDocumentation(QAxBase *that)
ITypeInfo *typeInfo = 0;
IDispatch *dispatch = 0;
- that->queryInterface(IID_IDispatch, (void**)&dispatch);
+ that->queryInterface(IID_IDispatch, reinterpret_cast<void **>(&dispatch));
if (dispatch)
dispatch->GetTypeInfo(0, LOCALE_SYSTEM_DEFAULT, &typeInfo);
@@ -151,7 +152,7 @@ QString qax_generateDocumentation(QAxBase *that)
stream << "<h3>Interfaces</h3>" << endl;
stream << "<ul>" << endl;
const char *inter = 0;
- int interCount = 1;
+ UINT interCount = 1;
while ((inter = mo->classInfo(mo->indexOfClassInfo("Interface " + QByteArray::number(interCount))).value())) {
stream << "<li>" << inter << endl;
interCount++;
@@ -352,7 +353,7 @@ QString qax_generateDocumentation(QAxBase *that)
setterSlot = "Set" + name;
} else {
QByteArray nameUp = name;
- nameUp[0] = toupper(nameUp.at(0));
+ nameUp[0] = char(toupper(nameUp.at(0)));
setterSlot = "set" + nameUp;
}
detail += QLatin1String("<a href=\"#") + QString::fromLatin1(setterSlot) + QLatin1String("\">") +
diff --git a/src/activeqt/container/qaxobject.cpp b/src/activeqt/container/qaxobject.cpp
index a2ea2dd..dc5189c 100644
--- a/src/activeqt/container/qaxobject.cpp
+++ b/src/activeqt/container/qaxobject.cpp
@@ -162,8 +162,8 @@ const QMetaObject *QAxObject::parentMetaObject() const
*/
void *QAxObject::qt_metacast(const char *cname)
{
- if (!qstrcmp(cname, "QAxObject")) return (void*)this;
- if (!qstrcmp(cname, "QAxBase")) return (QAxBase*)this;
+ if (!qstrcmp(cname, "QAxObject")) return static_cast<void *>(this);
+ if (!qstrcmp(cname, "QAxBase")) return static_cast<QAxBase *>(this);
return QObject::qt_metacast(cname);
}
@@ -212,7 +212,7 @@ bool QAxObject::doVerb(const QString &verb)
if (!verbs().contains(verb))
return false;
IOleObject *ole = 0;
- queryInterface(IID_IOleObject, (void**)&ole);
+ queryInterface(IID_IOleObject, reinterpret_cast<void **>(&ole));
if (!ole)
return false;
diff --git a/src/activeqt/container/qaxobject.h b/src/activeqt/container/qaxobject.h
index fc09a70..f7e16d2 100644
--- a/src/activeqt/container/qaxobject.h
+++ b/src/activeqt/container/qaxobject.h
@@ -53,9 +53,9 @@ public:
QObject* qObject() const Q_DECL_OVERRIDE { return static_cast<QObject *>(const_cast<QAxObject *>(this)); }
const char *className() const Q_DECL_OVERRIDE;
- QAxObject(QObject *parent = 0);
- QAxObject(const QString &c, QObject *parent = 0);
- QAxObject(IUnknown *iface, QObject *parent = 0);
+ explicit QAxObject(QObject *parent = Q_NULLPTR);
+ explicit QAxObject(const QString &c, QObject *parent = Q_NULLPTR);
+ explicit QAxObject(IUnknown *iface, QObject *parent = Q_NULLPTR);
~QAxObject();
bool doVerb(const QString &verb);
@@ -70,14 +70,14 @@ private:
template <> inline QAxObject *qobject_cast<QAxObject*>(const QObject *o)
{
- void *result = o ? const_cast<QObject *>(o)->qt_metacast("QAxObject") : 0;
- return (QAxObject*)(result);
+ void *result = o ? const_cast<QObject *>(o)->qt_metacast("QAxObject") : Q_NULLPTR;
+ return reinterpret_cast<QAxObject*>(result);
}
template <> inline QAxObject *qobject_cast<QAxObject*>(QObject *o)
{
- void *result = o ? o->qt_metacast("QAxObject") : 0;
- return (QAxObject*)(result);
+ void *result = o ? o->qt_metacast("QAxObject") : Q_NULLPTR;
+ return reinterpret_cast<QAxObject*>(result);
}
QT_END_NAMESPACE
diff --git a/src/activeqt/container/qaxscript.cpp b/src/activeqt/container/qaxscript.cpp
index 861edab..7c84e4b 100644
--- a/src/activeqt/container/qaxscript.cpp
+++ b/src/activeqt/container/qaxscript.cpp
@@ -151,11 +151,11 @@ HRESULT WINAPI QAxScriptSite::QueryInterface(REFIID iid, void **ppvObject)
{
*ppvObject = 0;
if (iid == IID_IUnknown)
- *ppvObject = (IUnknown*)(IActiveScriptSite*)this;
+ *ppvObject = static_cast<IUnknown *>(static_cast<IActiveScriptSite *>(this));
else if (iid == IID_IActiveScriptSite)
- *ppvObject = (IActiveScriptSite*)this;
+ *ppvObject = static_cast<IActiveScriptSite *>(this);
else if (iid == IID_IActiveScriptSiteWindow)
- *ppvObject = (IActiveScriptSiteWindow*)this;
+ *ppvObject = static_cast<IActiveScriptSiteWindow *>(this);
else
return E_NOINTERFACE;
@@ -196,10 +196,10 @@ HRESULT WINAPI QAxScriptSite::GetItemInfo(LPCOLESTR pstrName, DWORD mask, IUnkno
return TYPE_E_ELEMENTNOTFOUND;
if (mask & SCRIPTINFO_IUNKNOWN)
- object->queryInterface(IID_IUnknown, (void**)item);
+ object->queryInterface(IID_IUnknown, reinterpret_cast<void **>(item));
if (mask & SCRIPTINFO_ITYPEINFO) {
IProvideClassInfo *classInfo = 0;
- object->queryInterface(IID_IProvideClassInfo, (void**)&classInfo);
+ object->queryInterface(IID_IProvideClassInfo, reinterpret_cast<void **>(&classInfo));
if (classInfo) {
classInfo->GetClassInfo(type);
classInfo->Release();
@@ -291,7 +291,8 @@ HRESULT WINAPI QAxScriptSite::OnScriptError(IActiveScriptError *error)
SysFreeString(exception.bstrDescription);
SysFreeString(exception.bstrHelpFile);
- emit script->error(exception.wCode, QString::fromWCharArray(exception.bstrDescription), lineNumber, lineText);
+ emit script->error(exception.wCode, QString::fromWCharArray(exception.bstrDescription),
+ int(lineNumber), lineText);
return S_OK;
}
@@ -461,16 +462,16 @@ bool QAxScriptEngine::initialize(IUnknown **ptr)
return false;
CLSID clsid;
- HRESULT hres = CLSIDFromProgID((wchar_t*)script_language.utf16(), &clsid);
+ HRESULT hres = CLSIDFromProgID(reinterpret_cast<const wchar_t *>(script_language.utf16()), &clsid);
if(FAILED(hres))
return false;
- CoCreateInstance(clsid, 0, CLSCTX_INPROC_SERVER, IID_IActiveScript, (void**)&engine);
+ CoCreateInstance(clsid, 0, CLSCTX_INPROC_SERVER, IID_IActiveScript, reinterpret_cast<void **>(&engine));
if (!engine)
return false;
IActiveScriptParse *parser = 0;
- engine->QueryInterface(IID_IActiveScriptParse, (void**)&parser);
+ engine->QueryInterface(IID_IActiveScriptParse, reinterpret_cast<void **>(&parser));
if (!parser) {
engine->Release();
engine = 0;
@@ -510,7 +511,7 @@ bool QAxScriptEngine::initialize(IUnknown **ptr)
IDispatch *scriptDispatch = 0;
engine->GetScriptDispatch(0, &scriptDispatch);
if (scriptDispatch) {
- scriptDispatch->QueryInterface(IID_IUnknown, (void**)ptr);
+ scriptDispatch->QueryInterface(IID_IUnknown, reinterpret_cast<void **>(ptr));
scriptDispatch->Release();
}
#endif
@@ -535,7 +536,7 @@ bool QAxScriptEngine::hasIntrospection() const
return false;
IDispatch *scriptDispatch = 0;
- QAxBase::queryInterface(IID_IDispatch, (void**)&scriptDispatch);
+ QAxBase::queryInterface(IID_IDispatch, reinterpret_cast<void **>(&scriptDispatch));
if (!scriptDispatch)
return false;
@@ -579,7 +580,7 @@ QAxScriptEngine::State QAxScriptEngine::state() const
#ifndef QT_NO_QAXSCRIPT
SCRIPTSTATE state;
engine->GetScriptState(&state);
- return (State)state;
+ return State(state);
#else
return Uninitialized;
#endif
@@ -595,7 +596,7 @@ void QAxScriptEngine::setState(State st)
if (!engine)
return;
- engine->SetScriptState((SCRIPTSTATE)st);
+ engine->SetScriptState(SCRIPTSTATE(st));
#else
Q_UNUSED(st);
#endif
@@ -611,7 +612,8 @@ void QAxScriptEngine::addItem(const QString &name)
if (!engine)
return;
- engine->AddNamedItem((wchar_t*)name.utf16(), SCRIPTITEM_ISSOURCE|SCRIPTITEM_ISVISIBLE);
+ engine->AddNamedItem(reinterpret_cast<const wchar_t *>(name.utf16()),
+ SCRIPTITEM_ISSOURCE|SCRIPTITEM_ISVISIBLE);
#else
Q_UNUSED(name);
#endif
@@ -1153,7 +1155,7 @@ bool QAxScriptManager::registerEngine(const QString &name, const QString &extens
return false;
CLSID clsid;
- HRESULT hres = CLSIDFromProgID((wchar_t*)name.utf16(), &clsid);
+ const HRESULT hres = CLSIDFromProgID(reinterpret_cast<const wchar_t *>(name.utf16()), &clsid);
if (hres != S_OK)
return false;
diff --git a/src/activeqt/container/qaxscript.h b/src/activeqt/container/qaxscript.h
index ef2ae0a..67c94da 100644
--- a/src/activeqt/container/qaxscript.h
+++ b/src/activeqt/container/qaxscript.h
@@ -149,7 +149,7 @@ class QAxScriptManager : public QObject
Q_OBJECT
public:
- QAxScriptManager(QObject *parent = 0);
+ explicit QAxScriptManager(QObject *parent = Q_NULLPTR);
~QAxScriptManager();
void addObject(QAxBase *object);
@@ -212,7 +212,7 @@ inline QAxScriptEngine *QAxScript::scriptEngine() const
inline bool QAxScriptEngine::isValid() const
{
- return engine != 0;
+ return engine != Q_NULLPTR;
}
inline QString QAxScriptEngine::scriptLanguage() const
diff --git a/src/activeqt/container/qaxselect.cpp b/src/activeqt/container/qaxselect.cpp
index 0b40e78..0fc7d62 100644
--- a/src/activeqt/container/qaxselect.cpp
+++ b/src/activeqt/container/qaxselect.cpp
@@ -170,18 +170,20 @@ static QList<Control> readControls(const wchar_t *rootKey, unsigned wordSize)
if (result == ERROR_SUCCESS) {
RegCloseKey(subKey);
szBuffer = sizeof(buffer) / sizeof(wchar_t);
- RegistryQueryValue(classesKey, buffer, (LPBYTE)buffer, &szBuffer);
+ RegistryQueryValue(classesKey, buffer, reinterpret_cast<LPBYTE>(buffer), &szBuffer);
Control control;
control.clsid = clsid;
control.wordSize = wordSize;
control.name = QString::fromWCharArray(buffer);
szBuffer = sizeof(buffer) / sizeof(wchar_t);
- if (querySubKeyValue(classesKey, clsid + QStringLiteral("\\InprocServer32"), (LPBYTE)buffer, &szBuffer)) {
+ if (querySubKeyValue(classesKey, clsid + QStringLiteral("\\InprocServer32"),
+ reinterpret_cast<LPBYTE>(buffer), &szBuffer)) {
control.dll = QString::fromWCharArray(buffer);
control.dll.replace(systemRootPattern, systemRoot);
}
szBuffer = sizeof(buffer) / sizeof(wchar_t);
- if (querySubKeyValue(classesKey, clsid + QStringLiteral("\\VERSION"), (LPBYTE)buffer, &szBuffer))
+ if (querySubKeyValue(classesKey, clsid + QStringLiteral("\\VERSION"),
+ reinterpret_cast<LPBYTE>(buffer), &szBuffer))
control.version = QString::fromWCharArray(buffer);
controls.push_back(control);
}
diff --git a/src/activeqt/container/qaxselect.h b/src/activeqt/container/qaxselect.h
index 0b21c02..160b436 100644
--- a/src/activeqt/container/qaxselect.h
+++ b/src/activeqt/container/qaxselect.h
@@ -51,7 +51,7 @@ class QAxSelect : public QDialog
{
Q_OBJECT
public:
- QAxSelect(QWidget *parent = 0, Qt::WindowFlags flags = 0);
+ explicit QAxSelect(QWidget *parent = Q_NULLPTR, Qt::WindowFlags flags = Qt::WindowFlags());
~QAxSelect();
QString clsid() const;
diff --git a/src/activeqt/container/qaxwidget.cpp b/src/activeqt/container/qaxwidget.cpp
index 2dd4c31..bdc6e1d 100644
--- a/src/activeqt/container/qaxwidget.cpp
+++ b/src/activeqt/container/qaxwidget.cpp
@@ -194,7 +194,7 @@ public:
RECT rcPos = qaxNativeWidgetRect(host);
return m_spOleObject->DoVerb(index, 0, this, 0,
- (HWND)host->winId(),
+ reinterpret_cast<HWND>(host->winId()),
&rcPos);
}
@@ -383,11 +383,11 @@ public:
private:
struct OleMenuItem {
OleMenuItem(HMENU hm = 0, int ID = 0, QMenu *menu = 0)
- : hMenu(hm), id(ID), subMenu(menu)
+ : hMenu(hm), subMenu(menu), id(ID)
{}
HMENU hMenu;
- int id;
QMenu *subMenu;
+ int id;
};
typedef QMap<QAction*, OleMenuItem> MenuItemMap;
@@ -469,7 +469,7 @@ Q_GLOBAL_STATIC(QAxNativeEventFilter, s_nativeEventFilter)
bool QAxNativeEventFilter::nativeEventFilter(const QByteArray &, void *m, long *)
{
- MSG *msg = (MSG*)m;
+ MSG *msg = static_cast<MSG *>(m);
const uint message = msg->message;
if (message == WM_DISPLAYCHANGE)
qaxClearCachedSystemLogicalDpi();
@@ -486,7 +486,7 @@ bool QAxNativeEventFilter::nativeEventFilter(const QByteArray &, void *m, long *
}
if (host)
ax = qobject_cast<QAxWidget*>(host->parentWidget());
- if (ax && msg->hwnd != (HWND)host->winId()) {
+ if (ax && msg->hwnd != reinterpret_cast<HWND>(host->winId())) {
if (message >= WM_KEYFIRST && message <= WM_KEYLAST) {
QAxClientSite *site = host->clientSite();
site->eventTranslated = true; // reset in QAxClientSite::TranslateAccelerator
@@ -503,7 +503,7 @@ bool QAxNativeEventFilter::nativeEventFilter(const QByteArray &, void *m, long *
;
if (mouseTbl[i]) {
- QEvent::Type type = (QEvent::Type)mouseTbl[++i];
+ const QEvent::Type type = static_cast<QEvent::Type>(mouseTbl[++i]);
int button = mouseTbl[++i];
if (type != QEvent::MouseMove || ax->hasMouseTracking() || button) {
if (type == QEvent::MouseMove)
@@ -514,9 +514,9 @@ bool QAxNativeEventFilter::nativeEventFilter(const QByteArray &, void *m, long *
const QPoint gpos = qaxFromNativePosition(ax, nativeGlobalPos);
QPoint pos = ax->mapFromGlobal(gpos);
- QMouseEvent e(type, pos, gpos, (Qt::MouseButton)button,
- translateMouseButtonState(msg->wParam),
- translateModifierState(msg->wParam));
+ QMouseEvent e(type, pos, gpos, static_cast<Qt::MouseButton>(button),
+ translateMouseButtonState(int(msg->wParam)),
+ translateModifierState(int(msg->wParam)));
QCoreApplication::sendEvent(ax, &e);
}
}
@@ -532,7 +532,7 @@ QAxClientSite::QAxClientSite(QAxWidget *c)
{
aggregatedObject = widget->createAggregate();
if (aggregatedObject) {
- aggregatedObject->controlling_unknown = (IUnknown*)(IDispatch*)this;
+ aggregatedObject->controlling_unknown = static_cast<IUnknown *>(static_cast<IDispatch *>(this));
aggregatedObject->the_object = c;
}
@@ -617,13 +617,12 @@ bool QAxClientSite::activateObject(bool initialized, const QByteArray &data)
spPSI->Release();
} else if (data.length()) { //try initializing using a IPersistStorage
IPersistStorage *spPS = 0;
- m_spOleObject->QueryInterface( IID_IPersistStorage, (void**)&spPS );
+ m_spOleObject->QueryInterface( IID_IPersistStorage, reinterpret_cast<void **>(&spPS));
if (spPS) {
- HGLOBAL hGlobal = GlobalAlloc(GMEM_MOVEABLE, data.length());
+ HGLOBAL hGlobal = GlobalAlloc(GMEM_MOVEABLE, size_t(data.length()));
if (hGlobal) {
- BYTE* pbData = (BYTE*)GlobalLock(hGlobal);
- if (pbData)
- memcpy(pbData, data.data(), data.length());
+ if (BYTE* pbData = static_cast<BYTE *>(GlobalLock(hGlobal)))
+ memcpy(pbData, data.data(), size_t(data.length()));
GlobalUnlock(hGlobal);
// open an IStorage on the data and pass it to Load
LPLOCKBYTES pLockBytes = 0;
@@ -648,11 +647,11 @@ bool QAxClientSite::activateObject(bool initialized, const QByteArray &data)
}
IViewObject *spViewObject = 0;
- m_spOleObject->QueryInterface(IID_IViewObject, (void**) &spViewObject);
+ m_spOleObject->QueryInterface(IID_IViewObject, reinterpret_cast<void **>(&spViewObject));
m_spOleObject->Advise(this, &m_dwOleObject);
IAdviseSink *spAdviseSink = 0;
- QueryInterface(IID_IAdviseSink, (void**)&spAdviseSink);
+ QueryInterface(IID_IAdviseSink, reinterpret_cast<void **>(&spAdviseSink));
if (spAdviseSink && spViewObject) {
if (spViewObject)
spViewObject->SetAdvise(DVASPECT_CONTENT, 0, spAdviseSink);
@@ -684,12 +683,12 @@ bool QAxClientSite::activateObject(bool initialized, const QByteArray &data)
RECT rcPos = qaxQRect2Rect(QRect(qaxNativeWidgetPosition(host), qaxToNativeSize(host, sizehint)));
- m_spOleObject->DoVerb(OLEIVERB_INPLACEACTIVATE, 0, (IOleClientSite*)this, 0,
- (HWND)host->winId(),
+ m_spOleObject->DoVerb(OLEIVERB_INPLACEACTIVATE, 0, static_cast<IOleClientSite *>(this), 0,
+ reinterpret_cast<HWND>(host->winId()),
&rcPos);
if (!m_spOleControl)
- m_spOleObject->QueryInterface(IID_IOleControl, (void**)&m_spOleControl);
+ m_spOleObject->QueryInterface(IID_IOleControl, reinterpret_cast<void **>(&m_spOleControl));
if (m_spOleControl) {
m_spOleControl->OnAmbientPropertyChange(DISPID_AMBIENT_BACKCOLOR);
m_spOleControl->OnAmbientPropertyChange(DISPID_AMBIENT_FORECOLOR);
@@ -708,9 +707,9 @@ bool QAxClientSite::activateObject(bool initialized, const QByteArray &data)
}
} else {
IObjectWithSite *spSite = 0;
- widget->queryInterface(IID_IObjectWithSite, (void**)&spSite);
+ widget->queryInterface(IID_IObjectWithSite, reinterpret_cast<void **>(&spSite));
if (spSite) {
- spSite->SetSite((IUnknown*)(IDispatch*)this);
+ spSite->SetSite(static_cast<IUnknown *>(static_cast<IDispatch *>(this)));
spSite->Release();
}
}
@@ -785,7 +784,7 @@ HRESULT WINAPI QAxClientSite::QueryInterface(REFIID iid, void **iface)
*iface = 0;
if (iid == IID_IUnknown) {
- *iface = (IUnknown*)(IDispatch*)this;
+ *iface = static_cast<IUnknown *>(static_cast<IDispatch *>(this));
} else {
HRESULT res = S_OK;
if (aggregatedObject)
@@ -796,29 +795,29 @@ HRESULT WINAPI QAxClientSite::QueryInterface(REFIID iid, void **iface)
if (!(*iface)) {
if (iid == IID_IDispatch)
- *iface = (IDispatch*)this;
+ *iface = static_cast<IDispatch *>(this);
else if (iid == IID_IOleClientSite)
- *iface = (IOleClientSite*)this;
+ *iface = static_cast<IOleClientSite *>(this);
else if (iid == IID_IOleControlSite)
- *iface = (IOleControlSite*)this;
+ *iface = static_cast<IOleControlSite *>(this);
else if (iid == IID_IOleWindow)
- *iface = (IOleWindow*)(IOleInPlaceSite*)this;
+ *iface = static_cast<IOleWindow *>(static_cast<IOleInPlaceSite *>(this));
else if (iid == IID_IOleInPlaceSite)
- *iface = (IOleInPlaceSite*)this;
+ *iface = static_cast<IOleInPlaceSite *>(this);
#ifdef QAX_SUPPORT_WINDOWLESS
else if (iid == IID_IOleInPlaceSiteEx)
- *iface = (IOleInPlaceSiteEx*)this;
+ *iface = static_cast<IOleInPlaceSiteEx *>(this);
else if (iid == IID_IOleInPlaceSiteWindowless)
- *iface = (IOleInPlaceSiteWindowless*)this;
+ *iface = static_cast<IOleInPlaceSiteWindowless *>(this);
#endif
else if (iid == IID_IOleInPlaceFrame)
- *iface = (IOleInPlaceFrame*)this;
+ *iface = static_cast<IOleInPlaceFrame *>(this);
else if (iid == IID_IOleInPlaceUIWindow)
- *iface = (IOleInPlaceUIWindow*)this;
+ *iface = static_cast<IOleInPlaceUIWindow *>(this);
else if (iid == IID_IOleDocumentSite && canHostDocument)
- *iface = (IOleDocumentSite*)this;
+ *iface = static_cast<IOleDocumentSite *>(this);
else if (iid == IID_IAdviseSink)
- *iface = (IAdviseSink*)this;
+ *iface = static_cast<IAdviseSink *>(this);
}
if (!*iface)
return E_NOINTERFACE;
@@ -994,7 +993,7 @@ HRESULT WINAPI QAxClientSite::TranslateAccelerator(LPMSG lpMsg, DWORD /*grfModif
// if the request is coming from an out-of-proc server or a non ActiveQt server,
// we send the message to the host window. This will make sure this key event
// comes to Qt for processing.
- SendMessage((HWND)host->winId(), lpMsg->message, lpMsg->wParam, lpMsg->lParam);
+ SendMessage(reinterpret_cast<HWND>(host->winId()), lpMsg->message, lpMsg->wParam, lpMsg->lParam);
if (ActiveQtDetected && !fromInProcServer) {
// ActiveQt based servers will need further processing of the event
// (eg. <SPACE> key for a checkbox), so we return false.
@@ -1029,7 +1028,7 @@ HRESULT WINAPI QAxClientSite::GetWindow(HWND *phwnd)
if (!phwnd)
return E_POINTER;
- *phwnd = (HWND)host->winId();
+ *phwnd = reinterpret_cast<HWND>(host->winId());
return S_OK;
}
@@ -1062,7 +1061,7 @@ HRESULT WINAPI QAxClientSite::OnInPlaceActivate()
inPlaceObjectWindowless = true;
} else {
inPlaceObjectWindowless = false;
- m_spOleObject->QueryInterface(IID_IOleInPlaceObject, (void**) &m_spInPlaceObject);
+ m_spOleObject->QueryInterface(IID_IOleInPlaceObject, reinterpret_cast<void **>(&m_spInPlaceObject));
}
}
@@ -1080,10 +1079,10 @@ HRESULT WINAPI QAxClientSite::GetWindowContext(IOleInPlaceFrame **ppFrame, IOleI
if (!ppFrame || !ppDoc || !lprcPosRect || !lprcClipRect || !lpFrameInfo)
return E_POINTER;
- QueryInterface(IID_IOleInPlaceFrame, (void**)ppFrame);
- QueryInterface(IID_IOleInPlaceUIWindow, (void**)ppDoc);
+ QueryInterface(IID_IOleInPlaceFrame, reinterpret_cast<void **>(ppFrame));
+ QueryInterface(IID_IOleInPlaceUIWindow, reinterpret_cast<void **>(ppDoc));
- const HWND hwnd = (HWND)host->winId();
+ const HWND hwnd = reinterpret_cast<HWND>(host->winId());
::GetClientRect(hwnd, lprcPosRect);
::GetClientRect(hwnd, lprcClipRect);
@@ -1186,7 +1185,7 @@ static int menuItemEntry(HMENU menu, int index, MENUITEMINFO item, QString &text
wchar_t *titlebuf = new wchar_t[item.cch + 1];
item.dwTypeData = titlebuf;
item.cch++;
- ::GetMenuItemInfo(menu, index, true, &item);
+ ::GetMenuItemInfo(menu, UINT(index), true, &item);
text = QString::fromWCharArray(titlebuf);
delete [] titlebuf;
return MFT_STRING;
@@ -1225,7 +1224,7 @@ QMenu *QAxClientSite::generatePopup(HMENU subMenu, QWidget *parent)
memset(&item, 0, sizeof(MENUITEMINFO));
item.cbSize = sizeof(MENUITEMINFO);
item.fMask = MIIM_ID | MIIM_TYPE | MIIM_SUBMENU;
- ::GetMenuItemInfo(subMenu, i, true, &item);
+ ::GetMenuItemInfo(subMenu, UINT(i), true, &item);
QAction *action = 0;
QMenu *popupMenu = 0;
@@ -1273,7 +1272,7 @@ QMenu *QAxClientSite::generatePopup(HMENU subMenu, QWidget *parent)
}
if (action) {
- OleMenuItem oleItem(subMenu, item.wID, popupMenu);
+ OleMenuItem oleItem(subMenu, int(item.wID), popupMenu);
menuItemMap.insert(action, oleItem);
}
}
@@ -1299,7 +1298,7 @@ HRESULT WINAPI QAxClientSite::SetMenu(HMENU hmenuShared, HOLEMENU holemenu, HWND
memset(&item, 0, sizeof(MENUITEMINFO));
item.cbSize = sizeof(MENUITEMINFO);
item.fMask = MIIM_ID | MIIM_TYPE | MIIM_SUBMENU;
- ::GetMenuItemInfo(hmenuShared, i, true, &item);
+ ::GetMenuItemInfo(hmenuShared, UINT(i), true, &item);
QAction *action = 0;
QMenu *popupMenu = 0;
@@ -1335,7 +1334,7 @@ HRESULT WINAPI QAxClientSite::SetMenu(HMENU hmenuShared, HOLEMENU holemenu, HWND
}
if (action) {
- OleMenuItem oleItem(hmenuShared, item.wID, popupMenu);
+ OleMenuItem oleItem(hmenuShared, int(item.wID), popupMenu);
menuItemMap.insert(action, oleItem);
}
}
@@ -1366,12 +1365,12 @@ int QAxClientSite::qt_metacall(QMetaObject::Call call, int isignal, void **argv)
if (isignal != menuBar->metaObject()->indexOfSignal("triggered(QAction*)"))
return isignal;
- QAction *action = *(QAction**)argv[1];
+ QAction *action = *reinterpret_cast<QAction **>(argv[1]);
// ###
OleMenuItem oleItem = menuItemMap.value(action);
if (oleItem.hMenu)
- ::PostMessage(m_menuOwner, WM_COMMAND, oleItem.id, 0);
+ ::PostMessage(m_menuOwner, WM_COMMAND, WPARAM(oleItem.id), 0);
return -1;
}
@@ -1419,7 +1418,7 @@ HRESULT WINAPI QAxClientSite::EnableModeless(BOOL fEnable)
HRESULT WINAPI QAxClientSite::TranslateAccelerator(LPMSG lpMsg, WORD grfModifiers)
{
- return TranslateAccelerator(lpMsg, (DWORD)grfModifiers);
+ return TranslateAccelerator(lpMsg, DWORD(grfModifiers));
}
//**** IOleInPlaceUIWindow
@@ -1531,7 +1530,7 @@ HRESULT WINAPI QAxClientSite::ActivateMe(IOleDocumentView *pViewToActivate)
if (!pViewToActivate) {
IOleDocument *document = 0;
- m_spOleObject->QueryInterface(IID_IOleDocument, (void**)&document);
+ m_spOleObject->QueryInterface(IID_IOleDocument, reinterpret_cast<void **>(&document));
if (!document)
return E_FAIL;
@@ -1652,7 +1651,7 @@ void QAxHostWidget::resizeObject()
// document server - talk to view?
if (axhost->m_spActiveView) {
RECT rect;
- GetClientRect((HWND)winId(), &rect);
+ GetClientRect(reinterpret_cast<HWND>(winId()), &rect);
axhost->m_spActiveView->SetRect(&rect);
return;
@@ -1683,7 +1682,7 @@ bool QAxHostWidget::nativeEvent(const QByteArray &eventType, void *message, long
&& eventType == QByteArrayLiteral("windows_generic_MSG")) {
Q_ASSERT(axhost->m_spInPlaceObject);
MSG *msg = static_cast<MSG *>(message);
- IOleInPlaceObjectWindowless *windowless = (IOleInPlaceObjectWindowless*)axhost->m_spInPlaceObject;
+ IOleInPlaceObjectWindowless *windowless = axhost->m_spInPlaceObject;
Q_ASSERT(windowless);
LRESULT lres;
HRESULT hres = windowless->OnWindowMessage(msg->message, msg->wParam, msg->lParam, &lres);
@@ -1699,20 +1698,19 @@ bool QAxHostWidget::event(QEvent *e)
{
switch (e->type()) {
case QEvent::Timer:
- if (axhost && ((QTimerEvent*)e)->timerId() == setFocusTimer) {
+ if (axhost && static_cast<const QTimerEvent *>(e)->timerId() == setFocusTimer) {
killTimer(setFocusTimer);
setFocusTimer = 0;
RECT rcPos = qaxNativeWidgetRect(this);
- axhost->m_spOleObject->DoVerb(OLEIVERB_UIACTIVATE, 0, (IOleClientSite*)axhost, 0,
- (HWND)winId(),
- &rcPos);
+ axhost->m_spOleObject->DoVerb(OLEIVERB_UIACTIVATE, 0, static_cast<IOleClientSite *>(axhost), 0,
+ reinterpret_cast<HWND>(winId()), &rcPos);
if (axhost->m_spActiveView)
axhost->m_spActiveView->UIActivate(TRUE);
}
break;
case QEvent::WindowBlocked:
- if (IsWindowEnabled((HWND)winId())) {
- EnableWindow((HWND)winId(), false);
+ if (IsWindowEnabled(reinterpret_cast<HWND>(winId()))) {
+ EnableWindow(reinterpret_cast<HWND>(winId()), false);
if (axhost && axhost->m_spInPlaceActiveObject) {
axhost->inPlaceModelessEnabled = false;
axhost->m_spInPlaceActiveObject->EnableModeless(false);
@@ -1720,8 +1718,8 @@ bool QAxHostWidget::event(QEvent *e)
}
break;
case QEvent::WindowUnblocked:
- if (!IsWindowEnabled((HWND)winId())) {
- EnableWindow((HWND)winId(), true);
+ if (!IsWindowEnabled(reinterpret_cast<HWND>(winId()))) {
+ EnableWindow(reinterpret_cast<HWND>(winId()), true);
if (axhost && axhost->m_spInPlaceActiveObject) {
axhost->inPlaceModelessEnabled = true;
axhost->m_spInPlaceActiveObject->EnableModeless(true);
@@ -1792,7 +1790,7 @@ void QAxHostWidget::paintEvent(QPaintEvent*)
IViewObject *view = 0;
if (axhost)
- axhost->widget->queryInterface(IID_IViewObject, (void**)&view);
+ axhost->widget->queryInterface(IID_IViewObject, reinterpret_cast<void **>(&view));
if (!view)
return;
@@ -2082,8 +2080,8 @@ const QMetaObject *QAxWidget::parentMetaObject() const
*/
void *QAxWidget::qt_metacast(const char *cname)
{
- if (!qstrcmp(cname, "QAxWidget")) return (void*)this;
- if (!qstrcmp(cname, "QAxBase")) return (QAxBase*)this;
+ if (!qstrcmp(cname, "QAxWidget")) return static_cast<void *>(this);
+ if (!qstrcmp(cname, "QAxBase")) return static_cast<QAxBase *>(this);
return QWidget::qt_metacast(cname);
}
diff --git a/src/activeqt/container/qaxwidget.h b/src/activeqt/container/qaxwidget.h
index ce5efd3..e6131d9 100644
--- a/src/activeqt/container/qaxwidget.h
+++ b/src/activeqt/container/qaxwidget.h
@@ -56,12 +56,12 @@ class QAxWidget : public QWidget, public QAxBase
{
Q_OBJECT_FAKE
public:
- QObject* qObject() const Q_DECL_OVERRIDE { return (QWidget*)this; }
+ QObject* qObject() const Q_DECL_OVERRIDE { return const_cast<QAxWidget *>(this); }
const char *className() const Q_DECL_OVERRIDE;
- QAxWidget(QWidget* parent = 0, Qt::WindowFlags f = 0);
- QAxWidget(const QString &c, QWidget *parent = 0, Qt::WindowFlags f = 0);
- QAxWidget(IUnknown *iface, QWidget *parent = 0, Qt::WindowFlags f = 0);
+ explicit QAxWidget(QWidget* parent = Q_NULLPTR, Qt::WindowFlags f = Qt::WindowFlags());
+ explicit QAxWidget(const QString &c, QWidget *parent = Q_NULLPTR, Qt::WindowFlags f = Qt::WindowFlags());
+ explicit QAxWidget(IUnknown *iface, QWidget *parent = Q_NULLPTR, Qt::WindowFlags f = Qt::WindowFlags());
~QAxWidget();
void clear() Q_DECL_OVERRIDE;
@@ -94,14 +94,14 @@ private:
template <> inline QAxWidget *qobject_cast<QAxWidget*>(const QObject *o)
{
- void *result = o ? const_cast<QObject *>(o)->qt_metacast("QAxWidget") : 0;
- return (QAxWidget*)(result);
+ void *result = o ? const_cast<QObject *>(o)->qt_metacast("QAxWidget") : Q_NULLPTR;
+ return static_cast<QAxWidget *>(result);
}
template <> inline QAxWidget *qobject_cast<QAxWidget*>(QObject *o)
{
- void *result = o ? o->qt_metacast("QAxWidget") : 0;
- return (QAxWidget*)(result);
+ void *result = o ? o->qt_metacast("QAxWidget") : Q_NULLPTR;
+ return static_cast<QAxWidget *>(result);
}
QT_END_NAMESPACE
diff --git a/src/activeqt/control/qaxfactory.h b/src/activeqt/control/qaxfactory.h
index 9ee9a10..23989e2 100644
--- a/src/activeqt/control/qaxfactory.h
+++ b/src/activeqt/control/qaxfactory.h
@@ -149,13 +149,13 @@ inline bool QAxFactory::stopServer()
{ \
if (key == className) \
return &Class::staticMetaObject; \
- return 0; \
+ return Q_NULLPTR; \
} \
QObject *createObject(const QString &key) override \
{ \
if (key == className) \
- return new Class(0); \
- return 0; \
+ return new Class(Q_NULLPTR); \
+ return Q_NULLPTR; \
} \
QUuid classID(const QString &key) const override \
{ \
@@ -195,10 +195,10 @@ public:
{
const QMetaObject &mo = T::staticMetaObject;
if (key != QLatin1String(mo.className()))
- return 0;
+ return Q_NULLPTR;
if (!qstrcmp(mo.classInfo(mo.indexOfClassInfo("Creatable")).value(), "no"))
- return 0;
- return new T(0);
+ return Q_NULLPTR;
+ return new T(Q_NULLPTR);
}
void registerClass(const QString &key, QSettings *settings) const Q_DECL_OVERRIDE
@@ -243,7 +243,7 @@ private:
QAxFactoryList() \
: QAxFactory(IDTypeLib, IDApp) \
{ \
- QAxFactory *factory = 0; \
+ QAxFactory *factory = Q_NULLPTR; \
QStringList keys; \
QStringList::Iterator it; \
@@ -273,13 +273,13 @@ private:
QStringList featureList() const Q_DECL_OVERRIDE { return factoryKeys; } \
const QMetaObject *metaObject(const QString&key) const Q_DECL_OVERRIDE { \
QAxFactory *f = factories[key]; \
- return f ? f->metaObject(key) : 0; \
+ return f ? f->metaObject(key) : Q_NULLPTR; \
} \
QObject *createObject(const QString &key) Q_DECL_OVERRIDE { \
if (!creatable.value(key)) \
- return 0; \
+ return Q_NULLPTR; \
QAxFactory *f = factories[key]; \
- return f ? f->createObject(key) : 0; \
+ return f ? f->createObject(key) : Q_NULLPTR; \
} \
QUuid classID(const QString &key) const Q_DECL_OVERRIDE { \
QAxFactory *f = factories.value(key); \
diff --git a/src/activeqt/control/qaxserver.cpp b/src/activeqt/control/qaxserver.cpp
index 6abf2a7..b02c38b 100644
--- a/src/activeqt/control/qaxserver.cpp
+++ b/src/activeqt/control/qaxserver.cpp
@@ -124,18 +124,21 @@ QString qAxInit()
libFile = QString::fromWCharArray(qAxModuleFilename);
libFile = libFile.toLower();
- if (LoadTypeLibEx((wchar_t*)libFile.utf16(), REGKIND_NONE, &qAxTypeLibrary) == S_OK)
+ if (LoadTypeLibEx(reinterpret_cast<const wchar_t *>(libFile.utf16()),
+ REGKIND_NONE, &qAxTypeLibrary) == S_OK)
return libFile;
const int lastDot = libFile.lastIndexOf(QLatin1Char('.'));
libFile.truncate(lastDot);
libFile += QLatin1String(".tlb");
- if (LoadTypeLibEx((wchar_t*)libFile.utf16(), REGKIND_NONE, &qAxTypeLibrary) == S_OK)
+ if (LoadTypeLibEx(reinterpret_cast<const wchar_t *>(libFile.utf16()),
+ REGKIND_NONE, &qAxTypeLibrary) == S_OK)
return libFile;
libFile.truncate(lastDot);
libFile += QLatin1String(".olb");
- if (LoadTypeLibEx((wchar_t*)libFile.utf16(), REGKIND_NONE, &qAxTypeLibrary) == S_OK)
+ if (LoadTypeLibEx(reinterpret_cast<const wchar_t *>(libFile.utf16()),
+ REGKIND_NONE, &qAxTypeLibrary) == S_OK)
return libFile;
return QString();
@@ -230,7 +233,7 @@ HRESULT UpdateRegistry(BOOL bRegister)
return SELFREG_E_TYPELIB;
if (bRegister)
- RegisterTypeLib(qAxTypeLibrary, (wchar_t*)libFile.utf16(), 0);
+ RegisterTypeLib(qAxTypeLibrary, reinterpret_cast<wchar_t *>(const_cast<ushort *>(libFile.utf16())), 0);
else
UnRegisterTypeLib(libAttr->guid, libAttr->wMajorVerNum, libAttr->wMinorVerNum, libAttr->lcid, libAttr->syskind);
@@ -838,7 +841,7 @@ static HRESULT classIDL(QObject *o, const QMetaObject *mo, const QString &classN
key += '_';
}
enumValues.append(key);
- uint value = (uint)enumerator.value(j);
+ const uint value = uint(enumerator.value(j));
key = key.leftJustified(20);
out << "\t\t" << key << "\t= ";
if (enumerator.isFlag())
@@ -1158,7 +1161,6 @@ extern "C" HRESULT __stdcall DumpIDL(const QString &outfile, const QString &ver)
out << "\timportlib(\"stdole2.tlb\");" << endl << endl;
QStringList keys = qAxFactory()->featureList();
- QStringList::ConstIterator key;
out << "\t/************************************************************************" << endl;
out << "\t** If this causes a compile error in MIDL you need to upgrade the" << endl;
@@ -1241,7 +1243,7 @@ extern "C" HRESULT __stdcall DumpIDL(const QString &outfile, const QString &ver)
if (!o)
continue;
const QMetaObject *mo = o->metaObject();
- QAxBindable *bind = (QAxBindable*)o->qt_metacast("QAxBindable");
+ QAxBindable *bind = static_cast<QAxBindable *>(o->qt_metacast("QAxBindable"));
bool isBindable = bind != 0;
const QByteArray cleanType = qax_clean_type(className, mo).toLatin1();
diff --git a/src/activeqt/control/qaxserverbase.cpp b/src/activeqt/control/qaxserverbase.cpp
index b131e76..61645fd 100644
--- a/src/activeqt/control/qaxserverbase.cpp
+++ b/src/activeqt/control/qaxserverbase.cpp
@@ -467,7 +467,7 @@ public:
*iface = 0;
if (iid == IID_IUnknown) {
- *iface = (IUnknown*)this;
+ *iface = static_cast<IUnknown *>(this);
AddRef();
return S_OK;
}
@@ -486,7 +486,7 @@ bool QAxFactory::createObjectWrapper(QObject *object, IDispatch **wrapper)
{
*wrapper = 0;
QAxServerBase *obj = new QAxServerBase(object);
- obj->QueryInterface(IID_IDispatch, (void**)wrapper);
+ obj->QueryInterface(IID_IDispatch, reinterpret_cast<void **>(wrapper));
if (*wrapper)
return true;
@@ -663,7 +663,7 @@ public:
return E_POINTER;
*iface = 0;
if (iid == IID_IUnknown)
- *iface = (IConnectionPoint*)this;
+ *iface = static_cast<IConnectionPoint *>(this);
else if (iid == IID_IConnectionPoint)
*iface = this;
else if (iid == IID_IEnumConnections)
@@ -681,7 +681,7 @@ public:
}
STDMETHOD(GetConnectionPointContainer)(IConnectionPointContainer **ppCPC)
{
- return that->QueryInterface(IID_IConnectionPointContainer, (void**)ppCPC);
+ return that->QueryInterface(IID_IConnectionPointContainer, reinterpret_cast<void **>(ppCPC));
}
STDMETHOD(Advise)(IUnknown*pUnk, DWORD *pdwCookie)
{
@@ -690,7 +690,7 @@ public:
{
IDispatch *checkImpl = 0;
- pUnk->QueryInterface(iid, (void**)&checkImpl);
+ pUnk->QueryInterface(iid, reinterpret_cast<void **>(&checkImpl));
if (!checkImpl)
return CONNECT_E_CANNOTCONNECT;
checkImpl->Release();
@@ -804,7 +804,7 @@ public:
bool QAxWinEventFilter::nativeEventFilter(const QByteArray &, void *message, long *)
{
- MSG *pMsg = (MSG*)message;
+ MSG *pMsg = static_cast<MSG *>(message);
if (pMsg->message < WM_KEYFIRST || pMsg->message > WM_KEYLAST)
return false;
@@ -877,11 +877,11 @@ public:
{
*iface = 0;
if (iid == IID_IUnknown)
- *iface = (IUnknown*)this;
+ *iface = static_cast<IUnknown *>(this);
else if (iid == IID_IClassFactory)
- *iface = (IClassFactory*)this;
+ *iface = static_cast<IClassFactory *>(this);
else if (iid == IID_IClassFactory2 && licensed)
- *iface = (IClassFactory2*)this;
+ *iface = static_cast<IClassFactory2 *>(this);
else
return E_NOINTERFACE;
@@ -1196,7 +1196,7 @@ HRESULT QAxServerBase::InternalQueryInterface(REFIID iid, void **iface)
*iface = 0;
if (iid == IID_IUnknown) {
- *iface = (IUnknown*)(IDispatch*)this;
+ *iface = static_cast<IUnknown *>(static_cast<IDispatch *>(this));
} else {
HRESULT res = S_OK;
if (aggregatedObject)
@@ -1207,47 +1207,47 @@ HRESULT QAxServerBase::InternalQueryInterface(REFIID iid, void **iface)
if (!(*iface)) {
if (iid == qAxFactory()->interfaceID(class_name))
- *iface = (IDispatch*)this;
+ *iface = static_cast<IDispatch *>(this);
if (iid == IID_IDispatch)
- *iface = (IDispatch*)this;
+ *iface = static_cast<IDispatch *>(this);
else if (iid == IID_IAxServerBase)
- *iface = (IAxServerBase*)this;
+ *iface = static_cast<IAxServerBase *>(this);
else if (iid == IID_IOleObject)
- *iface = (IOleObject*)this;
+ *iface = static_cast<IOleObject *>(this);
else if (iid == IID_IConnectionPointContainer)
- *iface = (IConnectionPointContainer*)this;
+ *iface = static_cast<IConnectionPointContainer *>(this);
else if (iid == IID_IProvideClassInfo)
- *iface = (IProvideClassInfo*)this;
+ *iface = static_cast<IProvideClassInfo *>(this);
else if (iid == IID_IProvideClassInfo2)
- *iface = (IProvideClassInfo2*)this;
+ *iface = static_cast<IProvideClassInfo2 *>(this);
else if (iid == IID_IPersist)
- *iface = (IPersist*)(IPersistStream*)this;
+ *iface = static_cast<IPersist *>(static_cast<IPersistStream *>(this));
else if (iid == IID_IPersistStream)
- *iface = (IPersistStream*)this;
+ *iface = static_cast<IPersistStream *>(this);
else if (iid == IID_IPersistStreamInit)
- *iface = (IPersistStreamInit*)this;
+ *iface = static_cast<IPersistStreamInit *>(this);
else if (iid == IID_IPersistStorage)
- *iface = (IPersistStorage*)this;
+ *iface = static_cast<IPersistStorage *>(this);
else if (iid == IID_IPersistPropertyBag)
- *iface = (IPersistPropertyBag*)this;
+ *iface = static_cast<IPersistPropertyBag *>(this);
else if (iid == IID_IPersistFile &&
qAxFactory()->metaObject(class_name)->indexOfClassInfo("MIME") != -1)
- *iface = (IPersistFile*)this;
+ *iface = static_cast<IPersistFile *>(this);
else if (iid == IID_IViewObject)
- *iface = (IViewObject*)this;
+ *iface = static_cast<IViewObject *>(this);
else if (iid == IID_IViewObject2)
- *iface = (IViewObject2*)this;
+ *iface = static_cast<IViewObject2 *>(this);
else if (isWidget) {
if (iid == IID_IOleControl)
- *iface = (IOleControl*)this;
+ *iface = static_cast<IOleControl *>(this);
else if (iid == IID_IOleWindow)
- *iface = (IOleWindow*)(IOleInPlaceObject*)this;
+ *iface = static_cast<IOleWindow *>(static_cast<IOleInPlaceObject *>(this));
else if (iid == IID_IOleInPlaceObject)
- *iface = (IOleInPlaceObject*)this;
+ *iface = static_cast<IOleInPlaceObject *>(this);
else if (iid == IID_IOleInPlaceActiveObject)
- *iface = (IOleInPlaceActiveObject*)this;
+ *iface = static_cast<IOleInPlaceActiveObject *>(this);
else if (iid == IID_IDataObject)
- *iface = (IDataObject*)this;
+ *iface = static_cast<IDataObject *>(this);
}
}
if (!*iface)
@@ -1262,14 +1262,14 @@ HRESULT QAxServerBase::InternalQueryInterface(REFIID iid, void **iface)
*/
void QAxServerBase::internalBind()
{
- QAxBindable *axb = (QAxBindable*)qt.object->qt_metacast("QAxBindable");
+ QAxBindable *axb = static_cast<QAxBindable *>(qt.object->qt_metacast("QAxBindable"));
if (axb) {
// no addref; this is aggregated
axb->activex = this;
if (!aggregatedObject)
aggregatedObject = axb->createAggregate();
if (aggregatedObject) {
- aggregatedObject->controlling_unknown = (IUnknown*)(IDispatch*)this;
+ aggregatedObject->controlling_unknown = static_cast<IUnknown *>(static_cast<IDispatch *>(this));
aggregatedObject->the_object = qt.object;
}
}
@@ -1375,13 +1375,13 @@ class HackWidget : public QWidget
LRESULT QT_WIN_CALLBACK QAxServerBase::ActiveXProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
if (uMsg == WM_CREATE) {
- CREATESTRUCT *cs = (CREATESTRUCT*)lParam;
- QAxServerBase *that = (QAxServerBase*)cs->lpCreateParams;
+ CREATESTRUCT *cs = reinterpret_cast<CREATESTRUCT *>(lParam);
+ QAxServerBase *that = static_cast<QAxServerBase *>(cs->lpCreateParams);
#ifdef GWLP_USERDATA
- SetWindowLongPtr(hWnd, GWLP_USERDATA, (LONG_PTR)that);
+ SetWindowLongPtr(hWnd, GWLP_USERDATA, LONG_PTR(that));
#else
- SetWindowLong(hWnd, GWL_USERDATA, (LONG)that);
+ SetWindowLong(hWnd, GWL_USERDATA, LONG(that));
#endif
that->m_hWnd = hWnd;
@@ -1454,7 +1454,7 @@ LRESULT QT_WIN_CALLBACK QAxServerBase::ActiveXProc(HWND hWnd, UINT uMsg, WPARAM
that->DoVerb(OLEIVERB_UIACTIVATE, NULL, that->m_spClientSite, 0, that->m_hWnd, &rcPos);
if (that->isUIActive) {
IOleControlSite *spSite = 0;
- that->m_spClientSite->QueryInterface(IID_IOleControlSite, (void**)&spSite);
+ that->m_spClientSite->QueryInterface(IID_IOleControlSite, reinterpret_cast<void **>(&spSite));
if (spSite) {
spSite->OnFocus(true);
spSite->Release();
@@ -1469,9 +1469,8 @@ LRESULT QT_WIN_CALLBACK QAxServerBase::ActiveXProc(HWND hWnd, UINT uMsg, WPARAM
}
if (candidate) {
candidate->setFocus();
- HackWidget *widget = (HackWidget*)that->qt.widget;
if (::GetKeyState(VK_SHIFT) < 0)
- widget->focusNextPrevChild(false);
+ static_cast<HackWidget *>(that->qt.widget)->focusNextPrevChild(false);
}
}
}
@@ -1482,7 +1481,7 @@ LRESULT QT_WIN_CALLBACK QAxServerBase::ActiveXProc(HWND hWnd, UINT uMsg, WPARAM
if (QAxServerBase *that = axServerBaseFromWindow(hWnd)) {
if (that->isInPlaceActive && that->isUIActive && that->m_spClientSite) {
IOleControlSite *spSite = 0;
- that->m_spClientSite->QueryInterface(IID_IOleControlSite, (void**)&spSite);
+ that->m_spClientSite->QueryInterface(IID_IOleControlSite, reinterpret_cast<void **>(&spSite));
if (spSite) {
if (!::IsChild(that->m_hWnd, ::GetFocus()))
spSite->OnFocus(false);
@@ -1502,7 +1501,7 @@ LRESULT QT_WIN_CALLBACK QAxServerBase::ActiveXProc(HWND hWnd, UINT uMsg, WPARAM
case WM_INITMENUPOPUP:
if (QAxServerBase *that = axServerBaseFromWindow(hWnd)) {
if (that->qt.widget) {
- that->currentPopup = that->menuMap[(HMENU)wParam];
+ that->currentPopup = that->menuMap[reinterpret_cast<HMENU>(wParam)];
if (!that->currentPopup)
break;
const QMetaObject *mo = that->currentPopup->metaObject();
@@ -1511,7 +1510,7 @@ LRESULT QT_WIN_CALLBACK QAxServerBase::ActiveXProc(HWND hWnd, UINT uMsg, WPARAM
break;
that->currentPopup->qt_metacall(QMetaObject::InvokeMetaMethod, index, 0);
- that->createPopup(that->currentPopup, (HMENU)wParam);
+ that->createPopup(that->currentPopup, reinterpret_cast<HMENU>(wParam));
return 0;
}
}
@@ -1529,7 +1528,7 @@ LRESULT QT_WIN_CALLBACK QAxServerBase::ActiveXProc(HWND hWnd, UINT uMsg, WPARAM
bool menuClosed = false;
if (uMsg == WM_COMMAND) {
- menuObject = that->actionMap.value(wParam);
+ menuObject = that->actionMap.value(UINT(wParam));
} else if (!lParam) {
menuClosed = true;
menuObject = that->currentPopup;
@@ -1581,7 +1580,7 @@ HWND QAxServerBase::create(HWND hWndParent, RECT& rcPos)
HINSTANCE hInst = (HINSTANCE)qAxInstance;
EnterCriticalSection(&createWindowSection);
QString cn(QLatin1String("QAxControl"));
- cn += QString::number((quintptr)ActiveXProc);
+ cn += QString::number(quintptr(ActiveXProc));
if (!atom) {
WNDCLASS wcTemp;
wcTemp.style = CS_DBLCLKS;
@@ -1591,7 +1590,7 @@ HWND QAxServerBase::create(HWND hWndParent, RECT& rcPos)
wcTemp.hCursor = 0;
wcTemp.hIcon = 0;
wcTemp.hInstance = hInst;
- wcTemp.lpszClassName = (wchar_t*)cn.utf16();
+ wcTemp.lpszClassName = reinterpret_cast<const wchar_t *>(cn.utf16());
wcTemp.lpszMenuName = 0;
wcTemp.lpfnWndProc = ActiveXProc;
@@ -1602,7 +1601,7 @@ HWND QAxServerBase::create(HWND hWndParent, RECT& rcPos)
return 0;
Q_ASSERT(!m_hWnd);
- HWND hWnd = ::CreateWindow((wchar_t*)cn.utf16(), 0,
+ HWND hWnd = ::CreateWindow(reinterpret_cast<const wchar_t *>(cn.utf16()), 0,
WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS,
rcPos.left, rcPos.top, rcPos.right - rcPos.left,
rcPos.bottom - rcPos.top, hWndParent, 0, hInst, this);
@@ -1651,7 +1650,7 @@ HMENU QAxServerBase::createPopup(QMenu *popup, HMENU oldMenu)
actionMap.remove(itemId);
actionMap.insert(itemId, action);
}
- AppendMenu(popupMenu, flags, itemId, (const wchar_t *)action->text().utf16());
+ AppendMenu(popupMenu, flags, itemId, reinterpret_cast<const wchar_t *>(action->text().utf16()));
}
if (oldMenu)
DrawMenuBar(hwndMenuOwner);
@@ -1697,7 +1696,7 @@ void QAxServerBase::createMenu(QMenuBar *menuBar)
itemId = static_cast<ushort>(reinterpret_cast<quintptr>(action));
actionMap.insert(itemId, action);
}
- AppendMenu(hmenuShared, flags, itemId, (const wchar_t *)action->text().utf16());
+ AppendMenu(hmenuShared, flags, itemId, reinterpret_cast<const wchar_t *>(action->text().utf16()));
}
OLEMENUGROUPWIDTHS menuWidths = { { 0,edit,0,object,0,help } };
@@ -1772,7 +1771,7 @@ bool QAxServerBase::isPropertyExposed(int index)
BSTR bstrNames = QStringToBSTR(QLatin1String(property.name()));
DISPID dispId;
- GetIDsOfNames(IID_NULL, (BSTR*)&bstrNames, 1, LOCALE_USER_DEFAULT, &dispId);
+ GetIDsOfNames(IID_NULL, &bstrNames, 1, LOCALE_USER_DEFAULT, &dispId);
result = dispId != DISPID_UNKNOWN;
SysFreeString(bstrNames);
@@ -1906,7 +1905,7 @@ int QAxServerBase::qt_metacall(QMetaObject::Call call, int index, void **argv)
return true;
if (statusBar->isHidden()) {
- QString message = *(QString*)argv[1];
+ QString message = *static_cast<const QString *>(argv[1]);
m_spInPlaceFrame->SetStatusText(QStringToBSTR(message));
}
}
@@ -1963,8 +1962,8 @@ int QAxServerBase::qt_metacall(QMetaObject::Call call, int index, void **argv)
qAxTypeLibrary->GetTypeInfoOfGuid(qAxFactory()->eventsID(class_name), &eventInfo);
if (eventInfo) {
QString uni_name = QLatin1String(name);
- const OLECHAR *olename = reinterpret_cast<const OLECHAR *>(uni_name.utf16());
- eventInfo->GetIDsOfNames((OLECHAR**)&olename, 1, &eventId);
+ OLECHAR *olename = reinterpret_cast<OLECHAR *>(const_cast<ushort *>(uni_name.utf16()));
+ eventInfo->GetIDsOfNames(&olename, 1, &eventId);
eventInfo->Release();
}
}
@@ -1997,18 +1996,18 @@ int QAxServerBase::qt_metacall(QMetaObject::Call call, int index, void **argv)
clist->Reset();
ULONG cc = 1;
CONNECTDATA c[1];
- clist->Next(cc, (CONNECTDATA*)&c, &cc);
+ clist->Next(cc, reinterpret_cast<CONNECTDATA *>(&c), &cc);
if (cc) {
// setup parameters
unsigned int argErr = 0;
DISPPARAMS dispParams;
- dispParams.cArgs = pcount;
+ dispParams.cArgs = UINT(pcount);
dispParams.cNamedArgs = 0;
dispParams.rgdispidNamedArgs = 0;
dispParams.rgvarg = 0;
if (pcount) // Use malloc/free for eval package compatibility
- dispParams.rgvarg = (VARIANTARG*)malloc(pcount * sizeof(VARIANTARG));
+ dispParams.rgvarg = static_cast<VARIANTARG *>(malloc(size_t(pcount) * sizeof(VARIANTARG)));
int p = 0;
for (p = 0; p < pcount; ++p) {
VARIANT *arg = dispParams.rgvarg + (pcount - p - 1);
@@ -2024,7 +2023,7 @@ int QAxServerBase::qt_metacall(QMetaObject::Call call, int index, void **argv)
QVariant::Type vt = QVariant::nameToType(ptype);
if (vt == QVariant::UserType) {
if (ptype.endsWith('*')) {
- variant = QVariant(QMetaType::type(ptype), (void**)argv[p+1]);
+ variant = QVariant(QMetaType::type(ptype), reinterpret_cast<void **>(argv[p+1]));
// variant.setValue(*(void**)(argv[p + 1]), ptype);
} else {
variant = QVariant(QMetaType::type(ptype), argv[p+1]);
@@ -2048,7 +2047,7 @@ int QAxServerBase::qt_metacall(QMetaObject::Call call, int index, void **argv)
while (cc) {
if (c->pUnk) {
IDispatch *disp = 0;
- c->pUnk->QueryInterface(IID_QAxEvents, (void**)&disp);
+ 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);
@@ -2067,7 +2066,7 @@ int QAxServerBase::qt_metacall(QMetaObject::Call call, int index, void **argv)
}
c->pUnk->Release(); // AddRef'ed by clist->Next implementation
}
- clist->Next(cc, (CONNECTDATA*)&c, &cc);
+ clist->Next(cc, reinterpret_cast<CONNECTDATA *>(&c), &cc);
}
// clean up
@@ -2100,7 +2099,7 @@ bool QAxServerBase::emitRequestPropertyChange(const char *property)
clist->Reset();
ULONG cc = 1;
CONNECTDATA c[1];
- clist->Next(cc, (CONNECTDATA*)&c, &cc);
+ clist->Next(cc, reinterpret_cast<CONNECTDATA *>(&c), &cc);
if (cc) {
if (dispId == -1) {
BSTR bstr = QStringToBSTR(QLatin1String(property));
@@ -2110,7 +2109,7 @@ bool QAxServerBase::emitRequestPropertyChange(const char *property)
if (dispId != -1) while (cc) {
if (c->pUnk) {
IPropertyNotifySink *sink = 0;
- c->pUnk->QueryInterface(IID_IPropertyNotifySink, (void**)&sink);
+ c->pUnk->QueryInterface(IID_IPropertyNotifySink, reinterpret_cast<void **>(&sink));
bool disallows = sink && sink->OnRequestEdit(dispId) == S_FALSE;
sink->Release();
c->pUnk->Release();
@@ -2120,7 +2119,7 @@ bool QAxServerBase::emitRequestPropertyChange(const char *property)
return false;
}
}
- clist->Next(cc, (CONNECTDATA*)&c, &cc);
+ clist->Next(cc, reinterpret_cast<CONNECTDATA *>(&c), &cc);
}
}
clist->Release();
@@ -2148,7 +2147,7 @@ void QAxServerBase::emitPropertyChanged(const char *property)
clist->Reset();
ULONG cc = 1;
CONNECTDATA c[1];
- clist->Next(cc, (CONNECTDATA*)&c, &cc);
+ clist->Next(cc, reinterpret_cast<CONNECTDATA *>(&c), &cc);
if (cc) {
if (dispId == -1) {
BSTR bstr = QStringToBSTR(QLatin1String(property));
@@ -2158,14 +2157,14 @@ void QAxServerBase::emitPropertyChanged(const char *property)
if (dispId != -1) while (cc) {
if (c->pUnk) {
IPropertyNotifySink *sink = 0;
- c->pUnk->QueryInterface(IID_IPropertyNotifySink, (void**)&sink);
+ c->pUnk->QueryInterface(IID_IPropertyNotifySink, reinterpret_cast<void **>(&sink));
if (sink) {
sink->OnChanged(dispId);
sink->Release();
}
c->pUnk->Release();
}
- clist->Next(cc, (CONNECTDATA*)&c, &cc);
+ clist->Next(cc, reinterpret_cast<CONNECTDATA *>(&c), &cc);
}
}
clist->Release();
@@ -2392,7 +2391,7 @@ HRESULT WINAPI QAxServerBase::Invoke(DISPID dispidMember, REFIID riid,
QList<QByteArray> ptypes;
if (!prototype.isEmpty())
ptypes = prototype.split(',');
- UINT pcount = ptypes.count();
+ UINT pcount = UINT(ptypes.count());
// verify parameter count
if (pcount > pDispParams->cArgs) {
@@ -2420,7 +2419,7 @@ HRESULT WINAPI QAxServerBase::Invoke(DISPID dispidMember, REFIID riid,
QVariant static_varp[QAX_NUM_PARAMS + 1];
void *static_argv_pointer[QAX_NUM_PARAMS + 1];
- int totalParam = pcount;
+ int totalParam = int(pcount);
if (!type.isEmpty())
++totalParam;
@@ -2445,7 +2444,7 @@ HRESULT WINAPI QAxServerBase::Invoke(DISPID dispidMember, REFIID riid,
for (UINT p = 0; p < pcount; ++p) {
// map the VARIANT to the void*
bool out;
- QByteArray ptype = paramType(ptypes.at(p), &out);
+ QByteArray ptype = paramType(ptypes.at(int(p)), &out);
varp[p + 1] = VARIANTToQVariant(pDispParams->rgvarg[pcount - p - 1], ptype);
argv_pointer[p + 1] = 0;
if (varp[p + 1].isValid()) {
@@ -2501,7 +2500,7 @@ HRESULT WINAPI QAxServerBase::Invoke(DISPID dispidMember, REFIID riid,
// update reference parameters and return value
for (UINT p = 0; p < pcount; ++p) {
bool out;
- QByteArray ptype = paramType(ptypes.at(p), &out);
+ QByteArray ptype = paramType(ptypes.at(int(p)), &out);
if (out) {
if (!QVariantToVARIANT(varp[p + 1], pDispParams->rgvarg[pcount - p - 1], ptype, out))
ok = false;
@@ -2607,17 +2606,17 @@ HRESULT WINAPI QAxServerBase::Invoke(DISPID dispidMember, REFIID riid,
if (pexcepinfo) {
memset(pexcepinfo, 0, sizeof(EXCEPINFO));
- pexcepinfo->wCode = exception->code;
+ pexcepinfo->wCode = WORD(exception->code);
if (!exception->src.isNull())
pexcepinfo->bstrSource = QStringToBSTR(exception->src);
if (!exception->desc.isNull())
pexcepinfo->bstrDescription = QStringToBSTR(exception->desc);
if (!exception->context.isNull()) {
QString context = exception->context;
- int contextID = 0;
+ unsigned contextID = 0;
const int br = context.indexOf(QLatin1Char('[')); // "error[42]"
if (br != -1) {
- contextID = context.midRef(br + 1, context.size() - br - 2).toInt();
+ contextID = context.midRef(br + 1, context.size() - br - 2).toUInt();
context.truncate(br-1);
}
pexcepinfo->bstrHelpFile = QStringToBSTR(context);
@@ -2695,7 +2694,7 @@ HRESULT WINAPI QAxServerBase::Load(IStream *pStm)
if (stat.cbSize.HighPart) // more than 4GB - too large!
return S_FALSE;
- qtarray.resize(stat.cbSize.LowPart);
+ qtarray.resize(int(stat.cbSize.LowPart));
ULONG read;
pStm->Read(qtarray.data(), stat.cbSize.LowPart, &read);
} else if (hres == E_NOTIMPL) {
@@ -2703,7 +2702,7 @@ HRESULT WINAPI QAxServerBase::Load(IStream *pStm)
while (hres != S_FALSE) {
QByteArray arrayRead;
arrayRead.resize(4098);
- hres = pStm->Read(arrayRead.data(), arrayRead.size(), &read);
+ hres = pStm->Read(arrayRead.data(), ULONG(arrayRead.size()), &read);
if (hres != S_OK && hres != S_FALSE) {
qtarray.resize(0);
break;
@@ -2718,7 +2717,7 @@ HRESULT WINAPI QAxServerBase::Load(IStream *pStm)
QByteArray mimeType = mo->classInfo(mo->indexOfClassInfo("MIME")).value();
if (!mimeType.isEmpty()) {
mimeType.truncate(mimeType.indexOf(':')); // first type
- QAxBindable *axb = (QAxBindable*)qt.object->qt_metacast("QAxBindable");
+ QAxBindable *axb = static_cast<QAxBindable *>(qt.object->qt_metacast("QAxBindable"));
if (axb && axb->readData(&qtbuffer, QString::fromLatin1(mimeType)))
return S_OK;
}
@@ -2758,7 +2757,7 @@ HRESULT WINAPI QAxServerBase::Save(IStream *pStm, BOOL clearDirty)
bool saved = false;
QByteArray mimeType = mo->classInfo(mo->indexOfClassInfo("MIME")).value();
if (!mimeType.isEmpty()) {
- QAxBindable *axb = (QAxBindable*)qt.object->qt_metacast("QAxBindable");
+ QAxBindable *axb = static_cast<QAxBindable *>(qt.object->qt_metacast("QAxBindable"));
saved = axb && axb->writeData(&qtbuffer);
qtbuffer.close();
}
@@ -2792,9 +2791,9 @@ HRESULT WINAPI QAxServerBase::Save(IStream *pStm, BOOL clearDirty)
const char *data = qtarray.constData();
ULARGE_INTEGER newsize;
newsize.HighPart = 0;
- newsize.LowPart = qtarray.size();
+ newsize.LowPart = DWORD(qtarray.size());
pStm->SetSize(newsize);
- pStm->Write(data, qtarray.size(), &written);
+ pStm->Write(data, ULONG(qtarray.size()), &written);
pStm->Commit(STGC_ONLYIFCURRENT);
if (clearDirty)
@@ -2806,9 +2805,8 @@ HRESULT WINAPI QAxServerBase::GetSizeMax(ULARGE_INTEGER *pcbSize)
{
const QMetaObject *mo = qt.object->metaObject();
- int np = mo->propertyCount();
pcbSize->HighPart = 0;
- pcbSize->LowPart = np * 50;
+ pcbSize->LowPart = DWORD(mo->propertyCount()) * 50;
return S_OK;
}
@@ -2843,7 +2841,7 @@ HRESULT WINAPI QAxServerBase::Load(IStorage *pStg)
*/
streamName += QLatin1String("_Stream4.2");
- pStg->OpenStream((const wchar_t *)streamName.utf16(), 0, STGM_READ | STGM_SHARE_EXCLUSIVE, 0, &spStream);
+ pStg->OpenStream(reinterpret_cast<const wchar_t *>(streamName.utf16()), 0, 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);
if (!spStream)
@@ -2866,7 +2864,7 @@ HRESULT WINAPI QAxServerBase::Save(IStorage *pStg, BOOL /* fSameAsLoad */)
*/
streamName += QLatin1String("_Stream4.2");
- pStg->CreateStream((const wchar_t *)streamName.utf16(), STGM_CREATE | STGM_WRITE | STGM_SHARE_EXCLUSIVE, 0, 0, &spStream);
+ pStg->CreateStream(reinterpret_cast<const wchar_t *>(streamName.utf16()), STGM_CREATE | STGM_WRITE | STGM_SHARE_EXCLUSIVE, 0, 0, &spStream);
if (!spStream)
return E_FAIL;
@@ -3016,7 +3014,7 @@ HRESULT WINAPI QAxServerBase::Load(LPCOLESTR fileName, DWORD /* mode */)
if (mimeIndex == -1)
return E_NOTIMPL;
- QAxBindable *axb = (QAxBindable*)qt.object->qt_metacast("QAxBindable");
+ QAxBindable *axb = static_cast<QAxBindable *>(qt.object->qt_metacast("QAxBindable"));
if (!axb) {
qWarning() << class_name << ": No QAxBindable implementation for mime-type handling";
return E_NOTIMPL;
@@ -3061,7 +3059,7 @@ HRESULT WINAPI QAxServerBase::Save(LPCOLESTR fileName, BOOL fRemember)
if (mimeIndex == -1)
return E_NOTIMPL;
- QAxBindable *axb = (QAxBindable*)qt.object->qt_metacast("QAxBindable");
+ QAxBindable *axb = static_cast<QAxBindable *>(qt.object->qt_metacast("QAxBindable"));
if (!axb) {
qWarning() << class_name << ": No QAxBindable implementation for mime-type handling";
return E_NOTIMPL;
@@ -3253,7 +3251,7 @@ HRESULT WINAPI QAxServerBase::OnAmbientPropertyChange(DISPID dispID)
return S_OK;
IDispatch *disp = 0;
- m_spClientSite->QueryInterface(IID_IDispatch, (void**)&disp);
+ m_spClientSite->QueryInterface(IID_IDispatch, reinterpret_cast<void **>(&disp));
if (!disp)
return S_OK;
@@ -3272,11 +3270,11 @@ HRESULT WINAPI QAxServerBase::OnAmbientPropertyChange(DISPID dispID)
case DISPID_AMBIENT_BACKCOLOR:
case DISPID_AMBIENT_FORECOLOR:
if (isWidget) {
- long rgb;
+ unsigned rgb;
if (var.vt == VT_UI4)
rgb = var.ulVal;
else if (var.vt == VT_I4)
- rgb = var.lVal;
+ rgb = unsigned(var.lVal);
else
break;
QPalette pal = qt.widget->palette();
@@ -3521,7 +3519,7 @@ HRESULT WINAPI QAxServerBase::TranslateAcceleratorW(MSG *pMsg)
if (!topLevel) {
giveUp = false;
- ((HackWidget*)curFocus)->focusNextPrevChild(false);
+ static_cast<HackWidget *>(curFocus)->focusNextPrevChild(false);
curFocus->window()->setAttribute(Qt::WA_KeyboardFocusChange);
}
}
@@ -3533,7 +3531,7 @@ HRESULT WINAPI QAxServerBase::TranslateAcceleratorW(MSG *pMsg)
break;
if (nextFocus->focusPolicy() & Qt::TabFocus) {
giveUp = false;
- ((HackWidget*)curFocus)->focusNextPrevChild(true);
+ static_cast<HackWidget *>(curFocus)->focusNextPrevChild(true);
curFocus->window()->setAttribute(Qt::WA_KeyboardFocusChange);
break;
}
@@ -3568,12 +3566,12 @@ HRESULT WINAPI QAxServerBase::TranslateAcceleratorW(MSG *pMsg)
if (dwKeyMod & 4)
state |= Qt::AltModifier;
- int key = pMsg->wParam;
+ int key = int(pMsg->wParam);
// FIXME 4.10.2011: No longer exists in Lighthouse.
// if (!(key >= 'A' && key <= 'Z') && !(key >= '0' && key <= '9'))
// key = qt_translateKeyCode(pMsg->wParam);
- QKeyEvent override(QEvent::ShortcutOverride, key, (Qt::KeyboardModifiers)state);
+ QKeyEvent override(QEvent::ShortcutOverride, key, static_cast<Qt::KeyboardModifiers>(state));
override.ignore();
QCoreApplication::sendEvent(qt.widget->focusWidget(), &override);
if (override.isAccepted())
@@ -3586,7 +3584,7 @@ HRESULT WINAPI QAxServerBase::TranslateAcceleratorW(MSG *pMsg)
return S_FALSE;
IOleControlSite *controlSite = 0;
- m_spClientSite->QueryInterface(IID_IOleControlSite, (void**)&controlSite);
+ m_spClientSite->QueryInterface(IID_IOleControlSite, reinterpret_cast<void **>(&controlSite));
if (!controlSite)
return S_FALSE;
// set server type in the user-data of the window.
@@ -3653,8 +3651,8 @@ HRESULT WINAPI QAxServerBase::EnableModeless(BOOL fEnable)
static inline LPOLESTR QStringToOLESTR(const QString &qstring)
{
- LPOLESTR olestr = (wchar_t*)CoTaskMemAlloc(qstring.length()*2+2);
- memcpy(olestr, (ushort*)qstring.unicode(), qstring.length()*2);
+ LPOLESTR olestr = static_cast<wchar_t *>(CoTaskMemAlloc(size_t(qstring.length()) * 2 + 2));
+ memcpy(olestr, reinterpret_cast<const ushort *>(qstring.unicode()), size_t(qstring.length() * 2));
olestr[qstring.length()] = 0;
return olestr;
}
@@ -3700,7 +3698,7 @@ HRESULT WINAPI QAxServerBase::GetMiscStatus(DWORD dwAspect, DWORD *pdwStatus)
*/
HRESULT WINAPI QAxServerBase::Advise(IAdviseSink* pAdvSink, DWORD* pdwConnection)
{
- *pdwConnection = adviseSinks.count() + 1;
+ *pdwConnection = DWORD(adviseSinks.count()) + 1;
STATDATA data = { {0, 0, DVASPECT_CONTENT, -1, TYMED_NULL} , 0, pAdvSink, *pdwConnection };
adviseSinks.append(data);
pAdvSink->AddRef();
@@ -3749,7 +3747,7 @@ HRESULT QAxServerBase::internalActivate()
if (!m_spClientSite)
return S_OK;
if (!m_spInPlaceSite)
- m_spClientSite->QueryInterface(IID_IOleInPlaceSite, (void**)&m_spInPlaceSite);
+ m_spClientSite->QueryInterface(IID_IOleInPlaceSite, reinterpret_cast<void **>(&m_spInPlaceSite));
if (!m_spInPlaceSite)
return E_FAIL;
@@ -3813,7 +3811,7 @@ HRESULT QAxServerBase::internalActivate()
}
if (m_spInPlaceFrame) {
- hr = m_spInPlaceFrame->SetActiveObject(this, (wchar_t*)class_name.utf16());
+ hr = m_spInPlaceFrame->SetActiveObject(this, reinterpret_cast<const wchar_t *>(class_name.utf16()));
if (!FAILED(hr)) {
menuBar = (qt.widget && !qax_disable_inplaceframe) ? qt.widget->findChild<QMenuBar*>() : 0;
if (menuBar && !menuBar->isVisible()) {
@@ -3831,7 +3829,7 @@ HRESULT QAxServerBase::internalActivate()
}
}
if (spInPlaceUIWindow) {
- spInPlaceUIWindow->SetActiveObject(this, (wchar_t*)class_name.utf16());
+ spInPlaceUIWindow->SetActiveObject(this, reinterpret_cast<const wchar_t *>(class_name.utf16()));
spInPlaceUIWindow->SetBorderSpace(0);
}
}
@@ -3992,7 +3990,7 @@ HRESULT WINAPI QAxServerBase::SetClientSite(IOleClientSite* pClientSite)
m_spClientSite = pClientSite;
if (m_spClientSite) {
m_spClientSite->AddRef();
- m_spClientSite->QueryInterface(IID_IOleInPlaceSite, (void **)&m_spInPlaceSite);
+ m_spClientSite->QueryInterface(IID_IOleInPlaceSite, reinterpret_cast<void **>(&m_spInPlaceSite));
}
return S_OK;
@@ -4133,7 +4131,7 @@ HRESULT WINAPI QAxServerBase::GetData(FORMATETC *pformatetcIn, STGMEDIUM *pmediu
return ResultFromScode(STG_E_MEDIUMFULL);
}
- LPMETAFILEPICT pMF = (LPMETAFILEPICT)GlobalLock(hMem);
+ LPMETAFILEPICT pMF = static_cast<LPMETAFILEPICT>(GlobalLock(hMem));
pMF->hMF = hMF;
pMF->mm = MM_ANISOTROPIC;
const SIZEL sizeL = qaxMapPixToLogHiMetrics(QSize(width, height), qt.widget);
@@ -4226,7 +4224,7 @@ HRESULT WINAPI QAxServerBase::EnumFormatEtc(DWORD /* dwDirection */, IEnumFORMAT
-static int mapModifiers(int state)
+static int mapModifiers(Qt::KeyboardModifiers state)
{
int ole = 0;
if (state & Qt::ShiftModifier)
@@ -4272,7 +4270,7 @@ bool QAxServerBase::eventFilter(QObject *o, QEvent *e)
break;
case QEvent::KeyPress:
if (o == qt.object && hasStockEvents) {
- QKeyEvent *ke = (QKeyEvent*)e;
+ const QKeyEvent *ke = static_cast<const QKeyEvent *>(e);
int key = ke->key();
int state = ke->modifiers();
void *argv[] = {
@@ -4287,7 +4285,7 @@ bool QAxServerBase::eventFilter(QObject *o, QEvent *e)
break;
case QEvent::KeyRelease:
if (o == qt.object && hasStockEvents) {
- QKeyEvent *ke = (QKeyEvent*)e;
+ const QKeyEvent *ke = static_cast<const QKeyEvent *>(e);
int key = ke->key();
int state = ke->modifiers();
void *argv[] = {
@@ -4300,7 +4298,7 @@ bool QAxServerBase::eventFilter(QObject *o, QEvent *e)
break;
case QEvent::MouseMove:
if (o == qt.object && hasStockEvents) {
- QMouseEvent *me = (QMouseEvent*)e;
+ const QMouseEvent *me = static_cast<const QMouseEvent *>(e);
int button = me->buttons() & Qt::MouseButtonMask;
int state = mapModifiers(me->modifiers());
int x = me->x();
@@ -4317,7 +4315,7 @@ bool QAxServerBase::eventFilter(QObject *o, QEvent *e)
break;
case QEvent::MouseButtonRelease:
if (o == qt.object && hasStockEvents) {
- QMouseEvent *me = (QMouseEvent*)e;
+ const QMouseEvent *me = static_cast<const QMouseEvent *>(e);
int button = me->button();
int state = mapModifiers(me->modifiers());
int x = me->x();
@@ -4343,7 +4341,7 @@ bool QAxServerBase::eventFilter(QObject *o, QEvent *e)
internalActivate();
}
if (o == qt.widget && hasStockEvents) {
- QMouseEvent *me = (QMouseEvent*)e;
+ const QMouseEvent *me = static_cast<const QMouseEvent *>(e);
int button = me->button();
int state = mapModifiers(me->modifiers());
int x = me->x();
diff --git a/src/activeqt/control/qaxservermain.cpp b/src/activeqt/control/qaxservermain.cpp
index 8adb504..7aec11d 100644
--- a/src/activeqt/control/qaxservermain.cpp
+++ b/src/activeqt/control/qaxservermain.cpp
@@ -138,7 +138,7 @@ bool qax_startServer(QAxFactory::ServerType type)
CLSID clsid = qAxFactory()->classID(keys.at(object));
// Create a QClassFactory (implemented in qaxserverbase.cpp)
- HRESULT hRes = GetClassObject(clsid, IID_IClassFactory, (void**)&p);
+ HRESULT hRes = GetClassObject(clsid, IID_IClassFactory, reinterpret_cast<void **>(&p));
if (SUCCEEDED(hRes))
hRes = CoRegisterClassObject(clsid, p, CLSCTX_LOCAL_SERVER,
type == QAxFactory::MultipleInstances ? REGCLS_MULTIPLEUSE : REGCLS_SINGLEUSE,
diff --git a/src/activeqt/shared/qaxtypefunctions.cpp b/src/activeqt/shared/qaxtypefunctions.cpp
index 7e2d98b..63bc3df 100644
--- a/src/activeqt/shared/qaxtypefunctions.cpp
+++ b/src/activeqt/shared/qaxtypefunctions.cpp
@@ -71,8 +71,8 @@ bool QVariantToVoidStar(const QVariant &var, void *data, const QByteArray &typeN
if (!data)
return true;
- if (type == QMetaType::QVariant || type == QVariant::LastType || (type == 0 && typeName == "QVariant")) {
- *(QVariant*)data = var;
+ if (type == QMetaType::QVariant || type == uint(QVariant::LastType) || (type == 0 && typeName == "QVariant")) {
+ *reinterpret_cast<QVariant *>(data) = var;
return true;
}
@@ -80,69 +80,70 @@ bool QVariantToVoidStar(const QVariant &var, void *data, const QByteArray &typeN
case QVariant::Invalid:
break;
case QVariant::String:
- *(QString*)data = var.toString();
+ *reinterpret_cast<QString *>(data) = var.toString();
break;
case QVariant::Int:
- *(int*)data = var.toInt();
+ *reinterpret_cast<int *>(data) = var.toInt();
break;
case QVariant::UInt:
- *(uint*)data = var.toUInt();
+ *reinterpret_cast<uint *>(data) = var.toUInt();
break;
case QVariant::Bool:
- *(bool*)data = var.toBool();
+ *reinterpret_cast<bool *>(data) = var.toBool();
break;
case QVariant::Double:
- *(double*)data = var.toDouble();
+ *reinterpret_cast<double *>(data) = var.toDouble();
break;
case QVariant::Color:
- *(QColor*)data = qvariant_cast<QColor>(var);
+ *reinterpret_cast<QColor *>(data) = qvariant_cast<QColor>(var);
break;
case QVariant::Date:
- *(QDate*)data = var.toDate();
+ *reinterpret_cast<QDate *>(data) = var.toDate();
break;
case QVariant::Time:
- *(QTime*)data = var.toTime();
+ *reinterpret_cast<QTime *>(data) = var.toTime();
break;
case QVariant::DateTime:
- *(QDateTime*)data = var.toDateTime();
+ *reinterpret_cast<QDateTime *>(data) = var.toDateTime();
break;
case QVariant::Font:
- *(QFont*)data = qvariant_cast<QFont>(var);
+ *reinterpret_cast<QFont *>(data) = qvariant_cast<QFont>(var);
break;
case QVariant::Pixmap:
- *(QPixmap*)data = qvariant_cast<QPixmap>(var);
+ *reinterpret_cast<QPixmap *>(data) = qvariant_cast<QPixmap>(var);
break;
#ifndef QT_NO_CURSOR
case QVariant::Cursor:
- *(QCursor*)data = qvariant_cast<QCursor>(var);
+ *reinterpret_cast<QCursor *>(data) = qvariant_cast<QCursor>(var);
break;
#endif
case QVariant::List:
- *(QList<QVariant>*)data = var.toList();
+ *reinterpret_cast<QList<QVariant> *>(data) = var.toList();
break;
case QVariant::StringList:
- *(QStringList*)data = var.toStringList();
+ *reinterpret_cast<QStringList *>(data) = var.toStringList();
break;
case QVariant::ByteArray:
- *(QByteArray*)data = var.toByteArray();
+ *reinterpret_cast<QByteArray *>(data) = var.toByteArray();
break;
case QVariant::LongLong:
- *(qint64*)data = var.toLongLong();
+ *reinterpret_cast<qint64 *>(data) = var.toLongLong();
break;
case QVariant::ULongLong:
- *(quint64*)data = var.toULongLong();
+ *reinterpret_cast<quint64 *>(data) = var.toULongLong();
break;
case QVariant::Rect:
- *(QRect*)data = var.toRect();
+ *reinterpret_cast<QRect *>(data) = var.toRect();
break;
case QVariant::Size:
- *(QSize*)data = var.toSize();
+ *reinterpret_cast<QSize *>(data) = var.toSize();
break;
case QVariant::Point:
- *(QPoint*)data = var.toPoint();
+ *reinterpret_cast<QPoint *>(data) = var.toPoint();
break;
case QVariant::UserType:
- *(void**)data = *(void**)var.constData();
+ *reinterpret_cast<void **>(data) =
+ *reinterpret_cast<void **>(const_cast<void *>(var.constData()));
// qVariantGet(var, *(void**)data, typeName);
break;
default:
diff --git a/src/activeqt/shared/qaxtypefunctions.h b/src/activeqt/shared/qaxtypefunctions.h
index 74dfc89..d4fb604 100644
--- a/src/activeqt/shared/qaxtypefunctions.h
+++ b/src/activeqt/shared/qaxtypefunctions.h
@@ -68,7 +68,7 @@ struct IAxServerBase : public IUnknown
static inline BSTR QStringToBSTR(const QString &str)
{
- return SysAllocStringLen((OLECHAR*)str.unicode(), str.length());
+ return SysAllocStringLen(reinterpret_cast<const OLECHAR*>(str.unicode()), UINT(str.length()));
}
static inline uint QColorToOLEColor(const QColor &col)
diff --git a/src/tools/idc/main.cpp b/src/tools/idc/main.cpp
index 3a02f8c..60ec1e4 100644
--- a/src/tools/idc/main.cpp
+++ b/src/tools/idc/main.cpp
@@ -69,7 +69,7 @@ static bool prependPath()
return false;
*ptr++ = L';';
const wchar_t pathVariable[] = L"PATH";
- if (!GetEnvironmentVariable(pathVariable, ptr, maxEnvironmentSize - (ptr - buffer))
+ if (!GetEnvironmentVariable(pathVariable, ptr, DWORD(maxEnvironmentSize - (ptr - buffer)))
|| !SetEnvironmentVariable(pathVariable, buffer)) {
return false;
}
@@ -81,9 +81,9 @@ static QString errorString(DWORD errorCode)
wchar_t *resultW = 0;
FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER|FORMAT_MESSAGE_FROM_SYSTEM,
NULL, errorCode, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
- (LPWSTR)&resultW, 0, NULL);
+ reinterpret_cast<LPWSTR>(&resultW), 0, NULL);
const QString result = QString::fromWCharArray(resultW);
- LocalFree((HLOCAL)resultW);
+ LocalFree(resultW);
return result;
}
@@ -141,13 +141,14 @@ static bool runWithQtInEnvironment(const QString &cmd)
static bool attachTypeLibrary(const QString &applicationName, int resource, const QByteArray &data, QString *errorMessage)
{
- HANDLE hExe = BeginUpdateResource((const wchar_t *)applicationName.utf16(), false);
+ HANDLE hExe = BeginUpdateResource(reinterpret_cast<const wchar_t *>(applicationName.utf16()), false);
if (hExe == 0) {
if (errorMessage)
*errorMessage = QString::fromLatin1("Failed to attach type library to binary %1 - could not open file.").arg(applicationName);
return false;
}
- if (!UpdateResource(hExe, L"TYPELIB", MAKEINTRESOURCE(resource), 0, (void*)data.data(), data.count())) {
+ if (!UpdateResource(hExe, L"TYPELIB", MAKEINTRESOURCE(resource), 0,
+ const_cast<char *>(data.data()), DWORD(data.count()))) {
EndUpdateResource(hExe, true);
if (errorMessage)
*errorMessage = QString::fromLatin1("Failed to attach type library to binary %1 - could not update file.").arg(applicationName);
@@ -176,10 +177,10 @@ static bool attachTypeLibrary(const QString &applicationName, int resource, cons
static HMODULE loadLibraryQt(const QString &input)
{
if (QSysInfo::windowsVersion() < QSysInfo::WV_VISTA)
- return LoadLibrary((const wchar_t *)input.utf16()); // fallback for Windows XP and older
+ return LoadLibrary(reinterpret_cast<const wchar_t *>(input.utf16())); // fallback for Windows XP and older
// Load DLL with the folder containing the DLL temporarily added to the search path when loading dependencies
- return LoadLibraryEx((const wchar_t *)input.utf16(), NULL,
+ return LoadLibraryEx(reinterpret_cast<const wchar_t *>(input.utf16()), NULL,
LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR | LOAD_LIBRARY_SEARCH_DEFAULT_DIRS);
}
@@ -195,7 +196,7 @@ static bool registerServer(const QString &input)
return false;
}
typedef HRESULT(__stdcall* RegServerProc)();
- RegServerProc DllRegisterServer = (RegServerProc)GetProcAddress(hdll, "DllRegisterServer");
+ RegServerProc DllRegisterServer = reinterpret_cast<RegServerProc>(GetProcAddress(hdll, "DllRegisterServer"));
if (!DllRegisterServer) {
fprintf(stderr, "Library file %s doesn't appear to be a COM library\n", qPrintable(input));
return false;
@@ -217,7 +218,7 @@ static bool unregisterServer(const QString &input)
return false;
}
typedef HRESULT(__stdcall* RegServerProc)();
- RegServerProc DllUnregisterServer = (RegServerProc)GetProcAddress(hdll, "DllUnregisterServer");
+ RegServerProc DllUnregisterServer = reinterpret_cast<RegServerProc>(GetProcAddress(hdll, "DllUnregisterServer"));
if (!DllUnregisterServer) {
fprintf(stderr, "Library file %s doesn't appear to be a COM library\n", qPrintable(input));
return false;
@@ -241,7 +242,7 @@ static HRESULT dumpIdl(const QString &input, const QString &idlfile, const QStri
return 3;
}
typedef HRESULT(__stdcall* DumpIDLProc)(const QString&, const QString&);
- DumpIDLProc DumpIDL = (DumpIDLProc)GetProcAddress(hdll, "DumpIDL");
+ DumpIDLProc DumpIDL = reinterpret_cast<DumpIDLProc>(GetProcAddress(hdll, "DumpIDL"));
if (!DumpIDL) {
fprintf(stderr, "Couldn't resolve 'DumpIDL' symbol in %s\n", qPrintable(input));
return 3;
diff --git a/tools/dumpcpp/main.cpp b/tools/dumpcpp/main.cpp
index aa96d8c..84b8768 100644
--- a/tools/dumpcpp/main.cpp
+++ b/tools/dumpcpp/main.cpp
@@ -76,10 +76,10 @@ extern QString qax_docuFromName(ITypeInfo *typeInfo, const QString &name);
extern bool qax_dispatchEqualsIDispatch;
extern void qax_deleteMetaObject(QMetaObject *mo);
-QMap<QByteArray, QByteArray> namespaceForType;
-QVector<QByteArray> strings;
-QHash<QByteArray, int> stringIndex; // Optimization, speeds up generation
-QByteArrayList vTableOnlyStubs;
+static QMap<QByteArray, QByteArray> namespaceForType;
+static QVector<QByteArray> strings;
+static QHash<QByteArray, int> stringIndex; // Optimization, speeds up generation
+static QByteArrayList vTableOnlyStubs;
void writeEnums(QTextStream &out, const QMetaObject *mo)
{
@@ -342,7 +342,7 @@ void generateClassDecl(QTextStream &out, const QString &controlID, const QMetaOb
if (isupper(setter.at(0))) {
setter = "Set" + setter;
} else {
- setter[0] = toupper(setter[0]);
+ setter[0] = char(toupper(setter[0]));
setter = "set" + setter;
}
@@ -567,13 +567,13 @@ QT_FOR_EACH_STATIC_TYPE(RETURN_METATYPENAME_STRING)
return 0;
}
-uint nameToBuiltinType(const QByteArray &name)
+int nameToBuiltinType(const QByteArray &name)
{
if (name.isEmpty())
return 0;
- uint tp = QMetaType::type(name.constData());
- return tp < uint(QMetaType::User) ? tp : uint(QMetaType::UnknownType);
+ const int tp = QMetaType::type(name.constData());
+ return tp < QMetaType::User ? tp : QMetaType::UnknownType;
}
void copyFileToStream(QFile *file, QTextStream *stream)