Browse Source

Clear inbuilt script object type search cache when compiling script code to prevent crash if a failed script module compile is attempted several times.

Lasse Öörni 13 years ago
parent
commit
7524eb27a9

+ 3 - 3
Engine/Physics/PhysicsWorld.h

@@ -142,9 +142,9 @@ public:
     void RemoveJoint(Joint* joint);
     /// Add debug geometry to the debug renderer.
     void DrawDebugGeometry(bool depthTest);
-    /// Set debug renderer to use.
+    /// Set debug renderer to use. Called both by PhysicsWorld itself and physics components.
     void SetDebugRenderer(DebugRenderer* debug);
-    /// Set debug geometry depth test mode.
+    /// Set debug geometry depth test mode. Called both by PhysicsWorld itself and physics components.
     void SetDebugDepthTest(bool enable);
     
     /// Return the Bullet physics world.
@@ -202,7 +202,7 @@ private:
     float maxNetworkAngularVelocity_;
     /// Interpolation flag.
     bool interpolation_;
-    /// Debug renderer to use.
+    /// Debug renderer.
     DebugRenderer* debugRenderer_;
     /// Debug draw flags.
     int debugMode_;

+ 7 - 0
Engine/Script/Script.cpp

@@ -160,6 +160,8 @@ bool Script::Execute(const String& line)
     // Note: compiling code each time is slow. Not to be used for performance-critical or repeating activity
     PROFILE(ExecuteImmediate);
     
+    ClearObjectTypeCache();
+    
     String wrappedLine = "void f(){\n" + line + ";\n}";
     
     // If no immediate mode script file set, create a dummy module for compiling the line
@@ -399,6 +401,11 @@ Scene* Script::GetDefaultScene() const
     return defaultScene_;
 }
 
+void Script::ClearObjectTypeCache()
+{
+    objectTypes_.Clear();
+}
+
 asIObjectType* Script::GetObjectType(const char* declaration)
 {
     Map<const char*, asIObjectType*>::ConstIterator i = objectTypes_.Find(declaration);

+ 2 - 0
Engine/Script/Script.h

@@ -83,6 +83,8 @@ public:
     ScriptFile* GetDefaultScriptFile() const;
     /// Return immediate mode scene.
     Scene* GetDefaultScene() const;
+    /// Clear the inbuild object type cache.
+    void ClearObjectTypeCache();
     /// Query for an inbuilt object type by constant declaration. Can not be used for script types.
     asIObjectType* GetObjectType(const char* declaration);
     /// Return logging mode.

+ 2 - 0
Engine/Script/ScriptFile.cpp

@@ -524,6 +524,8 @@ void ScriptFile::ReleaseModule()
 {
     if (scriptModule_)
     {
+        script_->ClearObjectTypeCache();
+        
         // Clear search caches and event handlers
         includeFiles_.Clear();
         validClasses_.Clear();