summaryrefslogtreecommitdiff
path: root/src/ModuleCache.cc
diff options
context:
space:
mode:
authordon bright <hugh.m.bright@gmail.com>2013-01-28 02:42:20 (GMT)
committerdon bright <hugh.m.bright@gmail.com>2013-01-28 02:42:20 (GMT)
commit1e64dddf1ea30282c89de7f35854a68614234652 (patch)
tree165d37c1c66f6ff79d48c74794238b3f0bed09da /src/ModuleCache.cc
parent5c779159c208ca3d88c88479ab29f9cd66574859 (diff)
parentd0856efe6da545693f9c50a8a2514a9f999ab5ef (diff)
Merge branch 'master' of github.com:openscad/openscad into issue159
Diffstat (limited to 'src/ModuleCache.cc')
-rw-r--r--src/ModuleCache.cc15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/ModuleCache.cc b/src/ModuleCache.cc
index d03d121..19a3f84 100644
--- a/src/ModuleCache.cc
+++ b/src/ModuleCache.cc
@@ -72,20 +72,27 @@ Module *ModuleCache::evaluate(const std::string &filename)
PRINTB("WARNING: Can't open library file '%s'\n", filename);
return NULL;
}
- std::string text((std::istreambuf_iterator<char>(ifs)), std::istreambuf_iterator<char>());
+ std::stringstream textbuf;
+ textbuf << ifs.rdbuf();
+ textbuf << "\n" << commandline_commands;
print_messages_push();
-
+
+ Module *oldmodule = NULL;
cache_entry e = { NULL, cache_id };
if (this->entries.find(filename) != this->entries.end()) {
- delete this->entries[filename].module;
+ oldmodule = this->entries[filename].module;
}
this->entries[filename] = e;
std::string pathname = boosty::stringy(fs::path(filename).parent_path());
- lib_mod = dynamic_cast<Module*>(parse(text.c_str(), pathname.c_str(), false));
+ lib_mod = dynamic_cast<Module*>(parse(textbuf.str().c_str(), pathname.c_str(), false));
+ PRINTB_NOCACHE(" compiled module: %p", lib_mod);
if (lib_mod) {
+ // We defer deletion so we can ensure that the new module won't
+ // have the same address as the old
+ delete oldmodule;
this->entries[filename].module = lib_mod;
} else {
this->entries.erase(filename);
contact: Jan Huwald // Impressum