summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrandomdan <randomdan@localhost>2012-01-06 20:04:57 +0000
committerrandomdan <randomdan@localhost>2012-01-06 20:04:57 +0000
commit9697a7f814ddee68b4edba0ec62563367e04aeed (patch)
tree1ddb88baf7e6519ae4429dd97c14d3ab73eff128
parentFix missing email message content (diff)
downloadproject2-9697a7f814ddee68b4edba0ec62563367e04aeed.tar.bz2
project2-9697a7f814ddee68b4edba0ec62563367e04aeed.tar.xz
project2-9697a7f814ddee68b4edba0ec62563367e04aeed.zip
Fix another memory leak (better methods possibly available, but this will suffice for now)
-rw-r--r--project2/cgi/cgiAppEngine.h1
-rw-r--r--project2/cgi/cgiStagePresent.cpp3
-rw-r--r--project2/common/commonObjects.cpp5
-rw-r--r--project2/common/commonObjects.h1
-rw-r--r--project2/common/scriptLoader.cpp6
-rw-r--r--project2/common/scriptLoader.h1
6 files changed, 12 insertions, 5 deletions
diff --git a/project2/cgi/cgiAppEngine.h b/project2/cgi/cgiAppEngine.h
index a7648d1..64f081d 100644
--- a/project2/cgi/cgiAppEngine.h
+++ b/project2/cgi/cgiAppEngine.h
@@ -102,7 +102,6 @@ class CgiApplicationEngine : public ApplicationEngine, public TransformChainLink
virtual HttpHeaderPtr getHeader() const;
protected:
mutable MultiRowSetPresenterPtr presenter;
- ScriptNodePtr root;
};
/// The built-in fail-safe not found stage
diff --git a/project2/cgi/cgiStagePresent.cpp b/project2/cgi/cgiStagePresent.cpp
index 2ca6147..152b906 100644
--- a/project2/cgi/cgiStagePresent.cpp
+++ b/project2/cgi/cgiStagePresent.cpp
@@ -9,8 +9,7 @@ CgiApplicationEngine::PresentStage::PresentStage(const CgiEnvironment * e, Scrip
CgiApplicationEngine::ResponseStage(e, s->root()),
CommonObjects(s->root()),
CheckHost(s->root()),
- ViewHost(s->root()),
- root(s->root())
+ ViewHost(s->root())
{
s->loader.addLoadTarget(s->root(), Storer::into<OutputOptionsLoader>(&outputOptions));
s->loader.addLoadTarget(s->root(), Storer::into<PresenterLoader>(&presenter));
diff --git a/project2/common/commonObjects.cpp b/project2/common/commonObjects.cpp
index bc932b8..0e58cc8 100644
--- a/project2/common/commonObjects.cpp
+++ b/project2/common/commonObjects.cpp
@@ -16,6 +16,7 @@ CommonObjects::CommonObjects(ScriptNodePtr s) :
CommonObjects::~CommonObjects()
{
+ script->loader.discardLoadTargets();
}
RowSetPtr
@@ -36,9 +37,9 @@ CommonObjects::loadDataSource(const std::string & name) const
void
CommonObjects::loadScriptComponents() const
{
- if (script) {
+ if (!scriptLoaded) {
script->load(this, true);
- script.reset();
+ scriptLoaded = true;
}
}
diff --git a/project2/common/commonObjects.h b/project2/common/commonObjects.h
index 5c4b574..b70185c 100644
--- a/project2/common/commonObjects.h
+++ b/project2/common/commonObjects.h
@@ -37,6 +37,7 @@ class CommonObjects : public virtual IntrusivePtrBase {
RowSets rowSets;
mutable DataSources datasources;
mutable ScriptReaderPtr script;
+ mutable bool scriptLoaded;
private:
DataSources::const_iterator loadDataSource(const std::string & name) const;
diff --git a/project2/common/scriptLoader.cpp b/project2/common/scriptLoader.cpp
index db256a9..6d5abdb 100644
--- a/project2/common/scriptLoader.cpp
+++ b/project2/common/scriptLoader.cpp
@@ -49,6 +49,12 @@ LoaderBase::addLoadTargetSub(ScriptNodePtr src, const Glib::ustring & name, bool
}
}
+void
+LoaderBase::discardLoadTargets()
+{
+ targets.clear();
+}
+
ScriptNodePtr
LoaderBase::getSub(ScriptNodePtr root, const Glib::ustring & name, bool required)
{
diff --git a/project2/common/scriptLoader.h b/project2/common/scriptLoader.h
index b187ebb..b2faecd 100644
--- a/project2/common/scriptLoader.h
+++ b/project2/common/scriptLoader.h
@@ -31,6 +31,7 @@ class LoaderBase {
void addLoadTarget(ScriptNodePtr src, boost::intrusive_ptr<Storer> target);
void addLoadTargetSub(ScriptNodePtr src, const Glib::ustring & name, bool required, boost::intrusive_ptr<Storer> target);
+ void discardLoadTargets();
static void onAllComponents(const boost::function1<void, ComponentLoader *> &);