My app crashes when trying to quit
-
Hi, my app used to close properly but a few days back it started to crash when trying to quit.
I can't find where's the mistake.
Everything is OK until I call qApp->quit() (It happens also with QApplication::quit() and exit(1)).
Here's what I see in my app Output:2022-12-15 16:38:29.252285-0300 ProyectoPola[49557:596442] [qt.core.library] "/Users/santiagocarlos/Qt/6.4.1/macos/plugins/imageformats/libqgif.dylib" unloaded library (faked) ProyectoPola(49557,0x100307dc0) malloc: *** error for object 0x101c07310: pointer being freed was not allocated ProyectoPola(49557,0x100307dc0) malloc: *** set a breakpoint in malloc_error_break to debug Detected Qt Version: 0x60401 (namespace='no namespace') Found function QObject::property: 0x1012372e0 Found function QObject::customEvent: 0x10122f120
When the crash happens, this is the first function that I see in the debugger that has a problem. It's in the qarraydata.h file, in the following function:
static void deallocate(QArrayData *data) noexcept { static_assert(sizeof(QTypedArrayData) == sizeof(QArrayData)); QArrayData::deallocate(data, sizeof(T), alignof(AlignmentDummy)); }
All of this happens when I try to quit the app in my MainWindow. Here's the code for reference:
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) , ui(new Ui::MainWindow) { ui->setupUi(this); // Carga de logos. QPixmap logoBio(":/images/Resources/logobiotandil.png"); ui->logoBio->setPixmap(logoBio); QPixmap nombreBio(":/images/Resources/logobiotandil2.png"); ui->nombreBio->setPixmap(nombreBio); QPixmap nombreRed(":/images/Resources/redimecfondo.png"); ui->redimec->setPixmap(nombreRed); // Cargo pantallas // Set connection to database /* db = QSqlDatabase::addDatabase("QMARIADB"); db.setHostName("200.41.196.243"); db.setPort(3307); db.setDatabaseName("polarimetro"); db.setUserName("polarimetrolbt"); db.setPassword("polarimetrolbt"); qDebug() << "db connection on menu: " << db.open();*/ } void MainWindow::on_offButton_clicked() { qApp->quit(); } void MainWindow::on_onButton_clicked() { Menu* menuEnsayos = new Menu(this); ui->stackedWidget->addWidget(menuEnsayos); ui->stackedWidget->setCurrentWidget(menuEnsayos); } MainWindow::~MainWindow() { delete ui; }
I run the app and immediately push the "off button". I do not press the "on button" at all.
Can anyone help me, please?
Thanks in advance. -
Right now, I don't. I remember having that kind of stuff happening from time to time on Windows. I would just nuked the build folder and start fresh.
-
Hi,
Which version of macOS are you using ?
Which version of Xcode are you using ?
Does it also happen if you implement that in a default application ? -
@SGaist Hi! I'm using MacOS Catalina 10.15.7 and the command line tools version 12.0.
It's very weird, I just duplicated the project and run the app again, and works again. It might been a bug in the build folder, or something like that.
Do you know what could throw that kind of error?
-
Right now, I don't. I remember having that kind of stuff happening from time to time on Windows. I would just nuked the build folder and start fresh.