Signal and slot trouble
Johannes Pfau
spam at example.com
Sun Nov 21 01:47:57 PST 2010
Am 21.11.2010, 09:05 Uhr, schrieb Peter Federighi <pfederighi at yahoo.com>:
> SigWinchHandler winch;
> SigAlrmHandler alrm;
>
> // put sigaction code here
>
> sigWinchSignal.connect(&winch.handler);
> sigAlrmSignal.connect(&alrm.handler);
>
> // perhaps one of many functions I want called when a signal is raised
> class SigWinchHandler
> {
> void handler(int signal)
> {
> writeln("WINCH");
> }
> }
SigWinchHandler is a class, so you have to create instances of the class
with new. In your main function "SigWinchHandler winch;" just sets winch
to null and in the connect call you access winch.handler which causes the
crash. What you need to do is "SigWinchHandler winch = new
SigWinchHandler();" and the same for SigAlrmHandler.
--
Johannes Pfau
More information about the Digitalmars-d-learn
mailing list