Important: Please read the Qt Code of Conduct -

QtWinmigrate and __fastfail on deleting Qt Quick models

  • Hi,

    I'm using qtwinmigrate with Qt 5.12.5 to display Qt Quick controls in a Win32 app.

    More specifically, I have a C interface to a dll where I host a QQmlEngine instance that renders things through QQuickWidget which I show in the client application with help of QWinWidget (which is part of the qtwinmigrate framework).

    If I don't delete model objects then there is memory leaking each time when I hide then show the widget even if I don't recreate model objects but reusing old objects from a pool instead. I suspect old QML objects to be leaking.

    Since deleteLater() doesn't work because of absence of main Qt thread executing QApplication's event loop I've googled next way to delete model objects:

    QApplication::postEvent(m_Model, new QDeferredDeleteEvent());
    Application::sendPostedEvents(0, QEvent::DeferredDelete);

    It seemed to work well, everything was working fine and no memory was leaking. Unfortunately, I've recently discovered that sometimes it results in calls to __fastfail with next message:

    Object destroyed while one of its QML signal handlers is in progress. Most likely the object was deleted synchronously (use QObject::deleteLater() instead), or the application is running a nested event loop. This behavior is NOT supported!

    Calling disconnect() on these objects prior to deleting doesn't help.

    An attempt to create a QThread in the dll, move QApplication instance to this thread and run its event loop through calling exec() on it, then call deleteLater() on model objects normally failed as well. Model objects were not being deleted in this case. I might have done something wrong though.

    Do you have any suggestions what can I do with this problem?


    I've tried to reimplement the "in-dll QThread" approach once again since I definitely did it wrong for the first time. Now everything is created and lives in that thread but I can't display the control:

    1. I see next warning from Qt:

    WARNING: QApplication was not created in the main() thread.

    1. QWinWidget's constructor hangs on next call

    And since I'm using Qt::BlockingQueuedConnection for synchronization with the main thread it hangs as well.

Log in to reply