GTK+ Forums

Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
It is currently Mon Sep 01, 2014 11:28 pm

All times are UTC




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: [SOLVED] g_timeout_add runs function only once
PostPosted: Tue Apr 01, 2008 9:00 pm 
Offline
Familiar Face

Joined: Sun Mar 09, 2008 2:16 pm
Posts: 14
Hello everybody!

I use g_timeout_add to run the following code once per second:

Code:
void update (void)
{
   FILE *output;
   // char temp[100];
   output = popen("ls", "r");
   // save output to temp char
   pclose(output);
   
   g_print ("Hello World\n");
   
   return;
}

This will (of course) print useless "Hello World"s to the command line ...
The problem is that if I uncomment line 4 I'll only get one "Hello World"! It seems that the code only gets executed once ... what's the problem with chars and g_timeout_add?

Thank you for your help!


Last edited by Zarg on Wed Apr 02, 2008 5:47 am, edited 1 time in total.

Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 02, 2008 4:02 am 
Offline
GTK+ Guru

Joined: Tue Feb 05, 2008 8:39 am
Posts: 130
update() function must be gboolean. It should return TRUE if timeout loop must be repeated. And your function returns random value that depends on register eax (on i8086) value.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 02, 2008 5:47 am 
Offline
Familiar Face

Joined: Sun Mar 09, 2008 2:16 pm
Posts: 14
Thank you!

That really helped! :)

But it's really strange that it always worked without the char declaration and never worked with it ... anyway, problem solved! :)


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group