Solved App crash on emitting signal
-
@TagLog said in App crash on emitting signal:
on_taskChanged
What does on_taskChange do? Did you try to use debugger to go step by step through it to see where exactly it crashes and why?
-
Hi,
check the return status of connect statement.
and check logs in slot() and function where ur emmitting signal();Thanks,
-
on_taskChanged() slot must be culprit here. You can focus on the code inside the slot. You can use debugger to look at the issue as @jslum already suggested.
-
@jsulm It call another function called updateWindow(), but that function is also called by other buttons and stuff, so the problem is in the connection/signal/slot
-
Hi,
Please post the stack trace of your crash, that should help pinpoint the problem.
-
This is the stack trace (as a newbie, I think the problem could be in thread 1, the last one in the stack trace), in a breakpoint the debugger says this message: Disassembler failed: Cannot access memory at address 0x6a85097c, the function is unknown (??)
-
@TagLog
Can you show the content of following methods:- MainWindow::updateTree
- MainWindow::updateWindow
- MainWindow::on_taskChanged
?
-
@jsulm
Here you go:void MainWindow::on_taskChanged(){ updateWindow(); }
void MainWindow::updateWindow() { currentScene->clear(); for (unsigned i = 0; i < 12; i ++){ childrenScenes[i]->clear(); } ui->btnModify->setEnabled(true); ui->btnComplete->setEnabled(true); ui->btnAddChild->setEnabled(true); ui->lblProjectTitle->setText(currentProj.getTitle()); ui->lblCurrentTitle->setText(currentTask->getTitle()); ui->tedCurrentText->setText(currentTask->getText()); currentTask->drawAsCurrent(currentScene); for(unsigned i = 0; i < 12 && i < currentTask->getChildren().size(); i++){ childrenScenes[i]->setTaskShown(currentTask->getChildren()[i] ); childrenScenes[i]->drawTaskShown(); } updateTree(); }
void MainWindow::updateTree(){ QString TaskTree; Task* masterPointer = currentTask; while(masterPointer != Q_NULLPTR){ TaskTree = "/" + masterPointer->getTitle() + TaskTree; masterPointer = currentTask->getMaster(); } ui->lblDepTree->setText(TaskTree); }
I'm willing for any explanation if you need
-
First suspects are the following:
for (unsigned i = 0; i < 12; i ++){ childrenScenes[i]->clear(); }
and
for(unsigned i = 0; i < 12 && i < currentTask->getChildren().size(); i++){ childrenScenes[i]->setTaskShown(currentTask->getChildren()[i] ); childrenScenes[i]->drawTaskShown(); }
Are you confident thay you remain in bounds here? for both containers (currentTask->getChildren() and childrenScenes)?
EDIT: also, what is
currentTask
? Is it set properly?
-
If you make assumptions in your code, assert them (even static assert them if you can)
- is
currentTask
null? - is
currentScene
null? - is
childrenScenes
of size >=12 - is any
childrenScenes[i]
null
The easiest way to debug this is put a breakpoint at the first line of
on_taskChanged
and step into/over every line untill you find exactly where it explodes and fix whatever is wrong there - is
-
@BjornW In this test case I remain in bounds in those lines of code.
currentTask is a pointer to a custom class object which is initialized at the beginnning of the test.
-
@VRonin said in App crash on emitting signal:
The easiest way to debug this is put a breakpoint at the first line of on_taskChanged and step into/over every line untill you find exactly where it explodes and fix whatever is wrong there
-
@VRonin I'm doing this right now, as soon as I finish I'll tell you what I found
Edit: I can't find anything now, but for few days I can't look at the code, I'll continue to look ASAP
-
I finally found what caused crashes: it was the UpdateTree function. I wrote a wrong line which caused an infinite loop. I'm feeling both stupid and happy :) / :(