From d3494edf2c325093e136d7b33382fcfa192fc2e7 Mon Sep 17 00:00:00 2001 From: rdb Date: Sat, 31 Oct 2015 04:11:12 +0100 Subject: [PATCH 1/3] Address some rare crashes at shutdown --- direct/src/showbase/ShowBase.py | 3 ++- panda/src/display/graphicsEngine.cxx | 6 ++---- panda/src/putil/bamCache.I | 26 ++++++++++++++++++++++++++ panda/src/putil/bamCache.h | 2 ++ 4 files changed, 32 insertions(+), 5 deletions(-) diff --git a/direct/src/showbase/ShowBase.py b/direct/src/showbase/ShowBase.py index 6c6c68d4a8..9e4f7a9296 100644 --- a/direct/src/showbase/ShowBase.py +++ b/direct/src/showbase/ShowBase.py @@ -296,7 +296,6 @@ class ShowBase(DirectObject.DirectObject): self.physicsMgrEnabled = 0 self.physicsMgrAngular = 0 - self.createBaseAudioManagers() self.createStats() self.AppHasAudioFocus = 1 @@ -384,6 +383,8 @@ class ShowBase(DirectObject.DirectObject): else: ShowBase.notify.info('__dev__ == %s' % __dev__) + self.createBaseAudioManagers() + # set up recording of Functor creation stacks in __dev__ PythonUtil.recordFunctorCreationStacks() diff --git a/panda/src/display/graphicsEngine.cxx b/panda/src/display/graphicsEngine.cxx index 22b2b876f8..5d3c109c46 100644 --- a/panda/src/display/graphicsEngine.cxx +++ b/panda/src/display/graphicsEngine.cxx @@ -630,8 +630,7 @@ remove_all_windows() { // a hack, since it's not really related to removing windows, this // would nevertheless be a fine time to ensure the model cache (if // any) has been flushed to disk. - BamCache *cache = BamCache::get_global_ptr(); - cache->flush_index(); + BamCache::flush_global_index(); // And, hey, let's stop the vertex paging threads, if any. VertexDataPage::stop_threads(); @@ -716,8 +715,7 @@ render_frame() { // Since this gets called every frame, we should take advantage of // the opportunity to flush the cache if necessary. - BamCache *cache = BamCache::get_global_ptr(); - cache->consider_flush_index(); + BamCache::consider_flush_global_index(); // Anything that happens outside of GraphicsEngine::render_frame() // is deemed to be App. diff --git a/panda/src/putil/bamCache.I b/panda/src/putil/bamCache.I index 3d2906e36c..9527bd0a83 100644 --- a/panda/src/putil/bamCache.I +++ b/panda/src/putil/bamCache.I @@ -257,6 +257,32 @@ get_global_ptr() { return _global_ptr; } +//////////////////////////////////////////////////////////////////// +// Function: BamCache::consider_flush_global_index +// Access: Published, Static +// Description: If there is a global BamCache object, calls +// consider_flush_index() on it. +//////////////////////////////////////////////////////////////////// +INLINE void BamCache:: +consider_flush_global_index() { + if (_global_ptr != (BamCache *)NULL) { + _global_ptr->consider_flush_index(); + } +} + +//////////////////////////////////////////////////////////////////// +// Function: BamCache::flush_global_index +// Access: Published, Static +// Description: If there is a global BamCache object, calls +// flush_index() on it. +//////////////////////////////////////////////////////////////////// +INLINE void BamCache:: +flush_global_index() { + if (_global_ptr != (BamCache *)NULL) { + _global_ptr->flush_index(); + } +} + //////////////////////////////////////////////////////////////////// // Function: BamCache::mark_index_stale // Access: Private diff --git a/panda/src/putil/bamCache.h b/panda/src/putil/bamCache.h index beab547935..f0615111a1 100644 --- a/panda/src/putil/bamCache.h +++ b/panda/src/putil/bamCache.h @@ -83,6 +83,8 @@ PUBLISHED: void list_index(ostream &out, int indent_level = 0) const; INLINE static BamCache *get_global_ptr(); + INLINE static void consider_flush_global_index(); + INLINE static void flush_global_index(); private: void read_index(); From 63a9b5dfeca34d0ad06783958bfc98fddc64f1eb Mon Sep 17 00:00:00 2001 From: rdb Date: Sun, 1 Nov 2015 15:45:52 +0100 Subject: [PATCH 2/3] Re-expose MouseWatcherGroup; clearer error message for make_seq when getter is not exposed --- dtool/src/interrogate/interfaceMakerPythonNative.cxx | 2 +- panda/src/tform/mouseWatcherBase.cxx | 2 +- panda/src/tform/mouseWatcherGroup.h | 8 ++++++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/dtool/src/interrogate/interfaceMakerPythonNative.cxx b/dtool/src/interrogate/interfaceMakerPythonNative.cxx index 5a2dd24e41..1d5520470c 100644 --- a/dtool/src/interrogate/interfaceMakerPythonNative.cxx +++ b/dtool/src/interrogate/interfaceMakerPythonNative.cxx @@ -6121,7 +6121,7 @@ write_make_seq(ostream &out, Object *obj, const std::string &ClassName, << "\n" << " PyObject *getter = PyDict_GetItemString(Dtool_" << ClassName << "._PyType.tp_dict, \"" << element_name << "\");\n" << " if (getter == (PyObject *)NULL) {\n" - << " return NULL;\n" + << " return Dtool_Raise_AttributeError(self, \"" << element_name << "\");\n" << " }\n" << "\n" << " Py_ssize_t count = (Py_ssize_t)local_this->" << make_seq->_num_name << "();\n" diff --git a/panda/src/tform/mouseWatcherBase.cxx b/panda/src/tform/mouseWatcherBase.cxx index 6a5a92aa4c..559508029d 100644 --- a/panda/src/tform/mouseWatcherBase.cxx +++ b/panda/src/tform/mouseWatcherBase.cxx @@ -218,7 +218,7 @@ get_region(int n) const { //////////////////////////////////////////////////////////////////// void MouseWatcherBase:: output(ostream &out) const { - out << "MouseWatcherBase (" << _regions.size() << " regions)"; + out << "MouseWatcherGroup (" << _regions.size() << " regions)"; } //////////////////////////////////////////////////////////////////// diff --git a/panda/src/tform/mouseWatcherGroup.h b/panda/src/tform/mouseWatcherGroup.h index d07994581d..bab2b497e1 100644 --- a/panda/src/tform/mouseWatcherGroup.h +++ b/panda/src/tform/mouseWatcherGroup.h @@ -31,13 +31,17 @@ class EXPCL_PANDA_TFORM MouseWatcherGroup : public MouseWatcherBase, public: INLINE MouseWatcherGroup() {}; -public: +PUBLISHED: static TypeHandle get_class_type() { - ReferenceCount::init_type(); return _type_handle; } + +public: static void init_type() { + MouseWatcherBase::init_type(); + ReferenceCount::init_type(); register_type(_type_handle, "MouseWatcherGroup", + MouseWatcherBase::get_class_type(), ReferenceCount::get_class_type()); } From b1c7086cbc0d810a142d0b1a4ed8772a9dd843c4 Mon Sep 17 00:00:00 2001 From: rdb Date: Sun, 1 Nov 2015 15:53:02 +0100 Subject: [PATCH 3/3] Fix Rope, fix some unnecessary reliances on base.config --- direct/src/actor/Actor.py | 10 ++++++---- direct/src/showbase/PythonUtil.py | 2 +- direct/src/showbase/ShowBase.py | 6 ++++-- direct/src/showbase/Transitions.py | 2 +- direct/src/showutil/Rope.py | 6 +++++- 5 files changed, 17 insertions(+), 9 deletions(-) diff --git a/direct/src/actor/Actor.py b/direct/src/actor/Actor.py index 7802ebc3eb..d5fcaa8ee4 100644 --- a/direct/src/actor/Actor.py +++ b/direct/src/actor/Actor.py @@ -24,6 +24,8 @@ class Actor(DirectObject, NodePath): LoaderOptions.LFConvertAnim) validateSubparts = ConfigVariableBool('validate-subparts', True) + mergeLODBundles = ConfigVariableBool('merge-lod-bundles', True) + allowAsyncBind = ConfigVariableBool('allow-async-bind', True) class PartDef: @@ -171,10 +173,10 @@ class Actor(DirectObject, NodePath): # ['common']; when it is false, __animControlDict has one key # per each LOD name. - if mergeLODBundles == None: + if mergeLODBundles is None: # If this isn't specified, it comes from the Config.prc # file. - self.mergeLODBundles = base.config.GetBool('merge-lod-bundles', True) + self.mergeLODBundles = Actor.mergeLODBundles.getValue() else: self.mergeLODBundles = mergeLODBundles @@ -182,8 +184,8 @@ class Actor(DirectObject, NodePath): # asynchronous animation binding. This requires that you have # run "egg-optchar -preload" on your animation and models to # generate the appropriate AnimPreloadTable. - if allowAsyncBind == None: - self.allowAsyncBind = base.config.GetBool('allow-async-bind', True) + if allowAsyncBind is None: + self.allowAsyncBind = Actor.allowAsyncBind.getValue() else: self.allowAsyncBind = allowAsyncBind diff --git a/direct/src/showbase/PythonUtil.py b/direct/src/showbase/PythonUtil.py index 8d20e1683d..ccd4de8800 100644 --- a/direct/src/showbase/PythonUtil.py +++ b/direct/src/showbase/PythonUtil.py @@ -1995,7 +1995,7 @@ def pstatcollect(scope, level = None): try: - if not (__dev__ or config.GetBool('force-pstatcollect', 0)) or \ + if not (__dev__ or ConfigVariableBool('force-pstatcollect', False)) or \ not scope: return decorator diff --git a/direct/src/showbase/ShowBase.py b/direct/src/showbase/ShowBase.py index 9e4f7a9296..54e18040b3 100644 --- a/direct/src/showbase/ShowBase.py +++ b/direct/src/showbase/ShowBase.py @@ -75,6 +75,8 @@ class ShowBase(DirectObject.DirectObject): if logStackDump or uploadStackDump: ExceptionVarDump.install(logStackDump, uploadStackDump) + self.__autoGarbageLogging = self.__dev__ and self.config.GetBool('auto-garbage-logging', False) + ## The directory containing the main Python file of this application. self.mainDir = ExecutionEnvironment.getEnvironmentVariable("MAIN_DIR") @@ -2665,7 +2667,7 @@ class ShowBase(DirectObject.DirectObject): if not properties.getOpen(): # If the user closes the main window, we should exit. self.notify.info("User closed main window.") - if __dev__ and config.GetBool('auto-garbage-logging', 0): + if self.__autoGarbageLogging: GarbageReport.b_checkForGarbageLeaks() self.userExit() @@ -2673,7 +2675,7 @@ class ShowBase(DirectObject.DirectObject): self.mainWinForeground = 1 elif not properties.getForeground() and self.mainWinForeground: self.mainWinForeground = 0 - if __dev__ and config.GetBool('auto-garbage-logging', 0): + if self.__autoGarbageLogging: GarbageReport.b_checkForGarbageLeaks() if properties.getMinimized() and not self.mainWinMinimized: diff --git a/direct/src/showbase/Transitions.py b/direct/src/showbase/Transitions.py index ca4919a48f..2f2db9592d 100644 --- a/direct/src/showbase/Transitions.py +++ b/direct/src/showbase/Transitions.py @@ -168,7 +168,7 @@ class Transitions: self.loadFade() self.fade.reparentTo(aspect2d, FADE_SORT_INDEX) self.fade.setColor(self.alphaOn) - elif base.config.GetBool('no-loading-screen',0): + elif ConfigVariableBool('no-loading-screen', False): if finishIval: self.transitionIval = finishIval self.transitionIval.start() diff --git a/direct/src/showutil/Rope.py b/direct/src/showutil/Rope.py index 9f4a3b1c90..922c681631 100644 --- a/direct/src/showutil/Rope.py +++ b/direct/src/showutil/Rope.py @@ -10,7 +10,8 @@ class Rope(NodePath): thick lines built from triangle strips. """ - showRope = base.config.GetBool('show-rope', 1) + showRope = ConfigVariableBool('show-rope', True, \ + "Set this to false to deactivate the display of ropes.") def __init__(self, name = 'Rope'): self.ropeNode = RopeNode(name) @@ -18,6 +19,9 @@ class Rope(NodePath): self.ropeNode.setCurve(self.curve) NodePath.__init__(self, self.ropeNode) self.name = name + self.order = 0 + self.verts = [] + self.knots = None def setup(self, order, verts, knots = None): """This must be called to define the shape of the curve