From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!news.eternal-september.org!news.eternal-september.org!feeder.eternal-september.org!aioe.org!.POSTED!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: Pass a serial port as user data in a GTK callback handler? Date: Sun, 16 Feb 2014 10:20:35 +0100 Organization: cbb software GmbH Message-ID: References: Reply-To: mailbox@dmitry-kazakov.de NNTP-Posting-Host: dRN93LcgZmpMwxQ2TpSF2g.user.speranza.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org User-Agent: 40tude_Dialog/2.0.15.1 X-Notice: Filtered by postfilter v. 0.8.2 Xref: news.eternal-september.org comp.lang.ada:18602 Date: 2014-02-16T10:20:35+01:00 List-Id: 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