Skip to content

Commit

Permalink
Provide a better fix for the following issue:
Browse files Browse the repository at this point in the history
drahnr#194

Reschedule interactive GUI messages internally without
requiring the use of specialised scheduling functions.
  • Loading branch information
gtrentalancia committed Jun 25, 2017
1 parent e905a24 commit 27f932e
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 3 deletions.
27 changes: 27 additions & 0 deletions src/dialogs.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
* Boston, MA 02110-1301, USA.
*/

#include <sys/syscall.h>

#include <glib/gi18n.h>
#include <gtk/gtk.h>

Expand Down Expand Up @@ -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 weight=\"bold\" size=\"large\">");
span_msg = g_string_append (span_msg, title);
Expand Down Expand Up @@ -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 weight=\"bold\" size=\"large\">");
span_msg = g_string_append (span_msg, title);
Expand Down
6 changes: 3 additions & 3 deletions src/engines/ngspice-analysis.c
Original file line number Diff line number Diff line change
Expand Up @@ -873,7 +873,7 @@ static ThreadPipe *parse_noise_analysis (NgspiceAnalysisResources *resources)
tm->title = g_strdup ("Integrated Noise (V<sup>2</sup> or A<sup>2</sup>)");
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)++;
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit 27f932e

Please sign in to comment.