GUI still hanging...



This works (kinda), but I still have to call
a gtk_button_leave() in the while loop to get
my button to pop up. The code I'm using is
the following:

   pthread_create(&rwin->tid, NULL, ftp_connect_thread, NULL);
   while(gtk_events_pending())
   {
      g_main_iteration(FALSE);
      gtk_button_leave(GTK_BUTTON(toolbar->cd_button));
   }
   pthread_join(rwin->tid, &thread_ret);

My button pops up and all now, but my GUI still hangs.
Also, in my thread, I have the next couple of lines:

      log(LOG_MISC, "Looking up host \"%s\".\n", con_host);
printf("looking\n");
      if(!(rwin->host = gethostbyname(con_host)))
      {
         printf("died\n");
         log(LOG_ERR, "Connect Error: Could not look up remote "
             "host \"%s\"! (Reason: %s)\n", con_host, strerror(errno));
         close(sockid);
         return -1;
      }

I'm getting my "looking" message printing out, but because
my GUI is still hanging, my log message isn't printed
and it keeps doing this until the gethostbyname() is done
executing.

Any idea why my GUI is still hanging? Am I missing something
here that I need to do to ensure I can click my button and
resume doing things while my thread is executing? I've seen
other programs do this so I know it's possible... Please let
me know if there are any other code snippets I need to post.
Thanks!

Chris Phelps wrote:
> 
> This ought to do it:
> 
> while(gtk_events_pending())
>    gtk_main_iteration();
> 
> Later,
> Chicane

-- 
+-----------------------------------------------------+
| Jeff "Shippy" Shipman     E-Mail: shippy@cs.nmt.edu |
| Computer Science Major    ICQ: 1786493              |
| New Mexico Institute of Mining and Technology       |
| Homepage: http://www.nmt.edu/~shippy                |
+-----------------------------------------------------+




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