From: hreba <hreba@terra.com.br>
Subject: Re: Pass a serial port as user data in a GTK callback handler?
Date: Sun, 16 Feb 2014 13:57:42 -0300
Date: 2014-02-16T13:57:42-03:00 [thread overview]
Message-ID: <bmc5foF76avU1@mid.individual.net> (raw)
In-Reply-To: <ji9nvijji3oo$.zw7gtl9l5132.dlg@40tude.net>
On 02/16/2014 06:20 AM, Dmitry A. Kazakov wrote:
> 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.
So far I am only trying to open/close the port when the window
opens/closes, or check the availability of /dev/ttyUSB0 upon a button press.
> 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.
I think this is what I am trying right now.
> 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]
So I will be back when I have to fight with task programming in Ada, as
soon as I begin with the real communication part.
I did a fast search without finding a data structure "smart pointer" in
GObject, GLib or GTK (devhelp), only as part of the C++ language (which
I don't know). But I am using Ada. Could you give a hint/reference/link
to that?
--
Frank Hrebabetzky +55 / 48 / 3235 1106
Florianopolis, Brazil
next prev parent reply other threads:[~2014-02-16 16:57 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
2014-02-16 16:57 ` hreba [this message]
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