![]() |
Qt: QInputDialog and QMessageBox crash the application
This is a sample code from the application I'm currently working on.
The strings and the variable names are changed to make this sample more understandable. (In fact, I'm working on an EVE Online API client, and this is the code which asks the user for his/her User ID and API key.) Code:
if (QMessageBox::Yes == QMessageBox::question(this, "Do you agree?", "Terms of use", QMessageBox::Yes, QMessageBox::No))I compiled it with MADDE's Qt Creator integration. (The Qt version is 4.5.3, which is the default in PR 1.1.1.) When the application reaches this code block and displays the message box and then the input dialogs, it randomly crashes when I click on one of their buttons. There are no operations in the background, and nothing that would affect it. At least 1 out of 5 times, it crashes either on clicking on the "Yes", or clicking on the "Done" of the first input dialog. It has never crashed on the second input dialog, though. I tried to change getInt() to getString(), and then converting the result to int, but the dialog also crashed then, too. (Also about 1 of 5 times.) It seems that changing the MessageBox so that it only has a "Done" button makes it not crash, but then the first input dialog also crashes sometimes. I think I may be doing something wrong here, but I can't find any specific reason for this behaviour. Could anyone be so kind as to help me with that? |
Re: Qt: QInputDialog and QMessageBox crash the application
Must be that 4.5.3 Qt as with 4.6.2 it works fine. Also could be your waitDialog or connector.
|
Re: Qt: QInputDialog and QMessageBox crash the application
I reckon it will help if you can paste more of your source code here ( how exactly connector and waitDialog is defined and used etc and any other relevant parts.
what you have pasted seems ok to me, perhaps the core happens elsewhere. |
Re: Qt: QInputDialog and QMessageBox crash the application
Okay.
The application will have a GPL (or EU-PL, haven't decided yet) license, so I uploaded the whole source code to this location. It is a Qt Creator project file, which I run on the device using MADDE. It might not be perfect yet, but take into account that this is my first real Qt application. :) (And there are really too much TODOs in there.) I also uploaded a 2 minutes long video file on which you can see the issue. It's here. It's a little blurry, but you can see what I'm talking about. It simply crashes at pressing "Yes" on the message box, or pressing "Done" on the first input dialog. It seems that the second input dialog never crashes, however. On the video I managed to press the buttons without issue a few times, but sometimes the whole application just crashes for no reason when pressing them. (And LOL, I accidentally clicked the Weather widget several times after it had crashed...) The error occours in the MainWindow::addCharacter() method in the mainwindow.cpp. However, I doubt that the connector or the waitDialog could be the issue, because it is also present when I comment them out. |
Re: Qt: QInputDialog and QMessageBox crash the application
I forgot to mention: there are other oddities with the app, as well. For example, #if defined(Q_WS_MAEMO_5) doesn't work, and if I release the QNetworkReply* when I finished using it, the application crashes.
(These are commented in the souce code, if someone cares to look at it.) |
Re: Qt: QInputDialog and QMessageBox crash the application
Not sure but i think Q_WS_MAEMO_5 came in 4.6 and 4.5 has Q_WS_HILDON.
Still cant see reason why QMessageBox::question() would crash it. Does it crash in windows too? Maybe you could try debugging it with debugger to see what call crashes it? |
Re: Qt: QInputDialog and QMessageBox crash the application
The debbugger doesn't work with Qt Creator and MADDE.
(Breakpoints don't work also.) |
Re: Qt: QInputDialog and QMessageBox crash the application
Ive had a quick look at your code, and i couldnt figure out anything inapprorpiate immediately. WIll try to have a closer look.
If you have time at hand now, why not comment each of those 3 Dialogs one by one and localize it. comment out this as well in MainWindow::addCharacter(), since you said it occurs even without them. // This is to prevent Maemo bug #9883 appMenu->setEnabled(false); waitDialog->show(); connector->requestAccount(userId, apiKey); |
Re: Qt: QInputDialog and QMessageBox crash the application
Quote:
|
Re: Qt: QInputDialog and QMessageBox crash the application
1 Attachment(s)
Quote:
No matter, I now use the following: Code:
#if defined(Q_WS_MAEMO_5) || defined(Q_WS_HILDON)Quote:
Did you watch the video recording? Do the crashes happen on your device also, or is it only the fault of my device? Quote:
After some testing and trying to localize the issue, it seems that QMessageBox doesn't crash by itself, however QInputDialog crashes gladly. After some trying, the debugger actually worked, and it said that a segmentation fault has occoured. (I attached a zipped screenshot about it.) It seems that the error is in Qt's code, not mine. Can I do anything about it? The question is, why aren't any of the errors caught by the try-catch block in main() ? Quote:
I didn't know about deleteLater(), the tutorial I saw used the delete operator. (And it didn't crash the sample application which I made to test how it works.) Big thanks again to all of you! |
| All times are GMT. The time now is 03:22. |
vBulletin® Version 3.8.8