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. Crash on quit on default project
Forum Updated to NodeBB v4.3 + New Features

Crash on quit on default project

Scheduled Pinned Locked Moved Unsolved General and Desktop
9 Posts 4 Posters 2.0k Views 1 Watching
  • 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.
  • R Offline
    R Offline
    rXpSwiss
    wrote on last edited by
    #1

    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;
    }
    
    1 Reply Last reply
    0
    • dheerendraD Offline
      dheerendraD Offline
      dheerendra
      Qt Champions 2022
      wrote on last edited by
      #2

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

      Dheerendra
      @Community Service
      Certified Qt Specialist
      http://www.pthinks.com

      R 1 Reply Last reply
      6
      • dheerendraD dheerendra

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

        R Offline
        R Offline
        rXpSwiss
        wrote on last edited by
        #3

        @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.

        1 Reply Last reply
        0
        • dheerendraD Offline
          dheerendraD Offline
          dheerendra
          Qt Champions 2022
          wrote on last edited by dheerendra
          #4

          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
          @Community Service
          Certified Qt Specialist
          http://www.pthinks.com

          R 1 Reply Last reply
          7
          • dheerendraD dheerendra

            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 ?

            R Offline
            R Offline
            rXpSwiss
            wrote on last edited by
            #5

            @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 . . .
            
            1 Reply Last reply
            0
            • R Offline
              R Offline
              rXpSwiss
              wrote on last edited by
              #6

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

              mrjjM J.HilkJ 2 Replies Last reply
              0
              • R rXpSwiss

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

                mrjjM Offline
                mrjjM Offline
                mrjj
                Lifetime Qt Champion
                wrote on last edited by
                #7

                @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

                R 1 Reply Last reply
                0
                • R rXpSwiss

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

                  J.HilkJ Offline
                  J.HilkJ Offline
                  J.Hilk
                  Moderators
                  wrote on last edited by
                  #8

                  @rXpSwiss

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


                  Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


                  Q: What's that?
                  A: It's blue light.
                  Q: What does it do?
                  A: It turns blue.

                  1 Reply Last reply
                  0
                  • mrjjM mrjj

                    @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

                    R Offline
                    R Offline
                    rXpSwiss
                    wrote on last edited by
                    #9

                    @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.

                    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