Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Qt 4.8.1 app crashes on exit, Qt 4.7.4 runs OK
QtWS25 Last Chance

Qt 4.8.1 app crashes on exit, Qt 4.7.4 runs OK

Scheduled Pinned Locked Moved General and Desktop
5 Posts 2 Posters 1.3k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    gibbogle
    wrote on last edited by
    #1

    I have been developing Qt applications for a few years using Qt 4.7.4 with MSVC 2005. Things have been going smoothly. Recently I needed to start transferring my code to Qt 4.8.1 using MSVC 2010. Now a program that used to run OK gives me an error message saying that it has crashed when I close it (clicking the RH 'X' button). I can reproduce the problem with a program that does nothing but setupUi(). That is:

    @
    int main(int argc, char *argv[])
    {
    QApplication app(argc, argv);
    MainWindow mainWin;
    mainWin.show();

    return app.exec();
    

    }

    MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    {
    setupUi(this);
    showMaximized();
    }
    @

    About 4 seconds after I click the close button, I get:

    "The program has unexpectedly finished.
    D:\trophocell-abm\tropho_GUI-build-Qt_4_8_1\release\tropho_GUI.exe crashed"

    The 4 second delay is interesting - what is it doing?
    I presume there is something in my .ui file that is creating a problem. How can this happen? The UI is created as I would expect, and the error occurs on exit.

    I am building and running in Qt Creator.

    Any ideas? Is it likely to be caused by a change in Qt, or a change in MSVC?

    Thanks
    Gib

    [edit: added missing coding tags @ SGaist]

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Did you try to run it through the debugger ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • G Offline
        G Offline
        gibbogle
        wrote on last edited by
        #3

        I did just install MS SDK to get access to CDB. It is not a trivial matter for me to build a debug version of this app, because it links to the VTK libraries, which I will have to build debug versions of. To clarify, in the simple test that fails much more code is built than I showed, but the error can be demonstrated when MainWindow returns without doing anything except setupUi. I did run the debugger anyway, and it told me:

        HEAP[tropho_GUI.exe]: Invalid address specified to RtlFreeHeap( 00290000, 050913E0 )

        On a guess I removed a qwtPlot widget that I have been using. This prevents the crash with the simple example. But when I run the complete program (with without that qwtPlot) it crashes on exit again (after executing correctly), with the same heap error. I surmise that this is related to other uses I make of qwtPlot widgets that are created dynamically. It is not clear to me at this stage if the problem is an incompatibility of the qwt library (5.2.1, built with MSVC 2005) with MSVC 2010, or if I am just doing something wrong. The fact that it all works with MSVC 2005 suggests an incompatibility. Perhaps I need to rebuild the qwt library with MSVC 2010. Perhaps you can suggest a way I can remove the qwtPlot widgets myself (in closeEvent()) on exit instead of leaving it to Qt to do it automatically.

        Thanks
        Gib

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          You can't mix dlls from several versions of MSVC. The rule is: everything must be compiled with the same version of Visual Studio. Their compiler are not compatible one with the other.

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • G Offline
            G Offline
            gibbogle
            wrote on last edited by
            #5

            I think that's true for static libraries but not necessarily for DLLs. I am linking to another DLL built with MSVC 2005, and I can even replace that with a DLL built with MinGW (in that case I have to take special measures to generate the .lib). In any case, I have found that my problem is solved by deleting the QwtPlot objects in closeEvent(). It's all working now.

            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved