Segfault using modal dialogs in QPlugin



  • Hello everyone,

    I create this thread since nobody's answering on :
    http://qt-project.org/forums/viewthread/7344/

    Which is not a thread that I own (and is almost 2 years old).

    My problem is that whenever I call a modal dialog on a re-loaded QPlugin using QWidgets (if I remove the usage everythings works), I get a segfault from the modal dialog at :
    qapplication.cpp : l. 4562
    @ // deliver the event
    bool consumed = receiver->event(e);@

    I created a small testing program that uses two plugins. I can send it by email or on an online storage if someone wants to.
    Here are the relevants functions :
    mainapplication.cpp
    @void MainWindow::pluginInteract(QString pluginPath)
    {
    InterfaceExample *plugin;
    static QPluginLoader *loader;
    static QPluginLoader *oldloader;

    // Allow plugin reloading
    if (loader) {
    if (oldloader) {
    oldloader->unload();
    delete oldloader;
    }
    }

    loader = new QPluginLoader(pluginPath);
    if (loader) {
    if (loader->instance()) {
    plugin = qobject_cast<InterfaceExample *>(loader->instance());
    if (plugin) {
    // Where everything happens
    plugin->doSomething();
    oldloader = loader;
    }
    }
    }
    }

    void MainWindow::on_b_Action_clicked()
    {
    // Always works... on first time
    pluginInteract("../../Plugin1/dll/examplePlugin1.dll");
    // Segfault if this one is using a modal dialog
    pluginInteract("../../Plugin2/dll/examplePlugin2.dll");
    }@

    plugin1.cpp
    @Plugin1::Plugin1()
    {
    Plugin1Widget *gui_plugin = new Plugin1Widget();
    connect(this, SIGNAL(send_right()), gui_plugin, SLOT(do_right()));
    }

    void Plugin1::doSomething()
    {
    doSomethingRight();
    }

    void Plugin1::doSomethingRight()
    {
    emit send_right();
    }

    Q_EXPORT_PLUGIN2(PluginExample, Plugin1)@

    pluginwidget1.cpp
    @void Plugin1Widget::do_right()
    {
    // Nothing !
    QMessageBox::information(this, "Here is first plugin",
    "First plugin does nothing !");
    }@

    Same things on the plugin2widget.cpp:
    @void Plugin2Widget::do_wrong()
    {
    // Uncomment to unleash the fury and segfault every time
    // QFileDialog::getOpenFileName(this,
    // "Please choose a file",
    // qApp->applicationDirPath(),
    // "*");
    }@

    So at first I thought it was the call to QFileDialog::getOpenFileName that created the segfault, but now I know that it's the same for all modal dialogs so, did I miss something ? Did I do something wrong ? Or did I find a bug ?

    I use Qt4.8.4 on W7x64.

    Thanks in advance !



  • If no one can help with this issue, shall I report a bug on the tracker and then see what happens ?



  • Posted on the Qt bug tracker here :
    https://bugreports.qt-project.org/browse/QTBUG-30431



  • Hello again, I need some help.
    The bug I reported has been accepted but I'm not really optimistic about it being corrected in the few months I have left for my project.

    So I was wondering how to correct this (mis-)behaviour.

    I had the idea to put signals from the QPlugin to inform my application to display the dialog boxes.
    Do any of you have a better idea ?

    EDIT UPDATE : if someone is reading, deplacing the call from the QPlugin to the main app doesn't solve anything...
    Which means that when switching QPlugins, modal dialogs don't work anymore.


Log in to reply
 

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