1
0
forked from 0ad/0ad

Use Boost.Signals2 for Atlas. Patch by fabio. Fixes #2469.

This was SVN commit r15173.
This commit is contained in:
leper 2014-05-19 21:01:02 +00:00
parent 15472f7797
commit 940868398c
5 changed files with 10 additions and 50 deletions

View File

@ -252,15 +252,6 @@ extern_lib_defs = {
})
end,
},
boost_signals = {
link_settings = function()
add_default_links({
android_names = { "boost_signals-gcc-mt" },
unix_names = { os.findlib("boost_signals-mt") and "boost_signals-mt" or "boost_signals" },
osx_names = { "boost_signals-mt" },
})
end,
},
comsuppw = {
link_settings = function()
add_default_links({

View File

@ -1107,7 +1107,6 @@ function setup_atlas_projects()
atlas_extern_libs = {
"boost",
"boost_signals",
"comsuppw",
--"ffmpeg", -- disabled for now because it causes too many build difficulties
"libxml2",

View File

@ -1,4 +1,4 @@
/* Copyright (C) 2013 Wildfire Games.
/* Copyright (C) 2014 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
@ -26,10 +26,10 @@
#include "wx/filename.h"
#include <boost/version.hpp>
#if BOOST_VERSION >= 105400
#if BOOST_VERSION >= 104000
# include <boost/signals2/signal.hpp>
#else
# include <boost/signal.hpp>
# error Atlas requires Boost 1.40 or later
#endif
class AtObj;
@ -52,12 +52,7 @@ public:
};
AtlasWindow(wxWindow* parent, const wxString& title, const wxSize& size);
#if BOOST_VERSION >= 105400
boost::signals2::signal<void ()> sig_FileSaved;
#else
boost::signal<void ()> sig_FileSaved;
#endif
private:

View File

@ -1,4 +1,4 @@
/* Copyright (C) 2013 Wildfire Games.
/* Copyright (C) 2014 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
@ -39,17 +39,15 @@ variable_to_be_watched.NotifyObservers();
*/
#include <boost/bind.hpp>
#include <boost/version.hpp>
#if BOOST_VERSION >= 105400
#if BOOST_VERSION >= 104000
# include <boost/signals2.hpp>
typedef boost::signals2::connection ObservableConnection;
typedef boost::signals2::scoped_connection ObservableScopedConnection;
#else
# include <boost/signals.hpp>
typedef boost::signals::connection ObservableConnection;
typedef boost::signals::scoped_connection ObservableScopedConnection;
# error Atlas requires Boost 1.40 or later
#endif
#include <boost/bind.hpp>
template <typename T> class Observable : public T
{
@ -96,15 +94,8 @@ public:
else
{
// Temporarily disable conn
#if BOOST_VERSION >= 105400
boost::signals2::shared_connection_block blocker(conn);
#else
conn.block();
#endif
NotifyObservers();
#if BOOST_VERSION < 105400
conn.unblock();
#endif
}
}
@ -115,11 +106,7 @@ public:
}
private:
#if BOOST_VERSION >= 105400
boost::signals2::signal<void (const T&)> m_Signal;
#else
boost::signal<void (const T&)> m_Signal;
#endif
};
// A similar thing, but for wrapping pointers instead of objects
@ -179,25 +166,14 @@ public:
else
{
// Temporarily disable conn
#if BOOST_VERSION >= 105400
boost::signals2::shared_connection_block blocker(conn);
#else
conn.block();
#endif
NotifyObservers();
#if BOOST_VERSION < 105400
conn.unblock();
#endif
}
}
private:
T* m_Ptr;
#if BOOST_VERSION >= 105400
boost::signals2::signal<void (T*)> m_Signal;
#else
boost::signal<void (T*)> m_Signal;
#endif
};
class ObservableScopedConnections

View File

@ -84,14 +84,13 @@
#include <limits>
#include <cassert>
#include <boost/bind.hpp>
#include <boost/version.hpp>
#if BOOST_VERSION >= 105400
// Signals is deprecated since 1.54
#if BOOST_VERSION >= 104000
# include <boost/signals2.hpp>
#else
# include <boost/signals.hpp>
# error Atlas requires Boost 1.40 or later
#endif
#include <boost/bind.hpp>
// Nicer memory-leak detection:
#ifdef _WIN32