RE: App doesn't quit



        Hi,

        Have you checked by replacing gtk_main_quit by kill(getpid(),
SIGTERM); ?
(=auto kill)


-----Original Message-----
From: Chi Wa Au [mailto:cau erggroup com]
Sent: Thursday 1 March 2001 09:59
To: gtk-app-devel-list gnome org
Subject: App doesn't quit


I've written the following test app:

/* gtktest.c */
#include <pthread.h>
#include <gtk/gtk.h>

static pthread_t thr;

void *BgTask(void *p)
{
    printf("Background task started\n");
    sleep(10);
    gtk_main_quit();
    printf("Background task stopped\n");
    pthread_exit(p);
}

int CreateBgTask(void)
{
    if (pthread_create(&thr, NULL, BgTask, NULL) != 0) {
        printf("Cannot create background task\n");
        return -1;
    }
    return 0;
}

gint deleteCb(GtkWidget *widget, GdkEvent *event, gpointer data)
{
    gtk_main_quit();
    return FALSE;
}

gint destroyCb(GtkWidget *widget, GdkEvent *event, gpointer data)
{
    gtk_main_quit();
    return 0;
}

int main(int argc, char *argv[])
{
    GtkWidget *win;

    gtk_init(&argc, &argv);

    win = gtk_window_new(GTK_WINDOW_TOPLEVEL);
    gtk_signal_connect(GTK_OBJECT(win), "delete_event",
GTK_SIGNAL_FUNC(deleteCb), NULL);
    gtk_signal_connect(GTK_OBJECT(win), "destroy",
GTK_SIGNAL_FUNC(destroyCb), NULL);
    gtk_widget_show(win);

    CreateBgTask();

    gtk_main();

    return 0;
}
/* end of file */

I executed the app and expected the app to be terminated after around 10
seconds.  But it did not.

However, when I pressed a key or moved the cursor over the app window, the
app was terminated normally.

It seems like that the call to gtk_main_quit() in BgTask() cannot quit the
app until there is event sent to the app.

Can anyone tell me why?

Is there any way to quit the app without pressing the 'exit' button of the
app window?

Regards,
Au Chi Wa
ERG HK


**** DISCLAIMER **** 
"This e-mail and any attachments thereto may contain information 
which is confidential and/or protected by intellectual property 
rights and are intended for the sole use of the recipient(s) named above. 
Any use of the information contained herein (including, but not limited to, 
total or partial reproduction, communication or distribution in any form) 
by persons other than the designated recipient(s) is prohibited. 
If you have received this e-mail in error, please notify the sender either 
by telephone or by e-mail and delete the material from any computer. 
Thank you for your cooperation."





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