summaryrefslogtreecommitdiff
path: root/indra/test/test.cpp
diff options
context:
space:
mode:
authorStinson Linden <stinson@lindenlab.com>2014-05-16 22:44:25 +0100
committerStinson Linden <stinson@lindenlab.com>2014-05-16 22:44:25 +0100
commit34b2f2d1f841f7b7f93386d66be6943910cd055b (patch)
treef555da843edd3de150bcc91fa3e26bcca260455c /indra/test/test.cpp
parent76023f172c2a8eeb5c8d6b55119ef3e8faf8cc6f (diff)
MAINT-4009: First pass refactoring to eliminate memory related to error reporting that is not properly cleaned up.
Diffstat (limited to 'indra/test/test.cpp')
-rwxr-xr-xindra/test/test.cpp62
1 files changed, 45 insertions, 17 deletions
diff --git a/indra/test/test.cpp b/indra/test/test.cpp
index 10f71a2843..0dd21b6a05 100755
--- a/indra/test/test.cpp
+++ b/indra/test/test.cpp
@@ -95,25 +95,20 @@ public:
virtual void replay(std::ostream&) {}
};
-class LLReplayLogReal: public LLReplayLog, public LLError::Recorder, public boost::noncopyable
+class RecordToTempFile : public LLError::Recorder, public boost::noncopyable
{
public:
- LLReplayLogReal(LLError::ELevel level, apr_pool_t* pool):
- mOldSettings(LLError::saveAndResetSettings()),
- mProxy(new RecorderProxy(this)),
- mTempFile("log", "", pool), // create file
- mFile(mTempFile.getName().c_str()) // open it
+ RecordToTempFile(apr_pool_t* pPool)
+ : LLError::Recorder(),
+ boost::noncopyable(),
+ mTempFile("log", "", pPool),
+ mFile(mTempFile.getName().c_str())
{
- LLError::setFatalFunction(wouldHaveCrashed);
- LLError::setDefaultLevel(level);
- LLError::addRecorder(mProxy);
}
- virtual ~LLReplayLogReal()
+ virtual ~RecordToTempFile()
{
- LLError::removeRecorder(mProxy);
- delete mProxy;
- LLError::restoreSettings(mOldSettings);
+ mFile.close();
}
virtual void recordMessage(LLError::ELevel level, const std::string& message)
@@ -121,13 +116,13 @@ public:
mFile << message << std::endl;
}
- virtual void reset()
+ void reset()
{
mFile.close();
mFile.open(mTempFile.getName().c_str());
}
- virtual void replay(std::ostream& out)
+ void replay(std::ostream& out)
{
mFile.close();
std::ifstream inf(mTempFile.getName().c_str());
@@ -139,12 +134,45 @@ public:
}
private:
- LLError::Settings* mOldSettings;
- LLError::Recorder* mProxy;
NamedTempFile mTempFile;
std::ofstream mFile;
};
+class LLReplayLogReal: public LLReplayLog, public boost::noncopyable
+{
+public:
+ LLReplayLogReal(LLError::ELevel level, apr_pool_t* pool)
+ : LLReplayLog(),
+ boost::noncopyable(),
+ mOldSettings(LLError::saveAndResetSettings()),
+ mRecorder(new RecordToTempFile(pool))
+ {
+ LLError::setFatalFunction(wouldHaveCrashed);
+ LLError::setDefaultLevel(level);
+ LLError::addRecorder(mRecorder);
+ }
+
+ virtual ~LLReplayLogReal()
+ {
+ LLError::removeRecorder(mRecorder);
+ LLError::restoreSettings(mOldSettings);
+ }
+
+ virtual void reset()
+ {
+ boost::dynamic_pointer_cast<RecordToTempFile>(mRecorder)->reset();
+ }
+
+ virtual void replay(std::ostream& out)
+ {
+ boost::dynamic_pointer_cast<RecordToTempFile>(mRecorder)->replay(out);
+ }
+
+private:
+ LLError::Settings* mOldSettings;
+ LLError::RecorderPtr mRecorder;
+};
+
class LLTestCallback : public tut::callback
{
public: