Remove PhysicsManager singleton and use shared_ptr instead. Resolves the issue where sometimes destructors were called in an unexpected sequence resulting in a crash while exiting the application.

This commit is contained in:
cc9cii 2014-12-01 06:44:12 +11:00
parent 4c1906b999
commit 2720e5ea9d
19 changed files with 47 additions and 200 deletions

View file

@ -9,6 +9,8 @@
#include <components/files/configurationmanager.hpp>
#endif
#include "../../view/world/physicssystem.hpp"
void CSMDoc::Document::addGmsts()
{
static const char *gmstFloats[] =
@ -2253,7 +2255,7 @@ CSMDoc::Document::Document (const Files::ConfigurationManager& configuration,
mProjectPath ((configuration.getUserDataPath() / "projects") /
(savePath.filename().string() + ".project")),
mSaving (*this, mProjectPath, encoding),
mRunner (mProjectPath)
mRunner (mProjectPath), mPhysics(boost::shared_ptr<CSVWorld::PhysicsSystem>())
{
if (mContentFiles.empty())
throw std::runtime_error ("Empty content file sequence");
@ -2464,3 +2466,11 @@ void CSMDoc::Document::progress (int current, int max, int type)
{
emit progress (current, max, type, 1, this);
}
boost::shared_ptr<CSVWorld::PhysicsSystem> CSMDoc::Document::getPhysics ()
{
if(!mPhysics)
mPhysics = boost::shared_ptr<CSVWorld::PhysicsSystem> (new CSVWorld::PhysicsSystem());
return mPhysics;
}