Browse Source

dgui: show assertion when passing a NaN into DirectSlider

If we don't do this, we get an assertion somewhere in the bowels of the scene graph, which will be much less helpful for tracking down the origin of the NaN.
rdb 6 years ago
parent
commit
6b12fbe6f2
1 changed files with 5 additions and 1 deletions
  1. 5 1
      direct/src/gui/DirectSlider.py

+ 5 - 1
direct/src/gui/DirectSlider.py

@@ -10,6 +10,7 @@ from panda3d.core import *
 from . import DirectGuiGlobals as DGG
 from .DirectFrame import *
 from .DirectButton import *
+from math import isfinite
 
 """
 import DirectSlider
@@ -89,12 +90,15 @@ class DirectSlider(DirectFrame):
     def __setValue(self):
         # This is the internal function that is called when
         # self['value'] is directly assigned.
-        self.guiItem.setValue(self['value'])
+        value = self['value']
+        assert isfinite(value)
+        self.guiItem.setValue(value)
 
     def setValue(self, value):
         # This is the public function that is meant to be called by a
         # user that doesn't like to use (or doesn't understand) the
         # preferred interface of self['value'].
+        assert isfinite(value)
         self['value'] = value
 
     def getValue(self):