diff --git a/src/dialogs.c b/src/dialogs.c index a42040be..02598444 100644 --- a/src/dialogs.c +++ b/src/dialogs.c @@ -31,6 +31,8 @@ * Boston, MA 02110-1301, USA. */ +#include + #include #include @@ -72,6 +74,18 @@ void oregano_error_with_title (gchar *title, gchar *msg) { GtkWidget *dialog; GString *span_msg; + pid_t tid = 0; + +#ifdef SYS_gettid + tid = syscall(SYS_gettid); +#endif + // make sure that this is running in the main thread + if (tid && (getpid() != tid)) { + OreganoTitleMsg *tm = g_malloc (sizeof (OreganoTitleMsg)); + tm->title = title; + tm->msg = msg; + g_idle_add_full (G_PRIORITY_DEFAULT_IDLE, (GSourceFunc) oregano_schedule_error_with_title, tm, NULL); + } span_msg = g_string_new (""); span_msg = g_string_append (span_msg, title); @@ -129,6 +143,19 @@ void oregano_warning_with_title (gchar *title, gchar *msg) { GtkWidget *dialog; GString *span_msg; + pid_t tid = 0; + +#ifdef SYS_gettid + tid = syscall(SYS_gettid); +#endif + // make sure that this is running in the main thread + if (tid && (getpid() != tid)) { + OreganoTitleMsg *tm = g_malloc (sizeof (OreganoTitleMsg)); + tm->title = title; + tm->msg = msg; + g_idle_add_full (G_PRIORITY_DEFAULT_IDLE, (GSourceFunc) oregano_schedule_warning_with_title, tm, NULL); + return; + } span_msg = g_string_new (""); span_msg = g_string_append (span_msg, title); diff --git a/src/engines/ngspice-analysis.c b/src/engines/ngspice-analysis.c index 7fbe83d7..e9d527b3 100644 --- a/src/engines/ngspice-analysis.c +++ b/src/engines/ngspice-analysis.c @@ -873,7 +873,7 @@ static ThreadPipe *parse_noise_analysis (NgspiceAnalysisResources *resources) tm->title = g_strdup ("Integrated Noise (V2 or A2)"); tm->msg = g_strdup_printf ("Input: %f\nOutput: %f\n", inoise, onoise); - g_idle_add_full (G_PRIORITY_DEFAULT_IDLE, (GSourceFunc) oregano_schedule_warning_with_title, tm, NULL); + oregano_warning_with_title (tm->title, tm->msg); *analysis = g_list_append (*analysis, sdata); (*num_analysis)++; @@ -1014,7 +1014,7 @@ void ngspice_analysis (NgspiceAnalysisResources *resources) NG_DEBUG ("%d buf = %s", i, *buf); if (!get_analysis_type(*buf, &analysis_type) && !noise_enabled && i == 0) { - g_idle_add_full (G_PRIORITY_DEFAULT_IDLE, (GSourceFunc) oregano_schedule_warning, "No analysis found", NULL); + oregano_warning ("No analysis found"); break; } @@ -1042,7 +1042,7 @@ void ngspice_analysis (NgspiceAnalysisResources *resources) ac_enabled = FALSE; break; default: - g_idle_add_full (G_PRIORITY_DEFAULT_IDLE, (GSourceFunc) oregano_schedule_warning, "Unexpected analysis found", NULL); + oregano_warning ("Unexpected analysis found"); unexpected_analysis_found = TRUE; break; }