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:
|
||||
function_impl()
|
||||
: name_( "?" )
|
||||
, parent_( &root )
|
||||
, parent_( &root() )
|
||||
, valid_( true )
|
||||
{
|
||||
parent_->add( *this );
|
||||
|
|
|
|||
|
|
@ -20,6 +20,21 @@ namespace mock
|
|||
class node : protected verifiable
|
||||
{
|
||||
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 )
|
||||
{
|
||||
v_.push_back( &e );
|
||||
|
|
@ -42,24 +57,10 @@ namespace mock
|
|||
std::for_each( v_.begin(), v_.end(),
|
||||
std::mem_fun( &verifiable::reset ) );
|
||||
}
|
||||
virtual void untie()
|
||||
{}
|
||||
|
||||
void tag( const std::string& name )
|
||||
{
|
||||
name_ = name;
|
||||
}
|
||||
const std::string& tag() const
|
||||
{
|
||||
return name_;
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual ~node()
|
||||
{
|
||||
std::for_each( v_.begin(), v_.end(),
|
||||
std::mem_fun( &verifiable::untie ) );
|
||||
}
|
||||
virtual void untie()
|
||||
{}
|
||||
|
||||
private:
|
||||
typedef std::vector< verifiable* > verifiables_type;
|
||||
|
|
|
|||
|
|
@ -49,11 +49,11 @@ namespace mock
|
|||
public:
|
||||
object_impl()
|
||||
{
|
||||
root.add( *this );
|
||||
root().add( *this );
|
||||
}
|
||||
virtual ~object_impl()
|
||||
{
|
||||
root.remove( *this );
|
||||
root().remove( *this );
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -11,24 +11,22 @@
|
|||
|
||||
#include "config.hpp"
|
||||
#include "node.hpp"
|
||||
#include <boost/test/utils/trivial_singleton.hpp>
|
||||
|
||||
namespace mock
|
||||
{
|
||||
class root_t : public boost::unit_test::singleton< root_t >, public node
|
||||
inline node& root()
|
||||
{
|
||||
private:
|
||||
BOOST_TEST_SINGLETON_CONS( root_t );
|
||||
};
|
||||
BOOST_TEST_SINGLETON_INST( root )
|
||||
static node r;
|
||||
return r;
|
||||
}
|
||||
|
||||
inline bool verify()
|
||||
{
|
||||
return root.verify();
|
||||
return root().verify();
|
||||
}
|
||||
inline void reset()
|
||||
{
|
||||
root.reset();
|
||||
root().reset();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue