12-18-2013 09:08 AM
I've got this crash but i can't figure out why. The debugger doesn't help much:
Thread  (STOPPED) (Suspended : Signal : SIGSEGVegmentation fault)
The setVisible is called on a Label * object that is allocated in the constructor of the class that owns this field. The method where the crash happens is a slot method. The slot method is called by a connection with a specific class signal. The strange thing is that the first time that the signal is emitted and the slot method is called there are no crash at all. However the second time that the method is called the method crash on the first line where the setVisible take place.
The first time the function is called from a slot method of class ClassA and the second time from slot method of class ClassB. Both of these classes have the same reference to the object of class MyClass.
I know that graphic object cannot be updated from an external thread but here I call only the emit from a perhaps different thread.
Any help is appreciated.
Solved! Go to Solution.
12-18-2013 09:11 AM - edited 12-18-2013 09:13 AM
12-18-2013 09:21 AM - edited 12-18-2013 09:22 AM
This is the initialization:
MyLabel = new Label(); MyLabel->setHorizontalAlignment(HorizontalAlignmen
t::Fill); MyLabel->setVerticalAlignment(VerticalAlignment::F ill); MyLabel->textStyle()->setColor(Color::White); MyLabel->setText("Tentativi disponibili: X"); MyLabel->setVisible(false);
I forgot to say that there is another slot method that set the lable to visible before I call the update() method:
So i call update2() to show the label and then i set update() to hide the label. I do that to avoid the recreation of the whole Container object every time but i guess that this could be a workaround.
12-18-2013 09:30 AM
12-19-2013 11:18 AM - edited 12-19-2013 11:22 AM
I'm sorry I can't post the code because my company doesn't allow me to do that.
I checked the Variable with the debug visual of Momentics and and It seem to be NULL.
That's a very strange because I can see in front of me the Label and indeed the variable it's allocated in the constructor. It seems like to be freed or somithing like that.
The problem seems to be related the path: setVisible(false) - setVisible(true) - setVisible(false).
Can I do more then 2 switch from true to false and vice-versa ?
I add the component to the container but I set the Visibility to false. Then I show up the label and when some operations are finished I try to hide the label but it fail becouse of the NULL pointer.
Is an object freed when setVisible(false) is called ?
12-19-2013 11:30 AM
12-19-2013 11:32 AM
01-10-2014 02:04 PM
The variable was actually NULL but because another instance of the class MyClass was wrongly called using a different flow and the variable was wrongly unitialized.
I found another issue with a wrong usage of app->setScene method. I now use this method only on the first page of the app an the page switch is made using a NavigationPane rather than setting the new Page.
app->setScene(Page) //Only on the first page
app->setScene(NavigationPane) //On the next pages
I have wrongly used the setScene method to switch to a page then switching to another an then switching back to the first page. I read in the documentation that the setScene method destroy the previus graphical object, this is why I started using the NavigationPane more precisely:
...If the replaced scene (if one was set) is owned by the Application it will be deleted...
I think this mean that the memory is freed and the Page is no longer available to rendering.