sugarlabs / physics

a box2d playpen
GNU General Public License v3.0
7 stars 26 forks source link

Samples fail to load #49

Closed quozl closed 1 year ago

quozl commented 4 years ago

Samples are not loaded, because PhysicsGame.opening_queue is not checked.

Workaround: move the check for opening_queue inside the event loop.

--- a/physics.py
+++ b/physics.py
@@ -109,19 +109,6 @@ class PhysicsGame:
         self.world.renderer.set_surface(self.screen)
         self.world.add.ground()

-        if self.opening_queue:
-            path = self.opening_queue.encode('ascii', 'convert')
-            if os.path.exists(path):
-                self.world.json_load(path, serialized=True)
-                if 'full_pos_list' in self.world.additional_vars:
-                    self.full_pos_list = \
-                        self.world.additional_vars['full_pos_list']
-                if 'trackinfo' in self.world.additional_vars:
-                    self.trackinfo = self.world.additional_vars['trackinfo']
-                if 'tracked_bodies' in self.world.additional_vars:
-                    self.tracked_bodies = \
-                        self.world.additional_vars['tracked_bodies']
-
         while self.running:

             # Pump GTK messages.
@@ -220,6 +207,19 @@ class PhysicsGame:
             # Stay < 30 FPS to help keep the rest of the platform responsive
             self.clock.tick(30)  # Originally 50

+            if self.opening_queue:
+                path = self.opening_queue.encode('ascii', 'convert')
+                if os.path.exists(path):
+                    self.world.json_load(path, serialized=True)
+                    if 'full_pos_list' in self.world.additional_vars:
+                        self.full_pos_list = \
+                            self.world.additional_vars['full_pos_list']
+                    if 'trackinfo' in self.world.additional_vars:
+                        self.trackinfo = self.world.additional_vars['trackinfo']
+                    if 'tracked_bodies' in self.world.additional_vars:
+                        self.tracked_bodies = \
+                            self.world.additional_vars['tracked_bodies']
+
         return False

     def setTool(self, tool):

Samples do load on v32.2 and v33.

The samples once loaded fail to operate on v34, which was first mentioned in https://github.com/sugarlabs/physics/issues/27.