Re: Timer start registration breaks the gtk_main()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Robert,


-----Original Message-----
>From: Robert Pearce <rob@xxxxxxxxxxxxxxxxxxxx>
>Sent: Mar 26, 2011 3:14 PM
>To: ikorot@xxxxxxxxxxxxx
>Cc: gtk-list@xxxxxxxxx
>Subject: Re: Timer start registration breaks the gtk_main()
>
>Hi ikorot@xxxxxxxxxxxxx,
>
>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.

Yes, I believe I made a mistake here. I was not in front of my developmental machine,
so...
I think the ReadData() is returning gboolean.

Thank you.

>
>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

_______________________________________________
gtk-list mailing list
gtk-list@xxxxxxxxx
http://mail.gnome.org/mailman/listinfo/gtk-list


[Index of Archives]     [Touch Screen Library]     [GIMP Users]     [Gnome]     [KDE]     [Yosemite News]     [Steve's Art]

  Powered by Linux