[SOLVED] Plugin can load or not depending on whether my app is launched from Qt Creator or not



  • Hi, I am having an unexplained behaviour using Qt 4.7.3 and Qt Creator 2.2.1 on Windows 7 (everything works fine on Ubuntu 10.10 and Mac OS X 10.6 using the same versions of Qt and Qt Creator).

    Basically, my application relies on various plugins being loaded upon starting my application. Now, for some weird reason, there is one out of 10 plugins that doesn't load when running my application from outside Qt Creator while if I start my application from within Qt Creator, then the plugin loads fine! This is the case whether I build a debug or release version of my application.

    As I said, everything works fine on Linux and Mac OS X, so I am really puzzled as why that particular plugin doesn't load. Why that plugin?!

    I know it might be a very long shot, but is there something trivial that I might have overlooked?

    Here is some code that I use (before actually loading the plugin) to retrieve some information about the plugin itself:

    @PluginInfo Plugin::info(const QString &pPluginFileName)
    {
    // Return the information associated to the plugin

    PluginInfo pluginInfo;
    
    typedef PluginInfo (*PluginInfoFunc)();
    
    PluginInfoFunc pluginInfoFunc = (PluginInfoFunc) QLibrary::resolve(pPluginFileName,
                                                                       QString(name(pPluginFileName)+"PluginInfo").toLatin1().constData());
    
    if (pluginInfoFunc)
        // The plugin information function was found, so we can extract the
        // information we are after
    
        pluginInfo = pluginInfoFunc();
    else
    

    {
    // The plugin information funciton couldn't be found which means that
    // we are not dealing with an OpenCOR plugin

        pluginInfo.type = PluginInfo::Undefined;
    

    if (!name(pPluginFileName).compare("CellMLModelRepository")) {
    QLibrary lib(pPluginFileName);

    if (lib.load())
        QMessageBox::information(0, QString("Info"), "Can load...");
    else
        QMessageBox::information(0, QString("Info"), QString("Can NOT load... [%1 | %2]").arg(pPluginFileName,
                                                                                              QFileInfo(pPluginFileName).exists()?"YES":"NO"));
    

    }
    }@

    So, what happens is that I am trying to resolve a function which should be in my plugin. In all cases, it works but for that CellMLModelRepository plugin of mine. Having added some debug code, if the function cannot be found, I try to load the plugin using QLibrary which here fails for my CellMLModelRepository plugin even though QFile::exists() does report that the file exists...



  • For those curious about the above 'problem' that I reported, you can find some interesting information at Qt Centre where I also asked for some help: http://www.qtcentre.org/threads/42849-Plugin-can-load-or-not-depending-on-whether-my-app-is-launched-from-Qt-Creator-or-not.


Log in to reply
 

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