boost-signals

Can Qt signals return a value?

时光总嘲笑我的痴心妄想 提交于 2020-01-19 03:17:29
问题 Boost.Signals allows various strategies of using the return values of slots to form the return value of the signal. E.g. adding them, forming a vector out of them, or returning the last one. The common wisdom (expressed in the Qt documentation [EDIT: as well as some answers to this question ] ) is that no such thing is possible with Qt signals. However, when I run the moc on the following class definition: class Object : public QObject { Q_OBJECT public: explicit Object( QObject * parent=0 )

Boost: what could be the reasons for a crash in boost::slot<>::~slot?

人盡茶涼 提交于 2020-01-17 04:32:06
问题 I am getting such a crash: #0 0x90b05955 in __gnu_debug::_Safe_iterator_base::_M_detach #1 0x90b059ce in __gnu_debug::_Safe_iterator_base::_M_attach #2 0x90b05afa in __gnu_debug::_Safe_sequence_base::_M_detach_all #3 0x000bc54f in __gnu_debug::_Safe_sequence_base::~_Safe_sequence_base at safe_base.h:170 #4 0x000aac05 in __gnu_debug::_Safe_sequence<__gnu_debug_def::vector<boost::signals::trackable const*, std::allocator<boost::signals::trackable const*> > >::~_Safe_sequence at safe_sequence.h

Boost::signals2 - descruction of an object with the slot

女生的网名这么多〃 提交于 2019-12-31 03:37:26
问题 Consider this: #include <boost/signals2.hpp> #include <iostream> struct object_with_slot { void operator()() { std::cout << "Slot called!" << std::endl; member = 50500; } int member; }; int main() { boost::signals2::signal<void ()> sig; object_with_slot * ptr = new object_with_slot; sig.connect(*ptr); delete ptr; sig(); } Output is "Slot called!" and no crash or anything. That's why I have a few questions: 1) Why there is no crash? 2) Why there is no crash even if the slot function assigns

How to make a C++ boost::signal be caught from an object which encapsulates the object which emits it?

安稳与你 提交于 2019-12-23 04:36:30
问题 I have a TcpDevice class which encapsulates a TCP connection, which has an onRemoteDisconnect method which gets called whenever the remote end hangs up. Then, there's a SessionManager object which creates TcpSession objects which take a TcpDevice as a communication channel and inserts them in an internal pointer container for the application to use. In case any of the managed TcpSessions should end, I would like the SessionManager instance to be notified about it and then remove the

c++ Netbeans 7.2.1 linking boost libraries correctly

巧了我就是萌 提交于 2019-12-13 06:29:20
问题 I've recently switched from visual studio 2010 express to using NetBeans, and i'm already very impressed with the layout and simplicity, even though it did take a bit of nudging to compile right. However, i've got another problem. When i tested to see if boost would work as well, i included the file boost/signals.hpp in a main.cpp and then went to the additional library directories in the project options and added the lib directory of my boost install, same as i would do in visual studio.

How often to derive from boost::signals::trackable?

一世执手 提交于 2019-12-11 10:16:35
问题 When using Boost.Signals, boost allows you to derive from boost::signals::trackable in order to ease object/connection lifetime management (See the boost documentation). I am in an early stage of my project and I am thinking, whether to derive from boost::signals::trackable in every new class I write that might use Boost.Signals in the future or only in classes I am sure that they will need the functionality of the trackable bas e-class The main reason for th first approach would be to

segfault when using boost::signal with -D_GLIBCXX_DEBUG compiler flag

心不动则不痛 提交于 2019-12-11 01:49:44
问题 I'm building with g++, and yesterday a helpful person on SO told me to compile with the -D_GLIBCXX_DEBUG and -D_GLIBCXX_DEBUG_PEDANTIC flags. I did so, and I spent most of yesterday tweaking my code to conform to these flags. Now it's complaining about my use of boost::signal , and I'm not sure where the problem is. I have a class Yarl that has a function refresh() that I want to bind to a signal sigRefresh in another class EventHandler : class Yarl { private: void refresh(); (...) }; class

Is there a way to connect a boost signal directly to another signal?

本小妞迷上赌 提交于 2019-12-09 11:31:02
问题 I was wondering if there is a nicer way to connect a Boost signal of one class directly to a signal of another class? For example imagine a facade class with a bunch of members which provide their own signals. Now assume that the facade wants to expose these signals. I usually end up writing boilerplate methods which I then connect as signal handlers. using namespace boost::signal; class A { public: A(){}; virtual ~A(){}; signal<void()> signalA; }; class B { public: B(){}; virtual ~B(){};

Does the boost.signals2 library need to be built?

荒凉一梦 提交于 2019-12-09 01:24:27
问题 My system is having trouble building the boost libraries. I understand that most boost libraries are (fortunately) just headers that do not need to be build (with some exceptions). Does the boost :: signals2 library need to be built? Also is the boost.signals2 library dependant on the boost.signals library? 回答1: Signals is not header-only, signals2 is. But however, signals2 is explicitly developed for thread-safety and if you use boost.thread, this has to be compiled. As far as I know

Boost::Signals for C++ Data copying

a 夏天 提交于 2019-12-08 00:35:23
问题 Recently I had a class that looked like class IGraphElement{ typedef void FuncCharPtr(char*, int) ; public: void Add(FuncCharPtr* f) { FuncVec.push_back(f); } void CastData(char * data, int length){ for(size_t i = 0 ; i < FuncVec.size(); i++){ char* dataCopy = new char[length]; memcpy(dataCopy, data, length); FuncVec[i](dataCopy, length); } } private: vector<FuncCharPtr*> FuncVec ; }; There I was giving to all subscribers a pointer to there copy of data. Now I want to make my class to use