Commit f822bea0 authored by Albert Gräf's avatar Albert Gräf
Browse files

Add a global method to keep the watchdog happy while the GUI is busy.

For some reason, GUI operations which run for extended periods of time
may cause the engine to crash with a SIGHUP error on Linux. Apparently
this is caused by the watchdog bailing out and taking the engine with
it. This affects the new print operation as well as the existing message
operation in the file menu, possibly also search index generation for
the help browser, and maybe some other operations that still need to be

The new gui-busy method lets the GUI set an internal flag in the engine
which makes the engine keep the watchdog happy while the GUI does its
thing, using the same mechanism that is already in place to ping the
watchdog when running GUI-less. To these ends, the GUI needs to invoke
"pd gui-busy 1" when starting the time-consuming operation, and "pd
gui-busy 0" when the operation is done.
parent 1e52ce11
......@@ -1162,7 +1162,9 @@ exports.menu_saveas = menu_saveas;
function gui_canvas_print(name, initfile, initdir) {
// AG: We simply ignore initfile and initdir, as the print dialog will
// present its own file picker anyway if PDF output is chosen.
pdsend("pd gui-busy 1");
patchwin[name].print({ autoprint: false, headerString: initfile, footerString: path.join(initdir, initfile) });
pdsend("pd gui-busy 0");
post("printed "+initfile);
......@@ -107,6 +107,12 @@ static void glob_gui_properties(t_pd *dummy)
int sys_gui_busy;
static void glob_gui_busy(void *dummy, t_float f)
sys_gui_busy = f != 0;
// ths one lives inside g_editor so that it can access the clipboard
extern void glob_clipboard_text(t_pd *dummy, float f);
......@@ -201,6 +207,8 @@ void glob_init(void)
gensym("add-recent-file"), A_SYMBOL, 0);
class_addmethod(glob_pdobject, (t_method)glob_clear_recent_files,
gensym("clear-recent-files"), 0);
class_addmethod(glob_pdobject, (t_method)glob_gui_busy, gensym("gui-busy"),
#ifdef UNIX
class_addmethod(glob_pdobject, (t_method)glob_watchdog,
gensym("watchdog"), 0);
......@@ -312,11 +312,12 @@ static void sched_pollformeters( void)
int inclip, outclip, indb, outdb;
static int sched_nextmeterpolltime, sched_nextpingtime;
extern int sys_gui_busy;
/* if there's no GUI but we're running in "realtime", here is
where we arrange to ping the watchdog every 2 seconds. */
#if defined(__linux__) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__GNU__)
if (sys_nogui && sys_hipriority && (sched_diddsp - sched_nextpingtime > 0))
if ((sys_nogui||sys_gui_busy) && sys_hipriority && (sched_diddsp - sched_nextpingtime > 0))
/* ping every 2 seconds */
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment