Newbie: Problem with Signals

I am having some problems with boost::signals version 1_30_0 on XP,
compiled and linked using VC6.
I am building a timer mechanism, similar to that with Qt.
A user instanciates a timer with some millisecond value, starts the
timer via t.Start(), and then enters the event loop (or in most
cases, returns from a function call by the event loop).
Timer definition:
class Timer {
typedef boost::signal1

Ray wrote:
I am having some problems with boost::signals version 1_30_0 on XP, compiled and linked using VC6.
I am building a timer mechanism, similar to that with Qt. A user instanciates a timer with some millisecond value, starts the timer via t.Start(), and then enters the event loop (or in most cases, returns from a function call by the event loop).
Timer definition:
class Timer { typedef boost::signal1
TimerSignalType; typedef TimerSignalType::slot_type TimerSlotType; public: boost::signals::connection TimerConnect(const TimerSlotType& slot ) { return OnRing.connect( slot ); } Timer(); Timer( const Timer& ); Timer( unsigned long millesecInterval, TimerType t = Continous ); ~Timer(); void Start();
void Ring() {OnRing( myId );}
private:
TimerSignalType OnRing; int myId; };
void Rang( int i ) { cout << "Received timer " << endl; }
main() { EventLoop *eventLoop = EventLoop::Instance(); Timer t1( 3000, Continous ); t1.TimerConnect( boost::bind( Rang, _1) ); t1.Start(); eventLoop->Exec(); }
eventLoop->Exec() start an event loop. The code always crashes when atteping to execute the connected function.
What am I doing wrong?
I see nothing wrong with the code you posted. When I added the necessary stub definitions it compiled and ran fine.

Ray wrote:
I am having some problems with boost::signals version 1_30_0 on XP, compiled and linked using VC6.
I am building a timer mechanism, similar to that with Qt. A user instanciates a timer with some millisecond value, starts
--- In Boost-Users@yahoogroups.com, "Peter Dimov"
timer via t.Start(), and then enters the event loop (or in most cases, returns from a function call by the event loop).
Timer definition:
class Timer { typedef boost::signal1
TimerSignalType; typedef TimerSignalType::slot_type TimerSlotType; public: boost::signals::connection TimerConnect(const TimerSlotType& slot ) { return OnRing.connect( slot ); } Timer(); Timer( const Timer& ); Timer( unsigned long millesecInterval, TimerType t = Continous ); ~Timer(); void Start();
void Ring() {OnRing( myId );}
private:
TimerSignalType OnRing; int myId; };
void Rang( int i ) { cout << "Received timer " << endl; }
main() { EventLoop *eventLoop = EventLoop::Instance(); Timer t1( 3000, Continous ); t1.TimerConnect( boost::bind( Rang, _1) ); t1.Start(); eventLoop->Exec(); }
eventLoop->Exec() start an event loop. The code always crashes when atteping to execute the connected function.
What am I doing wrong?
I see nothing wrong with the code you posted. When I added the necessary stub definitions it compiled and ran fine.
Hmm.. Then it must be a dll problem. Maybe the dll I am linking against is not compatible with the other MS dll in my build. So then, this turns into a build issue.

Ray wrote:
--- In Boost-Users@yahoogroups.com, "Peter Dimov"
wrote: I see nothing wrong with the code you posted. When I added the necessary stub definitions it compiled and ran fine.
Hmm.. Then it must be a dll problem. Maybe the dll I am linking against is not compatible with the other MS dll in my build. So then, this turns into a build issue.
Make sure you are using the multithreaded DLL runtime if using the Signals DLL. If this doesn't work, try using the static lib, libboost_signals.lib; as usual, make sure that the runtime options of the DLL and your EXE match. If this fails, try manually adding libs/signals/src/*.cpp to your project. If it still fails then it isn't a build issue and you'll need to tell us more about the error.
participants (2)
-
Peter Dimov
-
Ray