I am making a free 2D game, using QGraphicsScene and QGraphicsView (and a number of other components such as QSound and QMovie). Even the main menu is stored in a scene (enabling custom graphics for the menu). So the scene, the view, and the associated layout that displays the view widget are all stored in member variables (in the main widget class of the application). When the player starts a new game, the main menu scene and view is replaced by the first game map and its content. Similarly, when the first map is finished, a new QGraphicsScene and view is instantiated for the second map (and stored in the same member variables for scene and view).
Before adding the new scene, layout and view, it is required to free the current versions (or there would be memory leak, obviously), so I made a clean function for it:
It does not seem to work, it changes the widget to an "empty" one with default background color (on E52, light blue).
On the other hand, this works perfectly:
How is this possible? Some deadlock?