summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2020-05-27 08:15:54 +0200
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2020-05-28 07:49:05 +0200
commitf5982f32cd38fb8b63522fe4390ac10eb2b1b157 (patch)
tree91eb07909dfffd6528458d6efd9597f9ce893c26 /src
parent592dcba7276b129220a27af3bef44a736ca347ba (diff)
Introduce private classes for QAxWidget, QAxObject
It solves the problem of calling virtual clear() from the destructor and prepares for further changes. Change-Id: Icb8530c70e451ab5f27443fbd54fb3b3cf5e8c03 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/activeqt/container/CMakeLists.txt4
-rw-r--r--src/activeqt/container/container.pro2
-rw-r--r--src/activeqt/container/qaxobject.cpp24
-rw-r--r--src/activeqt/container/qaxobject.h12
-rw-r--r--src/activeqt/container/qaxobject_p.h79
-rw-r--r--src/activeqt/container/qaxwidget.cpp74
-rw-r--r--src/activeqt/container/qaxwidget.h13
-rw-r--r--src/activeqt/container/qaxwidget_p.h83
8 files changed, 244 insertions, 47 deletions
diff --git a/src/activeqt/container/CMakeLists.txt b/src/activeqt/container/CMakeLists.txt
index ddb16d8..0f2ac6d 100644
--- a/src/activeqt/container/CMakeLists.txt
+++ b/src/activeqt/container/CMakeLists.txt
@@ -12,12 +12,12 @@ qt_add_module(AxContainer
../shared/qaxtypes.cpp ../shared/qaxtypes_p.h
qaxbase.cpp qaxbase.h qaxbase_p.h
qaxdump.cpp
- qaxobject.cpp qaxobject.h
+ qaxobject.cpp qaxobject.h qaxobject_p.h
qaxobjectinterface.h
qaxscript.cpp qaxscript.h
qaxscriptwrapper.cpp
qaxselect.cpp qaxselect.h qaxselect.ui
- qaxwidget.cpp qaxwidget.h
+ qaxwidget.cpp qaxwidget.h qaxwidget_p.h
LIBRARIES
Qt::AxBasePrivate
Qt::CorePrivate
diff --git a/src/activeqt/container/container.pro b/src/activeqt/container/container.pro
index a5cf33a..f0b482b 100644
--- a/src/activeqt/container/container.pro
+++ b/src/activeqt/container/container.pro
@@ -8,7 +8,9 @@ HEADERS = ../control/qaxaggregated.h \
qaxbase.h \
qaxbase_p.h \
qaxwidget.h \
+ qaxwidget_p.h \
qaxobject.h \
+ qaxobject_p.h \
qaxobjectinterface.h \
qaxscript.h \
qaxselect.h \
diff --git a/src/activeqt/container/qaxobject.cpp b/src/activeqt/container/qaxobject.cpp
index 317f83b..4a30803 100644
--- a/src/activeqt/container/qaxobject.cpp
+++ b/src/activeqt/container/qaxobject.cpp
@@ -49,6 +49,7 @@
****************************************************************************/
#include "qaxobject.h"
+#include "qaxobject_p.h"
#include "qaxbase_p.h"
#include <quuid.h>
@@ -84,6 +85,11 @@ private:
QAxBaseObject *m_o;
};
+QAxBaseObject::QAxBaseObject(QObjectPrivate &d, QObject *parent)
+ : QObject(d, parent)
+{
+}
+
/*!
\class QAxBaseObject
\brief QAxBaseObject provides static properties and signals for QAxObject.
@@ -187,7 +193,7 @@ private:
QObject constructor. To initialize the object, call setControl().
*/
QAxObject::QAxObject(QObject *parent)
-: QAxBaseObject(parent)
+: QAxBaseObject(*new QAxObjectPrivate, parent)
{
axBaseInit(new QAxObjectSignalBridge(this));
}
@@ -199,7 +205,7 @@ QAxObject::QAxObject(QObject *parent)
\sa setControl()
*/
QAxObject::QAxObject(const QString &c, QObject *parent)
-: QAxBaseObject(parent)
+: QAxBaseObject(*new QAxObjectPrivate, parent)
{
axBaseInit(new QAxObjectSignalBridge(this));
setControl(c);
@@ -210,7 +216,7 @@ QAxObject::QAxObject(const QString &c, QObject *parent)
iface. \a parent is propagated to the QObject constructor.
*/
QAxObject::QAxObject(IUnknown *iface, QObject *parent)
-: QAxBaseObject(parent), QAxBase(iface)
+: QAxBaseObject(*new QAxObjectPrivate, parent), QAxBase(iface)
{
axBaseInit(new QAxObjectSignalBridge(this));
}
@@ -221,7 +227,8 @@ QAxObject::QAxObject(IUnknown *iface, QObject *parent)
*/
QAxObject::~QAxObject()
{
- clear();
+ Q_D(QAxObject);
+ d->clear();
}
unsigned long QAxObject::classContext() const
@@ -246,7 +253,14 @@ bool QAxObject::setControl(const QString &c)
void QAxObject::clear()
{
- QAxBase::clear();
+ Q_D(QAxObject);
+ d->clear();
+}
+
+void QAxObjectPrivate::clear()
+{
+ Q_Q(QAxObject);
+ q->QAxBase::clear();
}
/*!
diff --git a/src/activeqt/container/qaxobject.h b/src/activeqt/container/qaxobject.h
index 56275c0..70d92d2 100644
--- a/src/activeqt/container/qaxobject.h
+++ b/src/activeqt/container/qaxobject.h
@@ -56,26 +56,28 @@
QT_BEGIN_NAMESPACE
+class QAxObjectPrivate;
+
class QAxBaseObject : public QObject, public QAxObjectInterface
{
Q_OBJECT
Q_PROPERTY(ulong classContext READ classContext WRITE setClassContext)
Q_PROPERTY(QString control READ control WRITE setControl RESET clear)
-protected:
- using QObject::QObject;
-
-public:
-
Q_SIGNALS:
void exception(int code, const QString &source, const QString &desc, const QString &help);
void propertyChanged(const QString &name);
void signal(const QString &name, int argc, void *argv);
+
+protected:
+ using QObject::QObject;
+ QAxBaseObject(QObjectPrivate &d, QObject* parent);
};
class QAxObject : public QAxBaseObject, public QAxBase
{
friend class QAxEventSink;
+ Q_DECLARE_PRIVATE(QAxObject)
public:
QObject* qObject() const override { return static_cast<QObject *>(const_cast<QAxObject *>(this)); }
const char *className() const override;
diff --git a/src/activeqt/container/qaxobject_p.h b/src/activeqt/container/qaxobject_p.h
new file mode 100644
index 0000000..43c8df1
--- /dev/null
+++ b/src/activeqt/container/qaxobject_p.h
@@ -0,0 +1,79 @@
+/****************************************************************************
+**
+** Copyright (C) 2020 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the ActiveQt framework of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** BSD License Usage
+** Alternatively, you may use this file under the terms of the BSD license
+** as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QAXOBJECT_P_H
+#define QAXOBJECT_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <QtAxContainer/qaxobject.h>
+#include <private/qobject_p.h>
+
+QT_BEGIN_NAMESPACE
+
+class QAxObjectPrivate : public QObjectPrivate
+{
+ Q_DECLARE_PUBLIC(QAxObject)
+public:
+ void clear();
+};
+
+QT_END_NAMESPACE
+
+#endif // QAXOBJECT_P_H
diff --git a/src/activeqt/container/qaxwidget.cpp b/src/activeqt/container/qaxwidget.cpp
index 4e2ca46..5d2aa53 100644
--- a/src/activeqt/container/qaxwidget.cpp
+++ b/src/activeqt/container/qaxwidget.cpp
@@ -49,6 +49,7 @@
****************************************************************************/
#include "qaxwidget.h"
+#include "qaxwidget_p.h"
#include "qaxbase_p.h"
#include <QtAxBase/private/qaxutils_p.h>
#include <QtAxBase/private/qaxtypefunctions_p.h>
@@ -2012,6 +2013,11 @@ void QAxHostWidget::paintEvent(QPaintEvent*)
\sa QAxBaseObject::exception()
*/
+QAxBaseWidget::QAxBaseWidget(QWidgetPrivate &d, QWidget *parent, Qt::WindowFlags f)
+ : QWidget(d, parent, f)
+{
+}
+
/*!
\class QAxWidget
\brief The QAxWidget class is a QWidget that wraps an ActiveX control.
@@ -2060,7 +2066,7 @@ void QAxHostWidget::paintEvent(QPaintEvent*)
call setControl().
*/
QAxWidget::QAxWidget(QWidget *parent, Qt::WindowFlags f)
-: QAxBaseWidget(parent, f)
+: QAxBaseWidget(*new QAxWidgetPrivate, parent, f)
{
axBaseInit(new QAxWidgetSignalBridge(this));
}
@@ -2072,7 +2078,7 @@ QAxWidget::QAxWidget(QWidget *parent, Qt::WindowFlags f)
\sa setControl()
*/
QAxWidget::QAxWidget(const QString &c, QWidget *parent, Qt::WindowFlags f)
-: QAxBaseWidget(parent, f)
+: QAxBaseWidget(*new QAxWidgetPrivate, parent, f)
{
axBaseInit(new QAxWidgetSignalBridge(this));
setControl(c);
@@ -2083,7 +2089,7 @@ QAxWidget::QAxWidget(const QString &c, QWidget *parent, Qt::WindowFlags f)
\a parent and \a f are propagated to the QWidget contructor.
*/
QAxWidget::QAxWidget(IUnknown *iface, QWidget *parent, Qt::WindowFlags f)
-: QAxBaseWidget(parent, f), QAxBase(iface)
+: QAxBaseWidget(*new QAxWidgetPrivate, parent, f), QAxBase(iface)
{
axBaseInit(new QAxWidgetSignalBridge(this));
}
@@ -2096,9 +2102,10 @@ QAxWidget::QAxWidget(IUnknown *iface, QWidget *parent, Qt::WindowFlags f)
*/
QAxWidget::~QAxWidget()
{
- if (container)
- container->reset(this);
- clear();
+ Q_D(QAxWidget);
+ if (d->container)
+ d->container->reset(this);
+ d->clear();
}
/*!
@@ -2152,10 +2159,11 @@ bool QAxWidget::createHostWindow(bool initialized)
*/
bool QAxWidget::createHostWindow(bool initialized, const QByteArray &data)
{
- if (!container) // Potentially called repeatedly from QAxBase::metaObject(), QAxWidget::initialize()
- container = new QAxClientSite(this);
+ Q_D(QAxWidget);
+ if (!d->container) // Potentially called repeatedly from QAxBase::metaObject(), QAxWidget::initialize()
+ d->container = new QAxClientSite(this);
- container->activateObject(initialized, data);
+ d->container->activateObject(initialized, data);
ATOM filter_ref = FindAtom(qaxatom);
if (!filter_ref)
@@ -2208,9 +2216,16 @@ bool QAxWidget::setControl(const QString &c)
*/
void QAxWidget::clear()
{
- if (isNull())
+ Q_D(QAxWidget);
+ d->clear();
+}
+
+void QAxWidgetPrivate::clear()
+{
+ Q_Q(QAxWidget);
+ if (q->isNull())
return;
- if (!QAxBase::control().isEmpty()) {
+ if (!q->QAxBase::control().isEmpty()) {
ATOM filter_ref = FindAtom(qaxatom);
if (filter_ref)
DeleteAtom(filter_ref);
@@ -2222,8 +2237,8 @@ void QAxWidget::clear()
if (container)
container->deactivate();
- QAxBase::clear();
- setFocusPolicy(Qt::NoFocus);
+ q->QAxBase::clear();
+ q->setFocusPolicy(Qt::NoFocus);
if (container) {
container->releaseAll();
@@ -2242,12 +2257,11 @@ void QAxWidget::clear()
*/
bool QAxWidget::doVerb(const QString &verb)
{
+ Q_D(QAxWidget);
if (!verbs().contains(verb))
return false;
- HRESULT hres = container->doVerb(indexOfVerb(verb));
-
- return hres == S_OK;
+ return d->container->doVerb(indexOfVerb(verb)) == S_OK;
}
/*!
@@ -2321,8 +2335,9 @@ int QAxWidget::qt_metacall(QMetaObject::Call call, int id, void **v)
*/
QSize QAxWidget::sizeHint() const
{
- if (container) {
- QSize sh = container->sizeHint();
+ Q_D(const QAxWidget);
+ if (d->container) {
+ QSize sh = d->container->sizeHint();
if (sh.isValid())
return sh;
}
@@ -2335,8 +2350,9 @@ QSize QAxWidget::sizeHint() const
*/
QSize QAxWidget::minimumSizeHint() const
{
- if (container) {
- QSize sh = container->minimumSizeHint();
+ Q_D(const QAxWidget);
+ if (d->container) {
+ QSize sh = d->container->minimumSizeHint();
if (sh.isValid())
return sh;
}
@@ -2349,22 +2365,23 @@ QSize QAxWidget::minimumSizeHint() const
*/
void QAxWidget::changeEvent(QEvent *e)
{
- if (isNull() || !container)
+ Q_D(QAxWidget);
+ if (isNull() || !d->container)
return;
switch (e->type()) {
case QEvent::EnabledChange:
- container->emitAmbientPropertyChange(DISPID_AMBIENT_UIDEAD);
+ d->container->emitAmbientPropertyChange(DISPID_AMBIENT_UIDEAD);
break;
case QEvent::FontChange:
- container->emitAmbientPropertyChange(DISPID_AMBIENT_FONT);
+ d->container->emitAmbientPropertyChange(DISPID_AMBIENT_FONT);
break;
case QEvent::PaletteChange:
- container->emitAmbientPropertyChange(DISPID_AMBIENT_BACKCOLOR);
- container->emitAmbientPropertyChange(DISPID_AMBIENT_FORECOLOR);
+ d->container->emitAmbientPropertyChange(DISPID_AMBIENT_BACKCOLOR);
+ d->container->emitAmbientPropertyChange(DISPID_AMBIENT_FORECOLOR);
break;
case QEvent::ActivationChange:
- container->windowActivationChange();
+ d->container->windowActivationChange();
break;
default:
break;
@@ -2376,8 +2393,9 @@ void QAxWidget::changeEvent(QEvent *e)
*/
void QAxWidget::resizeEvent(QResizeEvent *)
{
- if (container)
- container->resize(size());
+ Q_D(QAxWidget);
+ if (d->container)
+ d->container->resize(size());
}
/*!
diff --git a/src/activeqt/container/qaxwidget.h b/src/activeqt/container/qaxwidget.h
index a161246..25a6f75 100644
--- a/src/activeqt/container/qaxwidget.h
+++ b/src/activeqt/container/qaxwidget.h
@@ -57,7 +57,6 @@
QT_BEGIN_NAMESPACE
-class QAxHostWindow;
class QAxAggregated;
class QAxClientSite;
@@ -68,15 +67,16 @@ class QAxBaseWidget : public QWidget, public QAxObjectInterface
Q_OBJECT
Q_PROPERTY(ulong classContext READ classContext WRITE setClassContext)
Q_PROPERTY(QString control READ control WRITE setControl RESET clear)
-protected:
- using QWidget::QWidget;
-
public:
Q_SIGNALS:
void exception(int code, const QString &source, const QString &desc, const QString &help);
void propertyChanged(const QString &name);
void signal(const QString &name, int argc, void *argv);
+
+protected:
+ using QWidget::QWidget;
+ QAxBaseWidget(QWidgetPrivate &d, QWidget *parent, Qt::WindowFlags f);
};
class QAxWidget : public QAxBaseWidget, public QAxBase
@@ -121,10 +121,9 @@ protected:
void connectNotify(const QMetaMethod &signal) override;
const QMetaObject *fallbackMetaObject() const override;
private:
- friend class QAxClientSite;
- QAxClientSite *container = nullptr;
+ Q_DECLARE_PRIVATE(QAxWidget)
- QAxWidgetPrivate *m_unused = nullptr;
+ friend class QAxClientSite;
const QMetaObject *parentMetaObject() const override;
};
diff --git a/src/activeqt/container/qaxwidget_p.h b/src/activeqt/container/qaxwidget_p.h
new file mode 100644
index 0000000..c0f8e7e
--- /dev/null
+++ b/src/activeqt/container/qaxwidget_p.h
@@ -0,0 +1,83 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the ActiveQt framework of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** BSD License Usage
+** Alternatively, you may use this file under the terms of the BSD license
+** as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QAXWIDGET_P_H
+#define QAXWIDGET_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <QtAxContainer/qaxwidget.h>
+#include <private/qwidget_p.h>
+
+QT_BEGIN_NAMESPACE
+
+class QAxClientSite;
+
+class QAxWidgetPrivate : public QWidgetPrivate
+{
+ Q_DECLARE_PUBLIC(QAxWidget)
+public:
+ void clear();
+
+ QAxClientSite *container = nullptr;
+};
+
+QT_END_NAMESPACE
+
+#endif // QAXWIDGET_P_H