Permalink
Browse files

Hopefully fixed the second invalid pointer detection that could often…

… occur in the script manager.

For that, I removed an old allacrostian temp statement, fixing the check
about opening the same file multiple times.

This should permit me to disclose the bug origin in a easier way.

I also added a bit of useful log in case someone else got the issue.
  • Loading branch information...
1 parent c83e993 commit dd4769f0850d08049410ceae04e4a34509e258a6 Yohann Ferreira committed Sep 22, 2012
Showing with 19 additions and 7 deletions.
  1. +2 −2 src/engine/script/script.cpp
  2. +17 −5 src/engine/script/script_read.cpp
@@ -65,9 +65,9 @@ bool ScriptEngine::SingletonInitialize() {
bool ScriptEngine::IsFileOpen(const std::string& filename) {
- return false; // TEMP: working on resolving the issue with files being opened multiple times
-
if (_open_files.find(filename) != _open_files.end()) {
+ PRINT_WARNING << "The script file: " << filename << " was already open."
+ << std::endl;
return true;
}
return false;
@@ -98,14 +98,15 @@ bool ReadScriptDescriptor::OpenFile() {
void ReadScriptDescriptor::CloseFile() {
- if (IsFileOpen() == false) {
- IF_PRINT_WARNING(SCRIPT_DEBUG) << "could not close the file because it was not open." << std::endl;
+ if (!IsFileOpen()) {
+ PRINT_WARNING << "Could not close the file: " << _filename
+ << " because it was not open." << std::endl;
return;
}
// Probably not needed. Script errors should be printed immediately.
if (IsErrorDetected()) {
- IF_PRINT_WARNING(SCRIPT_DEBUG)
+ PRINT_WARNING
<< "the file " << _filename << " had the following error messages remaining:"
<< std::endl << _error_messages.str() << std::endl;
}
@@ -468,11 +469,17 @@ bool ReadScriptDescriptor::RunScriptFunction(const std::string& function_name) {
try {
ScriptCallFunction<void>(GetLuaState(), function_name.c_str());
- } catch(luabind::error e) {
+ }
+ catch(const luabind::error& e) {
PRINT_ERROR << "Error while loading :" << function_name << std::endl;
ScriptManager->HandleLuaError(e);
return false;
}
+ catch (const luabind::cast_failed& e) {
+ PRINT_ERROR << "Error while loading :" << function_name << std::endl;
+ ScriptManager->HandleCastError(e);
+ }
+
return true;
}
@@ -486,11 +493,16 @@ bool ReadScriptDescriptor::RunScriptObject(const luabind::object& object) {
try {
ScriptCallFunction<void>(object);
- } catch(luabind::error e) {
+ }
+ catch(const luabind::error& e) {
PRINT_ERROR << "Error while loading script object." << std::endl;
ScriptManager->HandleLuaError(e);
return false;
}
+ catch (const luabind::cast_failed& e) {
+ PRINT_ERROR << "Error while loading script object." << std::endl;
+ ScriptManager->HandleCastError(e);
+ }
return true;
}

0 comments on commit dd4769f

Please sign in to comment.