Hi,

My application is targeted to run as a software plugin inside another third party application. When a instance of my plugin is instanciated I check if qApp exists. If so, I will use that pointer, otherwise I will reuse the pointer. I also increment a counter to know how many instances of my plugin are active. When the plugin is deleted I check the counter. If it gets to zero I will delete qApp.

The problem is that I'm having a different behaviour across platforms. On OSX I don't even need to delete qApp, everything works alright. On Windows, if I don't delete the qApp, the host hangs, seems like a dead lock, so I need to force delete it and this is what I am doing:

_app->processEvents(QEventLoop::AllEvents, 1000);
_app->quit();
delete _app;
_app = 0;

This way, the host is able to close and exit but the return code is not zero, it is basically crashing but no error window pops up. If I don't call delete _app, the host hangs and it is not able to exit.

It is important to refer that I'm using a static and namespaced build of Qt and that I'm calling a new Windows thread to call qApp exec.

The thread body has two modes. Why? Because when I call _app->exec() it immediatelly returns saying that it must be called from main thread, however things continue to happen, Qml works, QObjects works, apparently at least! The approach works also, not apparent problems, but the thread doesn't return.

#ifdef Q_OS_WIN
unsigned int id;
Qt::HANDLE h = (Qt::HANDLE) _beginthreadex(NULL, 0, threadInit, this, 0, &id);
#endif

#ifdef Q_OS_WIN
unsigned int __stdcall threadInit(void *args)
{
    qDebug() << "--Qt Init Thread";
    IVst *plugin = (IVst*)args;

    #if 1
    while(plugin->_running)
        plugin->_app->processEvents();
    #else
    plugin->_app->exec();
    #endif

    qDebug() << "--Thread done";
    return 0;
}

So far on OSX I was not even deleting the app and it worked without issues.

Does anyone has a clue of what is going on?

Thanks,

Regards,

Nuno
_______________________________________________
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest

Reply via email to