summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrandomdan <randomdan@localhost>2011-01-25 00:24:29 +0000
committerrandomdan <randomdan@localhost>2011-01-25 00:24:29 +0000
commit586d5ba4e42aa72bba84b610793cadcd2df6c24a (patch)
treeeb4789b530073242e09708613b3eb9fb3f988598
parentCentralise the ICE splicer (diff)
downloadproject2-586d5ba4e42aa72bba84b610793cadcd2df6c24a.tar.bz2
project2-586d5ba4e42aa72bba84b610793cadcd2df6c24a.tar.xz
project2-586d5ba4e42aa72bba84b610793cadcd2df6c24a.zip
Fix Presenter's inheritance of CommonObjects
Use smart pointers to stages, they are refcounted after all Have variables keep a handle to their row sources, fixes crash during stage destruction
-rw-r--r--project2/cgi/cgiAppEngine.cpp6
-rw-r--r--project2/cgi/cgiAppEngine.h12
-rw-r--r--project2/presenter.h2
-rw-r--r--project2/rowSet.h1
-rw-r--r--project2/variables.cpp4
5 files changed, 13 insertions, 12 deletions
diff --git a/project2/cgi/cgiAppEngine.cpp b/project2/cgi/cgiAppEngine.cpp
index 12a30d7..d1c1579 100644
--- a/project2/cgi/cgiAppEngine.cpp
+++ b/project2/cgi/cgiAppEngine.cpp
@@ -48,9 +48,7 @@ void
CgiApplicationEngine::process() const
{
while (!doc && currentStage) {
- Stage * prev = currentStage;
currentStage = currentStage->run();
- delete prev;
}
if (!sessionID.is_nil()) {
header->setCookie(cgicc::HTTPCookie(SESSIONID, sessionID.str(), "Session ID",
@@ -82,7 +80,7 @@ CgiApplicationEngine::PresentStage::~PresentStage()
{
}
-CgiApplicationEngine::Stage *
+CgiApplicationEngine::StagePtr
CgiApplicationEngine::PresentStage::run()
{
BOOST_FOREACH(OrderedParamCheckers::value_type pc, parameterChecks) {
@@ -150,7 +148,7 @@ CgiApplicationEngine::RequestStage::RequestStage(const CgiApplicationEngine * e,
CgiApplicationEngine::RequestStage::~RequestStage()
{
}
-CgiApplicationEngine::Stage *
+CgiApplicationEngine::StagePtr
CgiApplicationEngine::RequestStage::run()
{
BOOST_FOREACH(OrderedParamCheckers::value_type pc, parameterChecks) {
diff --git a/project2/cgi/cgiAppEngine.h b/project2/cgi/cgiAppEngine.h
index abd4b9e..532b74d 100644
--- a/project2/cgi/cgiAppEngine.h
+++ b/project2/cgi/cgiAppEngine.h
@@ -37,11 +37,13 @@ class CgiApplicationEngine : public ApplicationEngine {
mutable cgicc::HTTPContentHeader * header;
private:
mutable boost::shared_ptr<xmlpp::Document> doc;
- class Stage : public CommonObjects {
+ class Stage;
+ typedef boost::intrusive_ptr<Stage> StagePtr;
+ class Stage : public virtual CommonObjects {
public:
Stage(const CgiApplicationEngine *);
virtual ~Stage() = 0;
- virtual Stage * run() = 0;
+ virtual StagePtr run() = 0;
protected:
const CgiApplicationEngine * appEngine;
};
@@ -49,7 +51,7 @@ class CgiApplicationEngine : public ApplicationEngine {
public:
RequestStage(const CgiApplicationEngine *, const std::string & id);
virtual ~RequestStage();
- virtual Stage * run();
+ virtual StagePtr run();
std::string present;
protected:
OrderedParamCheckers parameterChecks;
@@ -60,9 +62,9 @@ class CgiApplicationEngine : public ApplicationEngine {
PresentStage(const CgiApplicationEngine *, const std::string & id);
PresentStage(const CgiApplicationEngine *, const std::string & group, const std::string & id);
virtual ~PresentStage();
- virtual Stage * run();
+ virtual StagePtr run();
};
- mutable Stage * currentStage;
+ mutable StagePtr currentStage;
mutable UUID sessionID;
};
diff --git a/project2/presenter.h b/project2/presenter.h
index b0f3262..13468f3 100644
--- a/project2/presenter.h
+++ b/project2/presenter.h
@@ -9,7 +9,7 @@
#include "paramChecker.h"
#include "commonObjects.h"
-class Presenter : public CommonObjects, public virtual IntrusivePtrBase {
+class Presenter : public virtual CommonObjects, public virtual IntrusivePtrBase {
public:
Presenter(const std::string & group, const std::string & file);
virtual ~Presenter() = 0;
diff --git a/project2/rowSet.h b/project2/rowSet.h
index f25f937..d85f77b 100644
--- a/project2/rowSet.h
+++ b/project2/rowSet.h
@@ -14,6 +14,7 @@
class RowProcessor;
class RowSet;
typedef boost::intrusive_ptr<RowSet> RowSetPtr;
+typedef boost::intrusive_ptr<const RowSet> ConstRowSetPtr;
typedef std::map<std::string, RowSetPtr> RowSets;
class RowSet : public virtual SourceObject {
diff --git a/project2/variables.cpp b/project2/variables.cpp
index 2267e8b..5c4508f 100644
--- a/project2/variables.cpp
+++ b/project2/variables.cpp
@@ -183,11 +183,11 @@ class VariableParent : public VariableImplDyn, public RowUser {
boost::bind((gCV)&RowSet::getCurrentValue, _2, name));
}
}
- mutable const RowSet * row;
+ mutable ConstRowSetPtr row;
const size_t depth;
const bool attr;
const RowUser * dep;
- mutable boost::function2<void, Glib::ustring &, const RowSet *> getValue;
+ mutable boost::function2<void, Glib::ustring &, ConstRowSetPtr> getValue;
};
class VariableParse : public VariableImplDyn, public RowUser {