Running the main loop in a separate thread
- From: Petko <pditchev gmail com>
- To: gtkmm-list gnome org
- Subject: Running the main loop in a separate thread
- Date: Sat, 08 Sep 2012 00:06:51 +0300
Hello everyone , I hope the topic isn't reposted too much . I've been
on it for about 3 hours now and Google doesn't seem to point to much info .
Briefly put - I have a GLUT app that I want to use gtkmm windows with
(for input/other dialogues) . I thought I can just run the GTKmm main
loop in a separate thread , but that turned out not to work properly .
So firstly - is the concept flawed , or should I refine my code till
it works ? At the moment I can run the gtkmm window in a separate thread
(the main loop that is) , but upon ending the thread (or closing the
window via X or the window.hide() function) the window hangs (and
doesn't get cleaned off the screen). The thread however (I think) closes
properly , and my guess was that that would destroy the window but what
do I know..
Here's the code for gtkmm . On keypress the GLUT window calls
get_new_note in a new thread. The GTKmm application and widgets are global.
Note *AddNote(char *text){
notes.broi++; //broi==count in bulgarian
notes.n[notes.broi] = new Note;
notes.n[notes.broi]->text = g_strdup(text);
return notes.n[notes.broi];
}
void *get_new_note(void*id){
app->run(*new_note_window);
delete new_note_window;
return 0;
}
void new_note_input_done(){
const char *text;
text=note_text->get_text().c_str();
d((char *)text);
AddNote((char*)text);
new_note_window->hide(); //stuff I tried prior to hide:
new_note_window->unset_application();//sigc::hide(new_note_window);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]