Qt - confused on QDialog choice on main
===

I have the following Qt code:

    int main(int argc, char *argv[])
    {
        QApplication app(argc, argv);
    
        ChoosingDialog cdlg;

        if(!startWin.exec())
        {
            // nothing chosen
            return 0;
        }
    
        if(cdlg.firstWindowSelected)
        {
            CFirstWindow win;
            win.show();
    
            return app.exec();
        }
        else
        {
            CSecondWindow win;
            win.show();
    
            return app.exec();
        }
    
    }


this seems to work but it's giving me an error on "event dispatcher cleanup" in some asm line. I tried to trick a bit and I saw that the problem is related to the app.exec() calling.

How am I supposed to call app.exec() and show a QDialog (ChoosingDialog) which prompts the user to choose between two QMainWindow (CFirstWindow and CSecondWindow) ?