add helper class to tmp. block a boost signal/slot connection

This commit is contained in:
wmayer
2017-12-21 22:22:33 +01:00
parent 5b358e1bd9
commit 495c048ece

View File

@@ -30,6 +30,7 @@
#include <iostream>
#include <vector>
#include <string>
#include <boost/signals.hpp>
#include <QString>
namespace Base
@@ -146,6 +147,8 @@ private:
Private* d;
};
// ----------------------------------------------------------------------------
template<typename Status, class Object>
class ObjectStatusLocker
{
@@ -162,6 +165,23 @@ private:
// ----------------------------------------------------------------------------
class ConnectionBlocker {
typedef boost::BOOST_SIGNALS_NAMESPACE::connection Connection;
bool b;
Connection& c;
public:
ConnectionBlocker(Connection& c) : c(c) {
b = c.blocked();
c.block(true);
}
~ConnectionBlocker() {
c.block(b);
}
};
// ----------------------------------------------------------------------------
struct BaseExport Tools
{
static std::string getUniqueName(const std::string&, const std::vector<std::string>&,int d=0);