comparison gtk/dw.c @ 494:edcf9ec12f8c

Fixed a bug in the dialog system on Unix where, gtk_main() could exit when dw_dialog_wait() and dw_dialog_dismiss() were called from different threads.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Tue, 02 Dec 2003 18:40:27 +0000
parents 84e471a4ec7e
children 8267a3066476
comparison
equal deleted inserted replaced
493:84e471a4ec7e 494:edcf9ec12f8c
1097 1097
1098 tmp->eve = dw_event_new(); 1098 tmp->eve = dw_event_new();
1099 dw_event_reset(tmp->eve); 1099 dw_event_reset(tmp->eve);
1100 tmp->data = data; 1100 tmp->data = data;
1101 tmp->done = FALSE; 1101 tmp->done = FALSE;
1102 tmp->method = FALSE;
1102 tmp->result = NULL; 1103 tmp->result = NULL;
1103 1104
1104 return tmp; 1105 return tmp;
1105 } 1106 }
1106 1107
1112 * result: Data to be returned by dw_dialog_wait(). 1113 * result: Data to be returned by dw_dialog_wait().
1113 */ 1114 */
1114 int dw_dialog_dismiss(DWDialog *dialog, void *result) 1115 int dw_dialog_dismiss(DWDialog *dialog, void *result)
1115 { 1116 {
1116 dialog->result = result; 1117 dialog->result = result;
1117 if(pthread_self() == _dw_thread || _dw_thread == (pthread_t)-1) 1118 if(dialog->method)
1118 gtk_main_quit(); 1119 gtk_main_quit();
1119 else 1120 else
1120 dw_event_post(dialog->eve); 1121 dw_event_post(dialog->eve);
1121 dialog->done = TRUE; 1122 dialog->done = TRUE;
1122 return 0; 1123 return 0;
1140 newprocess = 1; 1141 newprocess = 1;
1141 gdk_threads_enter(); 1142 gdk_threads_enter();
1142 } 1143 }
1143 1144
1144 if(pthread_self() == _dw_thread) 1145 if(pthread_self() == _dw_thread)
1146 {
1147 dialog->method = TRUE;
1145 gtk_main(); 1148 gtk_main();
1149 }
1146 else 1150 else
1151 {
1152 dialog->method = FALSE;
1147 dw_event_wait(dialog->eve, -1); 1153 dw_event_wait(dialog->eve, -1);
1154 }
1148 1155
1149 if(newprocess) 1156 if(newprocess)
1150 { 1157 {
1151 _dw_thread = (pthread_t)-1; 1158 _dw_thread = (pthread_t)-1;
1152 gdk_threads_leave(); 1159 gdk_threads_leave();