mirror of
https://github.com/mat007/turtle.git
synced 2026-06-22 12:13:43 +00:00
Fixed a crash due to static initialization order fiasco on some platforms
git-svn-id: https://svn.code.sf.net/p/turtle/code/trunk@145 860be788-9bd5-4423-9f1e-828f051e677b
This commit is contained in:
parent
f0fd0428d8
commit
f1030c6dfd
4 changed files with 26 additions and 27 deletions
|
|
@ -120,7 +120,7 @@ namespace mock
|
||||||
public:
|
public:
|
||||||
function_impl()
|
function_impl()
|
||||||
: name_( "?" )
|
: name_( "?" )
|
||||||
, parent_( &root )
|
, parent_( &root() )
|
||||||
, valid_( true )
|
, valid_( true )
|
||||||
{
|
{
|
||||||
parent_->add( *this );
|
parent_->add( *this );
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,21 @@ namespace mock
|
||||||
class node : protected verifiable
|
class node : protected verifiable
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
virtual ~node()
|
||||||
|
{
|
||||||
|
std::for_each( v_.begin(), v_.end(),
|
||||||
|
std::mem_fun( &verifiable::untie ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
void tag( const std::string& name )
|
||||||
|
{
|
||||||
|
name_ = name;
|
||||||
|
}
|
||||||
|
const std::string& tag() const
|
||||||
|
{
|
||||||
|
return name_;
|
||||||
|
}
|
||||||
|
|
||||||
void add( verifiable& e )
|
void add( verifiable& e )
|
||||||
{
|
{
|
||||||
v_.push_back( &e );
|
v_.push_back( &e );
|
||||||
|
|
@ -42,24 +57,10 @@ namespace mock
|
||||||
std::for_each( v_.begin(), v_.end(),
|
std::for_each( v_.begin(), v_.end(),
|
||||||
std::mem_fun( &verifiable::reset ) );
|
std::mem_fun( &verifiable::reset ) );
|
||||||
}
|
}
|
||||||
virtual void untie()
|
|
||||||
{}
|
|
||||||
|
|
||||||
void tag( const std::string& name )
|
|
||||||
{
|
|
||||||
name_ = name;
|
|
||||||
}
|
|
||||||
const std::string& tag() const
|
|
||||||
{
|
|
||||||
return name_;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual ~node()
|
virtual void untie()
|
||||||
{
|
{}
|
||||||
std::for_each( v_.begin(), v_.end(),
|
|
||||||
std::mem_fun( &verifiable::untie ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
typedef std::vector< verifiable* > verifiables_type;
|
typedef std::vector< verifiable* > verifiables_type;
|
||||||
|
|
|
||||||
|
|
@ -49,11 +49,11 @@ namespace mock
|
||||||
public:
|
public:
|
||||||
object_impl()
|
object_impl()
|
||||||
{
|
{
|
||||||
root.add( *this );
|
root().add( *this );
|
||||||
}
|
}
|
||||||
virtual ~object_impl()
|
virtual ~object_impl()
|
||||||
{
|
{
|
||||||
root.remove( *this );
|
root().remove( *this );
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,24 +11,22 @@
|
||||||
|
|
||||||
#include "config.hpp"
|
#include "config.hpp"
|
||||||
#include "node.hpp"
|
#include "node.hpp"
|
||||||
#include <boost/test/utils/trivial_singleton.hpp>
|
|
||||||
|
|
||||||
namespace mock
|
namespace mock
|
||||||
{
|
{
|
||||||
class root_t : public boost::unit_test::singleton< root_t >, public node
|
inline node& root()
|
||||||
{
|
{
|
||||||
private:
|
static node r;
|
||||||
BOOST_TEST_SINGLETON_CONS( root_t );
|
return r;
|
||||||
};
|
}
|
||||||
BOOST_TEST_SINGLETON_INST( root )
|
|
||||||
|
|
||||||
inline bool verify()
|
inline bool verify()
|
||||||
{
|
{
|
||||||
return root.verify();
|
return root().verify();
|
||||||
}
|
}
|
||||||
inline void reset()
|
inline void reset()
|
||||||
{
|
{
|
||||||
root.reset();
|
root().reset();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue