[Qt-interest] Problem with unloading a plugin under Win7 and QtNetwork

Michael Ernst | Sobex ernst at sobex.de
Wed Jan 12 23:57:52 CET 2011


Hi,

I wrote an update service which is loaded as plug-in. It downloads Files via HTTP and uses QNetworkAccessManager for the network requests. The files are stored in a temporary directory. After that the plug-in is unloaded so that it could be updated as well - that is the theory. There is no problem under Windows Xp, but Windows 7 shows some strange behavior. After calling the unload function of QPluginLoader the program is stuck and the call does not return. That kind of behavior of QPluginLoader is completely unknown to me. There is another strange phenomenon. This problem only occurs on machines without an IDE (I used VS 2008 / 32 bit to compile the program).

I put an example together which demonstrates the problem and attached it. Here is the most important code:

Loader class:

void Loader::load()
{
    loader.setFileName(qApp->applicationDirPath() + "/plugin.dll");
    QObject* obj = loader.instance();

    QThread* thr = qobject_cast<QThread*>(obj);
    connect(thr, SIGNAL(finished()), this, SLOT(finished()));
    thr->start();
}

void Loader::finished()
{
    loader.unload();
}

and the plugin class:
void Plugin::run()
{
    QNetworkAccessManager manager;
    QNetworkRequest request;
    request.setUrl(QUrl("http://qt.nokia.com"));
    request.setRawHeader("User-Agent", "MyOwnBrowser 1.0");

    QNetworkReply* reply = manager.get(request);
    connect(reply, SIGNAL(finished()), this, SLOT(finished()));
    exec();
    delete reply;
}

void Plugin::finished()
{
    quit();
}

It is shortened to the most existential parts. Maybe someone has an idea.

Thanks,
Michael

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20110112/4c2e4fff/attachment.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: plugin-network.zip
Type: application/x-zip-compressed
Size: 2690 bytes
Desc: plugin-network.zip
Url : http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20110112/4c2e4fff/attachment.bin 


More information about the Qt-interest-old mailing list