Crash on quit on default project



  • Hello,

    My application crashes on quit after the return in the main.
    My first guess was an issue with memory allocation but since the project was basic QT one created from VS2015 I did not allocate anything new. There is only one delete in my main window and the delete is :

    delete ui;
    

    It crashes after the return in the main and the debugger just tells me that there is an access violation in the main thread.
    I am not sure what could cause that issue, is it coming from somewhere else ?

    #include "MainWindow.h"
    #include <QtWidgets/QApplication>
    
    int main(int argc, char *argv[])
    {
    	QApplication a(argc, argv);
    	MainWindow w;
    	w.show();
    	return a.exec();
    }
    
    #include "mainwindow.h"
    #include "ui_mainwindow.h"
    
    MainWindow::MainWindow(QWidget *parent) :
        QMainWindow(parent),
        ui(new Ui::MainWindow)
    {
            ui->setupUi(this);
    	this->setCentralWidget(ui->vwMain);
    }
    
    MainWindow::~MainWindow()
    {
        delete ui;
    }
    


  • any reason you r doing this->setCentralWidget(ui->vwMain); ? mwMain is from ui object which is initialised with ui.setupUI ?



  • @dheerendra
    That was me thinking for one second that the main layout was maybe not a child of the window and that he didn't get deleted.
    I just removed the line but it didn't change anything.



  • This kind of issue arises intermittently since some stray cases objects were tried deleting twice. inside main.cpp can you try the following ?

    MainWindow *w = new MainWindow;
    w->show();
       delete w;
    

    Off course this will not show anything as w object is deleted immediately. Now do you hit the problem ?



  • @dheerendra I get an error as I start the program.

    ASSERT: "!receiver->d_func()->postedEvents" in file kernel\qcoreapplication.cpp,
     line 1714
    Press any key to continue . . .
    


  • I also tried make my ui object not a pointer.
    The application still crashes on close.


  • Qt Champions 2016

    @rXpSwiss
    Can you try with 100% clean default project ?
    That is no
    this->setCentralWidget(ui->vwMain);
    or any other stuff :)

    If that crashes, i would guess on DLL issues



  • @rXpSwiss

    what else is there in your application? Give us more info :)



  • @mrjj said in Crash on quit on default project:

    @rXpSwiss
    Can you try with 100% clean default project ?
    That is no
    this->setCentralWidget(ui->vwMain);
    or any other stuff :)

    If that crashes, i would guess on DLL issues

    I did do that too.
    So might be DLL ? Because it did work with QT Creator but not with VS2015

    @J.Hilk said in Crash on quit on default project:

    @rXpSwiss

    what else is there in your application? Give us more info :)

    Nothing, well now there is because I still had to start making it it just crashes when I close it.
    But before that there was nothing that the default code and a UI file.


Log in to reply
 

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