"Zombie" process after using QAxWidget::setControl



  • Hi,
    I have created very simple activeX host and also very simple activeX "plugin" for it. Host is just able to display other activeX registered in the system inside its main window. Everything is all right until I open created plugin. When my simple activeX control is opened there (PluginMW class name) after closing host application (press window close button) host window is closed but process is still running. Have anyone experienced similar behaviour?

    Code without *.ui, def and rc files for both projects below:

    Host application:

    QtHost.pro
    @QT += core gui axserver axcontainer

    RC_FILE = QtHost.rc

    greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

    TARGET = QtHost
    TEMPLATE = app

    SOURCES += main.cpp
    mainwindow.cpp

    HEADERS += mainwindow.h

    FORMS += mainwindow.ui@

    mainwindow.h
    @#pragma once
    #include <memory>
    #include <functional>
    #include <QMainWindow>
    #include <QAxBindable>

    namespace Ui {
    class MainWindow;
    }

    class HostMW :
    public QMainWindow,
    public QAxBindable
    {
    Q_OBJECT

    public:
        explicit HostMW(QWidget *parent = 0);
        ~HostMW();
    
    public Q_SLOTS:
        void    OpenActiveX();
    
    protected:
        virtual void closeEvent(QCloseEvent* event);
    
        std::unique_ptr<Ui::MainWindow> m_ui;
    

    };@

    mainwindow.cpp
    @#include "mainwindow.h"
    #include "ui_mainwindow.h"
    #include <QAxSelect>

    HostMW::HostMW(QWidget *parent) :
    QMainWindow(parent),
    m_ui(new Ui::MainWindow)
    {
    m_ui->setupUi(this);
    connect(m_ui->actionOpen, SIGNAL(triggered()), this, SLOT(OpenActiveX()));
    }

    HostMW::~HostMW()
    {
    }

    void HostMW::OpenActiveX()
    {
    QAxSelect selectDlg;

    if(selectDlg.exec&#40;&#41;)
        m_ui->axWidget->setControl( selectDlg.clsid() );
    

    }

    void HostMW::closeEvent(QCloseEvent* event)
    {
    m_ui->axWidget->clear();
    QMainWindow::closeEvent(event);
    }@

    main.cpp
    @#include "mainwindow.h"
    #include <QApplication>
    #include <QAxFactory>

    QAXFACTORY_DEFAULT( HostMW,
    "{E882C984-D032-4FE4-B9ED-FB6FB7AE14DC}",
    "{1E99D028-E029-46A4-A407-65201C202E2B}",
    "{CBC1659A-65AA-4563-8A02-8E66CD691626}",
    "{2D3ADEC5-F74F-4EE0-927D-57D8787D42FE}",
    "{278565C9-ADC5-4D6B-95FA-7AF273DAC06C}"
    )

    int main (int argc, char *argv[])
    {

    QApplication a(argc, argv);
    
    if(QAxFactory::isServer())
         return a.exec&#40;&#41;;
    
    HostMW w;
    w.show();
    return a.exec&#40;&#41;;
    

    }
    @

    Plugin activeX

    QtPlugin.pro
    @QT += core gui axserver

    RC_FILE = QtPlugin.rc
    DEF_FILE = QtPlugin.def

    greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

    TARGET = QtPlugin
    TEMPLATE = lib

    SOURCES += main.cpp
    pluginmainwnd.cpp

    HEADERS += pluginmainwnd.h

    FORMS += pluginmainwnd.ui
    @

    pluginmainwnd.h
    @#pragma once
    #include <QDialog>
    #include <QAxBindable>

    namespace Ui {
    class PluginMainWnd;
    }

    class PluginMW :
    public QDialog,
    public QAxBindable
    {
    Q_OBJECT

    public:
        explicit PluginMW(QWidget *parent = 0);
        ~PluginMW();
    
    private:
        Ui::PluginMainWnd *ui;
    

    };
    @

    pluginmainwnd.cpp
    @#include "pluginmainwnd.h"
    #include "ui_pluginmainwnd.h"

    PluginMW::PluginMW(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::PluginMainWnd)
    {
    ui->setupUi(this);
    }

    PluginMW::~PluginMW()
    {
    delete ui;
    }
    @

    main.cpp
    @#include "pluginmainwnd.h"
    #include <QAxFactory>

    QAXFACTORY_DEFAULT( PluginMW,
    "{ED25D61D-212C-4BD1-9D1D-494989A21417}",
    "{DEA97433-B364-4A3E-83E1-D9CD6CC51B27}",
    "{381308B5-A03A-4E92-969D-FFA24E813CE3}",
    "{FE2C1F9D-B063-480D-BA8E-E4CCA0ADF5C1}",
    "{5A6E1A28-E3AF-41DD-BFAB-C3F9498658A5}"
    )
    @



  • I forgot to mention.
    I use 5.4 QT on Windows 7. Process hangs inside QEventDispatcherWin32::processEvents
    on MsgWaitForMultipleObjectsEx function.

    Edit: operating system information added


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.