Solved My program start to crash because of MessageBox
-
@mrjj said in My program start to crash because of MessageBox:
Just start the app in debug mode. And then make it crash.
It should show in call stack what it was doing before it died.It shows numerous windows like this:
What is all mean?
@J.Hilk said in My program start to crash because of MessageBox:
also do you call processEvents() somewhre inside your code?
No
-
@Engelard said in My program start to crash because of MessageBox:
It shows numerous windows like this:
These are uninteresting.
We need the call stack (also called stack trace, or backtrace)
-
Hi
the call stack / trace it looks like this
-
-
@Engelard
and that is from it crashes ? -
@mrjj If i comment out my line
QMessageBox::information(nullptr, "ERROR", "trtrtr");
Debugger will be absolutely empty. When i use this static function of messBox, it give me such output.
-
Hey i just found that it work well if i put it in the constructor, so it crashes only when it in my other functions, strange.
UPDATE:
Here is info for everyone. Yesterday, i noticed that the app not just crashed, it crashed like.. twice, and all my app mostly about the use of "pressed" and "released" SLOTs of the buttons. I removed usage of release slot, and now app do just single crash. Here is how "release button" chain looks like:
void MainWindow::on_button_Q_released() { //lightRestore(currentButton); }
And here is that only function which it use:
void MainWindow::lightRestore(QPushButton *lamp) { lamp->setStyleSheet("QPushButton{color: white;background-color: rgb(35,35,35);border-style: outset;border-width: 2px;border-radius: 15px;border-color: black;font: bold 12px;}"); }
-
Hi, if I read the trace correctly, the user presses the button_G, that functions calls mainJourney() which issues the QMessageBox() call.
Could you show the code for mainJourney()? -
@Engelard said in My program start to crash because of MessageBox:
currentButton
seems like currentButton is no longer a valid QPushButton-Pointer,
If you have a pointer member variable, you should make sure that you always set it to a nullptr when the pointed to object is destroyed/invalid.
And always check against that before accessing it:void MainWindow::lightRestore(QPushButton *lamp) { if(lamp) lamp->setStyleSheet(...); }
-
@hskoglund said in My program start to crash because of MessageBox:
Could you show the code for mainJourney()?
No, that stuff is too big, it called from pressButton SLOT, above much simplier and compact example of release, it does the same crash.
-
@J.Hilk nice advice, tnx. But it valid(without that messageBox stuff everything works perfectly), i added if-check line. Nothing it changed(2nd crash exist).
UPDATE:
If i put messageBox AFTER assignment of that button - will be no crashes, but also it is not possible to hold the button(because this messageBox take over priority and it is now main waindow).
void MainWindow::on_button_Q_pressed() { currentButton = mainJourney('Q'); lightSet(currentButton); QMessageBox::information(nullptr, "ERROR", "trtrtr"); }
-