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 in closeEvent()
Forum Updated to NodeBB v4.3 + New Features

Crash in closeEvent()

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 1 Posters 392 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.
  • deisikD Offline
    deisikD Offline
    deisik
    wrote on last edited by deisik
    #1

    If I choose to ignore event in closeEvent() in QMainWindow, application crashes within a few seconds after clicking [x]

    main.cpp:

    #include "main_window.h"
    
    #include <QApplication>
    
    int main(int argc, char *argv[])
    {
        QApplication a(argc, argv);
        MainWindow w;
        w.show();
        return a.exec();
    }
    

    main_window.h:

    #ifndef MAINWINDOW_H
    #define MAINWINDOW_H
    
    #include <QMainWindow>
    #include <QCloseEvent>
    
    class MainWindow : public QMainWindow {
        Q_OBJECT
    
    public:
        MainWindow(QWidget *parent = nullptr);
    protected slots:
        void closeEvent(QCloseEvent*);
    };
    
    #endif // MAINWINDOW_H
    

    main_window.cpp

    #include "main_window.h"
    
    void MainWindow::closeEvent(QCloseEvent *event) {
        event->ignore();
    }
    
    MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) {
    }
    

    Call stack:

    1 poll 0x7ffff638699f
    2 ?? 0x7ffff5fd28ce
    3 g_main_context_iteration 0x7ffff5fd29ef
    4 QEventDispatcherGlib::processEvents qeventdispatcher_glib.cpp 393 0x7ffff6c59b3a
    5 QEventLoop::exec qflags.h 108 0x7ffff69bdd5b
    6 QCoreApplication::exec qflags.h 74 0x7ffff69ba13e
    7 main main.cpp 10 0x55555555724f

    Feels like the crash doesn't have anything to do with Qt (broken glibc?)

    1 Reply Last reply
    0
    • deisikD Offline
      deisikD Offline
      deisik
      wrote on last edited by deisik
      #2

      I updated glibc along with a few x11 libraries and after rebooting the problem is gone, although not sure if simple rebooting wouldn't do the trick (was up for a couple of months)

      deisikD 1 Reply Last reply
      0
      • deisikD deisik

        I updated glibc along with a few x11 libraries and after rebooting the problem is gone, although not sure if simple rebooting wouldn't do the trick (was up for a couple of months)

        deisikD Offline
        deisikD Offline
        deisik
        wrote on last edited by deisik
        #3

        It turned it out to be a system-wide issue after an uptime of couple months or so. Any program (for example, Firefox) would be forcefully closed after a few seconds if it showed a warning dialog box on exit

        1 Reply Last reply
        1

        • Login

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