comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: Pass a serial port as user data in a GTK callback handler?
Date: Sun, 16 Feb 2014 10:20:35 +0100
Date: 2014-02-16T10:20:35+01:00	[thread overview]
Message-ID: <ji9nvijji3oo$.zw7gtl9l5132.dlg@40tude.net> (raw)
In-Reply-To: bmabpcFq9c8U1@mid.individual.net

On Sat, 15 Feb 2014 21:32:58 -0200, hreba wrote:

> My actual programming exercise has a GTK GUI, and I want a callback 
> handler to communicate through a serial port, so I need to pass the port 
> in my user data, which must be of

Additionally to other responses.

There cannot be any reason to pass a stream object to GTK signal handler.
It is most certainly wrong to do any I/O from a signal handler, as it would
block the UI.

In some cases the UI may indeed be aware of I/O objects, like a COM port
configuration dialog or cancel button. In these cases there is a larger
object that contains the I/O object usually as a private member.

Specifically to GTK, you should better use smart pointers rather than raw
access types when dealing with callbacks and pass them around. The point
that UI and I/O will run in independent tasks. It is difficult to prevent
dangling pointers otherwise. [I don't consider global variables, of course]

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de

  parent reply	other threads:[~2014-02-16  9:20 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-15 23:32 Pass a serial port as user data in a GTK callback handler? hreba
2014-02-16  0:35 ` Jeffrey Carter
2014-02-16 16:18   ` hreba
2014-02-16  7:45 ` Niklas Holsti
2014-02-16 16:14   ` hreba
2014-02-16  9:20 ` Dmitry A. Kazakov [this message]
2014-02-16 16:57   ` hreba
2014-02-16 18:02     ` Dmitry A. Kazakov
2014-02-17 16:13 ` adambeneschan
2014-02-17 16:20   ` adambeneschan
2014-02-17 21:31     ` Robert A Duff
2014-02-19  0:53       ` Randy Brukardt
2014-02-19 22:22         ` Robert A Duff
2014-02-20  0:34           ` Randy Brukardt
2014-02-20 11:07             ` Simon Wright
2014-02-20 16:11             ` Robert A Duff
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox