summaryrefslogtreecommitdiff
path: root/src/module.cc
diff options
context:
space:
mode:
authorMarius Kintel <marius@kintel.net>2013-06-13 05:16:26 (GMT)
committerMarius Kintel <marius@kintel.net>2013-06-13 05:16:26 (GMT)
commitbd0248e109f6a290570bca55949583ea80bdce38 (patch)
tree67a4409890ef44544b08af915a428cf18a283de7 /src/module.cc
parent0cb8ab508ec1b3a072a2d5ef63fe1d46f16310f0 (diff)
Fixed a bug where changing a file during a large automatic reload could cause a crash
Diffstat (limited to 'src/module.cc')
-rw-r--r--src/module.cc16
1 files changed, 4 insertions, 12 deletions
diff --git a/src/module.cc b/src/module.cc
index 046d0c4..8fb8506 100644
--- a/src/module.cc
+++ b/src/module.cc
@@ -264,43 +264,35 @@ bool FileModule::handleDependencies()
// as it will have a relative path.
// Iterating manually since we want to modify the container while iterating
- std::vector<std::pair<std::string, FileModule*> > modified_modules;
FileModule::ModuleContainer::iterator iter = this->usedlibs.begin();
while (iter != this->usedlibs.end()) {
FileModule::ModuleContainer::iterator curr = iter++;
- FileModule *oldmodule = curr->second;
bool wasmissing = false;
// Get an absolute filename for the module
- std::string filename = curr->first;
+ std::string filename = *curr;
if (!boosty::is_absolute(filename)) {
wasmissing = true;
fs::path fullpath = find_valid_path(this->path, filename);
if (!fullpath.empty()) filename = boosty::stringy(fullpath);
}
+ FileModule *oldmodule = ModuleCache::instance()->lookup(filename);
FileModule *newmodule = ModuleCache::instance()->evaluate(filename);
// Detect appearance but not removal of files
if (newmodule && oldmodule != newmodule) {
changed = true;
#ifdef DEBUG
- PRINTB_NOCACHE(" %s: %p", filename % newmodule);
+ PRINTB_NOCACHE(" %s: %p -> %p", filename % oldmodule % newmodule);
#endif
}
- if (newmodule) {
- modified_modules.push_back(std::make_pair(filename, newmodule));
- this->usedlibs.erase(curr);
- }
- else {
+ if (!newmodule) {
// Only print warning if we're not part of an automatic reload
if (!oldmodule && !wasmissing) {
PRINTB_NOCACHE("WARNING: Failed to compile library '%s'.", filename);
}
}
}
- BOOST_FOREACH(const FileModule::ModuleContainer::value_type &mod, modified_modules) {
- this->usedlibs[mod.first] = mod.second;
- }
this->is_handling_dependencies = false;
return changed;
contact: Jan Huwald // Impressum