Re: Timer start registration breaks the gtk_main()
- From: Robert Pearce <rob bdt-home demon co uk>
- To: ikorot earthlink net
- Cc: gtk-list gnome org
- Subject: Re: Timer start registration breaks the gtk_main()
- Date: Sat, 26 Mar 2011 22:14:22 +0000
Hi ikorot earthlink net,
On Sat, 26 Mar 2011 11:38:27 -0700 (GMT-07:00) you wrote:
> Hi, Robert,
>
> Here is what I do:
>
> int main()
> {
> CFrame *frame = new CFrame();
> result = frame->OpenPort();
> if( !result )
> return 1;
> else
> {
> g_timer_add_seconds( 1, (GSourceFunc) frame->ReadData(), NULL );
^^^^^^^^^ ^^
> gtk_widget_show( window );
> frame->ReadData();
> gtk_main();
> }
> }
>
> in frame.h:
>
> class CFrame
> {
> void ReadData();
^^^^
> }
>
> Do you see any problems with that?
Yes. You are casting the _RESULT_ of a _CALL_ to ReadData into a GSourceFunc, but ReadData returns void. This produces utterly random results.
The second argument of g_timeout_add_seconds is a function pointer, and requires that you pass it a simple C function reference _without_ the call syntax.
Cheers,
Rob
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]