I am working on a Qt app which runs on android & iOS.
Scenario: Calling delete on a pointer causes my app to crash sometimes gives me the following error on Android.
Fatal signal 11 (SIGSEGV), code 1, fault addr 0x3c in tid 7134 (QtThread)
This is caused due to a delete call in updatePaintNode
of my QQuickItem
derived class.
// My updatePaintNode logic relevant to this question
QSGNode * MyQQuickItem::updatePaintNode(QSGNode * oldNode, UpdatePaintNodeData * updatePaintNodeData) {
Q_UNUSED(oldNode)
Q_UNUSED(updatePaintNodeData)
if(class_mem_node != Q_NULLPTR) {
delete class_mem_node; // this is where the crash occurs
}
class_mem_node = new QSGNode;
// Execute drawing logic
return class_mem_node;
}
Problem:
Another window of my application is dependent on MyQQuickItem::updatePaintNode
to execute but sometimes on Android the call to delete class_mem_node
causes the crash with the Fatal signal
error. Interestingly, the issue only happens on android, not on iOS or OSX.
Question:
What is wrong in my logic in updatePaintNode
? Is this a thread synchronisation issue?
Is there some way I can check whether the QSGNode
is in use & return out?