Skip to content

Commit

Permalink
libdeng2|ScriptSystem|Fixed: Adding native modules
Browse files Browse the repository at this point in the history
Cannot refer to the private instance before it has been assigned to d.
  • Loading branch information
skyjake committed Feb 17, 2013
1 parent a0aa1d4 commit 338e393
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions doomsday/libdeng2/src/scriptsys/scriptsystem.cpp
Expand Up @@ -56,7 +56,7 @@ DENG2_PIMPL(ScriptSystem), DENG2_OBSERVES(Record, Deletion)
mod.addNumber("CPU_BITS", Version::cpuBits()).setReadOnly();
mod.addBoolean("DEBUG", Version::isDebugBuild()).setReadOnly();

self.addNativeModule("Version", mod);
addNativeModule("Version", mod);
}

~Instance()
Expand All @@ -67,6 +67,12 @@ DENG2_PIMPL(ScriptSystem), DENG2_OBSERVES(Record, Deletion)
}
}

void addNativeModule(String const &name, Record &module)
{
nativeModules.insert(name, &module);
module.audienceForDeletion += this;
}

void recordBeingDeleted(Record &record)
{
QMutableMapIterator<String, Record *> iter(nativeModules);
Expand All @@ -91,8 +97,7 @@ ScriptSystem::~ScriptSystem()

void ScriptSystem::addNativeModule(String const &name, Record &module)
{
d->nativeModules.insert(name, &module);
module.audienceForDeletion += d;
d->addNativeModule(name, module);
}

static int sortFilesByModifiedAt(File const *a, File const *b)
Expand Down

0 comments on commit 338e393

Please sign in to comment.