summaryrefslogtreecommitdiffstats
path: root/src/activeqt/control
diff options
context:
space:
mode:
Diffstat (limited to 'src/activeqt/control')
-rw-r--r--src/activeqt/control/qaxserver.cpp70
-rw-r--r--src/activeqt/control/qaxserverbase.cpp37
-rw-r--r--src/activeqt/control/qaxserverdll.cpp2
-rw-r--r--src/activeqt/control/qaxservermain.cpp4
4 files changed, 45 insertions, 68 deletions
diff --git a/src/activeqt/control/qaxserver.cpp b/src/activeqt/control/qaxserver.cpp
index 1703765..6abf2a7 100644
--- a/src/activeqt/control/qaxserver.cpp
+++ b/src/activeqt/control/qaxserver.cpp
@@ -248,7 +248,7 @@ HRESULT UpdateRegistry(BOOL bRegister)
// we try to create the ActiveX widgets later on...
bool delete_qApp = false;
if (!qApp) {
- int argc = 0;
+ static int argc = 0; // static lifetime, since it's passed as reference to QApplication, which has a lifetime exceeding the stack frame
(void)new QApplication(argc, 0);
delete_qApp = true;
}
@@ -496,13 +496,11 @@ static const char* const type_map[][2] =
// Userdefined Qt datatypes - some not on Borland though
{ "QCursor", "enum MousePointer" },
{ "Qt::FocusPolicy", "enum FocusPolicy" },
-#ifndef Q_CC_BOR
-# if __REQUIRED_RPCNDR_H_VERSION__ >= Q_REQUIRED_RPCNDR_H_VERSION
+#if __REQUIRED_RPCNDR_H_VERSION__ >= Q_REQUIRED_RPCNDR_H_VERSION
{ "QRect", "struct QRect" },
{ "QSize", "struct QSize" },
{ "QPoint", "struct QPoint" },
-# endif
-#endif
+#endif // __REQUIRED_RPCNDR_H_VERSION__ >= Q_REQUIRED_RPCNDR_H_VERSION
// And we support COM data types
{ "BOOL", "BOOL" },
{ "BSTR", "BSTR" },
@@ -704,7 +702,15 @@ bool ignoreProps(const char *test)
return ignore(test, ignore_props);
}
-#define STRIPCB(x) x = x.mid(1, x.length()-2)
+static QString stripCurlyBraces(const QUuid &uuid)
+{
+ if (uuid.isNull())
+ return QString();
+ QString result = uuid.toString().toUpper();
+ result.chop(1);
+ result.remove(0, 1);
+ return result;
+}
static QByteArray prototype(const QList<QByteArray> &parameterTypes, const QList<QByteArray> &parameterNames, bool *ok)
{
@@ -804,17 +810,14 @@ static HRESULT classIDL(QObject *o, const QMetaObject *mo, const QString &classN
control = true;
}
- QString classID = qAxFactory()->classID(className).toString().toUpper();
- if (QUuid(classID).isNull())
+ const QString classID = stripCurlyBraces(qAxFactory()->classID(className));
+ if (classID.isEmpty())
return 4;
- STRIPCB(classID);
- QString interfaceID = qAxFactory()->interfaceID(className).toString().toUpper();
- if (QUuid(interfaceID).isNull())
+ const QString interfaceID = stripCurlyBraces(qAxFactory()->interfaceID(className));
+ if (interfaceID.isEmpty())
return 5;
- STRIPCB(interfaceID);
- QString eventsID = qAxFactory()->eventsID(className).toString().toUpper();
- bool hasEvents = !QUuid(eventsID).isNull();
- STRIPCB(eventsID);
+ const QString eventsID = stripCurlyBraces(qAxFactory()->eventsID(className));
+ const bool hasEvents = !eventsID.isEmpty();
QString cleanClassName = qax_clean_type(className, mo);
QString defProp(QLatin1String(mo->classInfo(mo->indexOfClassInfo("DefaultProperty")).value()));
@@ -950,7 +953,7 @@ static HRESULT classIDL(QObject *o, const QMetaObject *mo, const QString &classN
if (i <= qtSlots && ignoreSlots(name))
continue;
- signature = signature.mid(name.length() + 1);
+ signature.remove(0, name.length() + 1);
signature.truncate(signature.length() - 1);
name = renameOverloads(replaceKeyword(name));
if (ignoreSlots(name))
@@ -970,7 +973,8 @@ static HRESULT classIDL(QObject *o, const QMetaObject *mo, const QString &classN
if (!ok)
outBuffer += "\t/****** Slot parameter uses unsupported datatype\n";
- outBuffer += "\t\t[id(" + QString::number(id).toLatin1() + ")] " + type + ' ' + name + '(' + ptype + ");\n";
+ outBuffer += "\t\t[id(" + QByteArray::number(id) + ")] " + type + ' '
+ + name + '(' + ptype + ");\n";
if (!ok)
outBuffer += "\t******/\n";
@@ -1016,7 +1020,7 @@ static HRESULT classIDL(QObject *o, const QMetaObject *mo, const QString &classN
QByteArray signature(signal.methodSignature());
QByteArray name(signature.left(signature.indexOf('(')));
- signature = signature.mid(name.length() + 1);
+ signature.remove(0, name.length() + 1);
signature.truncate(signature.length() - 1);
QList<QByteArray> parameterTypes(signal.parameterTypes());
@@ -1082,11 +1086,7 @@ static HRESULT classIDL(QObject *o, const QMetaObject *mo, const QString &classN
return S_OK;
}
-#if defined(Q_CC_BOR)
-extern "C" __stdcall HRESULT DumpIDL(const QString &outfile, const QString &ver)
-#else
extern "C" HRESULT __stdcall DumpIDL(const QString &outfile, const QString &ver)
-#endif
{
qAxIsServer = false;
QTextStream out;
@@ -1101,14 +1101,12 @@ extern "C" HRESULT __stdcall DumpIDL(const QString &outfile, const QString &ver)
QString filebase = QString::fromWCharArray(qAxModuleFilename);
filebase.truncate(filebase.lastIndexOf(QLatin1Char('.')));
- QString appID = qAxFactory()->appID().toString().toUpper();
- if (QUuid(appID).isNull())
+ const QString appID = stripCurlyBraces(qAxFactory()->appID());
+ if (appID.isEmpty())
return 1;
- STRIPCB(appID);
- QString typeLibID = qAxFactory()->typeLibID().toString().toUpper();
- if (QUuid(typeLibID).isNull())
+ const QString typeLibID = stripCurlyBraces(qAxFactory()->typeLibID());
+ if (typeLibID.isEmpty())
return 2;
- STRIPCB(typeLibID);
QString typelib = filebase.right(filebase.length() - filebase.lastIndexOf(QLatin1String("\\"))-1);
if (!file.open(QIODevice::WriteOnly))
@@ -1124,12 +1122,9 @@ extern "C" HRESULT __stdcall DumpIDL(const QString &outfile, const QString &ver)
if (version.isEmpty())
version = QLatin1String("1.0");
- QString idQRect(QUuid(CLSID_QRect).toString());
- STRIPCB(idQRect);
- QString idQSize(QUuid(CLSID_QSize).toString());
- STRIPCB(idQSize);
- QString idQPoint(QUuid(CLSID_QPoint).toString());
- STRIPCB(idQPoint);
+ const QString idQRect = stripCurlyBraces(QUuid(CLSID_QRect));
+ const QString idQSize = stripCurlyBraces(QUuid(CLSID_QSize));
+ const QString idQPoint = stripCurlyBraces(QUuid(CLSID_QPoint));
out << "/****************************************************************************" << endl;
out << "** Interface definition generated for ActiveQt project" << endl;
@@ -1147,7 +1142,7 @@ extern "C" HRESULT __stdcall DumpIDL(const QString &outfile, const QString &ver)
// dummy application to create widgets
bool delete_qApp = false;
if (!qApp) {
- int argc=0;
+ static int argc = 0; // static lifetime, since it's passed as reference to QApplication, which has a lifetime exceeding the stack frame
(void)new QApplication(argc, 0);
delete_qApp = true;
}
@@ -1172,7 +1167,6 @@ extern "C" HRESULT __stdcall DumpIDL(const QString &outfile, const QString &ver)
out << "\t** use the correct files." << endl;
out << "\t**" << endl;
-#ifndef Q_CC_BOR
#if __REQUIRED_RPCNDR_H_VERSION__ < Q_REQUIRED_RPCNDR_H_VERSION
out << "\t** Required version of MIDL could not be verified. QRect, QSize and QPoint" << endl;
out << "\t** support needs an updated Platform SDK to be installed." << endl;
@@ -1204,10 +1198,6 @@ extern "C" HRESULT __stdcall DumpIDL(const QString &outfile, const QString &ver)
#if __REQUIRED_RPCNDR_H_VERSION__ < Q_REQUIRED_RPCNDR_H_VERSION
out << "\t*/" << endl;
#endif
-#else
- out << "\t** Custom data types not supported with Borland." << endl;
- out << "\t*************************************************************************" << endl;
-#endif
out << endl;
out << "\t/* Forward declaration of classes that might be used as parameters */" << endl << endl;
diff --git a/src/activeqt/control/qaxserverbase.cpp b/src/activeqt/control/qaxserverbase.cpp
index b1eac89..d6af214 100644
--- a/src/activeqt/control/qaxserverbase.cpp
+++ b/src/activeqt/control/qaxserverbase.cpp
@@ -433,7 +433,7 @@ class QAxServerAggregate : public IUnknown
{
public:
QAxServerAggregate(const QString &className, IUnknown *outerUnknown)
- : m_outerUnknown(outerUnknown), ref(0)
+ : ref(0)
{
object = new QAxServerBase(className, outerUnknown);
object->registerActiveObject(this);
@@ -476,7 +476,6 @@ public:
private:
QAxServerBase *object;
- IUnknown *m_outerUnknown;
LONG ref;
CRITICAL_SECTION refCountSection;
@@ -790,7 +789,7 @@ private:
LRESULT QT_WIN_CALLBACK axs_FilterProc(int nCode, WPARAM wParam, LPARAM lParam)
{
if (qApp && !invokeCount)
- qApp->sendPostedEvents();
+ QCoreApplication::sendPostedEvents();
return CallNextHookEx(qax_hhook, nCode, wParam, lParam);
}
@@ -906,7 +905,7 @@ public:
int argc = 0;
new QApplication(argc, 0);
}
- qApp->setQuitOnLastWindowClosed(false);
+ QGuiApplication::setQuitOnLastWindowClosed(false);
if (qAxOutProcServer)
QAbstractEventDispatcher::instance()->installNativeEventFilter(qax_winEventFilter());
@@ -921,7 +920,7 @@ public:
// If we created QApplication instance, ensure native event loop starts properly
// by calling processEvents.
if (qax_ownQApp)
- qApp->processEvents();
+ QCoreApplication::processEvents();
HRESULT res;
// Create the ActiveX wrapper - aggregate if requested
@@ -1321,7 +1320,7 @@ bool QAxServerBase::internalCreate()
if (isWidget) {
if (!stayTopLevel) {
QEvent e(QEvent::EmbeddingControl);
- QApplication::sendEvent(qt.widget, &e);
+ QCoreApplication::sendEvent(qt.widget, &e);
}
qt.widget->setAttribute(Qt::WA_QuitOnClose, false);
qt.widget->move(0, 0);
@@ -1970,7 +1969,7 @@ int QAxServerBase::qt_metacall(QMetaObject::Call call, int index, void **argv)
}
}
- signature = signature.mid(name.length() + 1);
+ signature.remove(0, name.length() + 1);
signature.truncate(signature.length() - 1);
if (!signature.isEmpty())
@@ -2291,15 +2290,11 @@ HRESULT WINAPI QAxServerBase::Invoke(DISPID dispidMember, REFIID riid,
index = mo->indexOfProperty(name);
}
} else {
- BSTR bname;
- UINT cname = 0;
- if (m_spTypeInfo)
- m_spTypeInfo->GetNames(dispidMember, &bname, 1, &cname);
- if (!cname)
+ if (!m_spTypeInfo)
+ return res;
+ name = qaxTypeInfoName(m_spTypeInfo, dispidMember);
+ if (name.isEmpty())
return res;
-
- name = QString::fromWCharArray(bname).toLatin1();
- SysFreeString(bname);
}
}
@@ -2620,13 +2615,9 @@ HRESULT WINAPI QAxServerBase::Invoke(DISPID dispidMember, REFIID riid,
if (!exception->context.isNull()) {
QString context = exception->context;
int contextID = 0;
- int br = context.indexOf(QLatin1Char('['));
+ const int br = context.indexOf(QLatin1Char('[')); // "error[42]"
if (br != -1) {
- context = context.mid(br+1);
- context.chop(1);
- contextID = context.toInt();
-
- context = exception->context;
+ contextID = context.midRef(br + 1, context.size() - br - 2).toInt();
context.truncate(br-1);
}
pexcepinfo->bstrHelpFile = QStringToBSTR(context);
@@ -3343,7 +3334,7 @@ HRESULT WINAPI QAxServerBase::OnAmbientPropertyChange(DISPID dispID)
case DISPID_AMBIENT_RIGHTTOLEFT:
if (var.vt != VT_BOOL)
break;
- qApp->setLayoutDirection(var.boolVal?Qt::RightToLeft:Qt::LeftToRight);
+ QGuiApplication::setLayoutDirection(var.boolVal ? Qt::RightToLeft : Qt::LeftToRight);
break;
}
@@ -3582,7 +3573,7 @@ HRESULT WINAPI QAxServerBase::TranslateAcceleratorW(MSG *pMsg)
QKeyEvent override(QEvent::ShortcutOverride, key, (Qt::KeyboardModifiers)state);
override.ignore();
- QApplication::sendEvent(qt.widget->focusWidget(), &override);
+ QCoreApplication::sendEvent(qt.widget->focusWidget(), &override);
if (override.isAccepted())
return S_FALSE;
}
diff --git a/src/activeqt/control/qaxserverdll.cpp b/src/activeqt/control/qaxserverdll.cpp
index fa4619b..7117cbb 100644
--- a/src/activeqt/control/qaxserverdll.cpp
+++ b/src/activeqt/control/qaxserverdll.cpp
@@ -96,7 +96,7 @@ STDAPI DllCanUnloadNow()
return S_OK;
// check if qApp still runs widgets (in other DLLs)
- QWidgetList widgets = qApp->allWidgets();
+ QWidgetList widgets = QApplication::allWidgets();
int count = widgets.count();
for (int w = 0; w < widgets.count(); ++w) {
// remove all Qt generated widgets
diff --git a/src/activeqt/control/qaxservermain.cpp b/src/activeqt/control/qaxservermain.cpp
index 96cd503..8adb504 100644
--- a/src/activeqt/control/qaxservermain.cpp
+++ b/src/activeqt/control/qaxservermain.cpp
@@ -73,11 +73,7 @@ extern HRESULT GetClassObject(const GUID &clsid, const GUID &iid, void **ppUnk);
extern ulong qAxLockCount();
extern bool qax_winEventFilter(void *message);
-#if defined(Q_CC_BOR)
-extern "C" __stdcall HRESULT DumpIDL(const QString &outfile, const QString &ver);
-#else
STDAPI DumpIDL(const QString &outfile, const QString &ver);
-#endif
// Monitors the shutdown event
static DWORD WINAPI MonitorProc(void* /* pv */)