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

Fix the findbox regression, part 2.

This gets rid of some race conditions in the find operation, by ensuring
that edit mode is only updated *after* mapping a subpatch window.

This bug manifested itself when searching for objects in subpatches
which are not visible at the time the find operation gets invoked. In
this case, on the GUI side we both have to create the subpatch window
and put it in edit mode. In the previous implementation these two
operations would be executed separately and asynchronously. The end
result was that usually the latter operation setting the edit mode in
the GUI would win out, and the edit mode would later get overwritten
again when the window was created.

We fixed that race condition by ensuring that the engine is queried for
its current edit mode status after creating a canvas window. The engine
replies with a call to gui_canvas_set_editmode() in the GUI and thus the
edit mode in the GUI now properly reflects the status in the engine
after a window is mapped.

TL;DR: This fix should now make sure that edit mode on the GUI side
reflects that of the engine at all times.
parent df2fd7fd
......@@ -1323,7 +1323,7 @@ function register_window_id(cid, attr_array) {
// Initialize the zoom level to the value retrieved from the patch, if any.
nw.Window.get().zoomLevel = attr_array.zoom;
pdgui.canvas_map(cid); // side-effect: triggers gui_canvas_get_scroll
pdgui.canvas_set_editmode(cid, attr_array.editmode);
pdgui.canvas_query_editmode(cid);
// For now, there is no way for the cord inspector to be turned on by
// default. But if this changes we need to set its menu item checkbox
// accordingly here
......
......@@ -1302,6 +1302,13 @@ function gui_canvas_set_editmode(cid, state) {
canvas_set_editmode(cid, state);
}
// ask the engine about the current edit mode
function canvas_query_editmode(cid) {
pdsend(cid, "query-editmode");
}
exports.canvas_query_editmode = canvas_query_editmode;
function update_grid(grid) {
// Update the grid background of all canvas windows when the corresponding
// option in the gui prefs changes.
......
......@@ -2717,6 +2717,8 @@ void g_canvas_setup(void)
gensym("vis"), A_FLOAT, A_NULL);
class_addmethod(canvas_class, (t_method)glist_menu_open,
gensym("menu-open"), A_NULL);
class_addmethod(canvas_class, (t_method)canvas_query_editmode,
gensym("query-editmode"), A_NULL);
class_addmethod(canvas_class, (t_method)canvas_map,
gensym("map"), A_FLOAT, A_NULL);
class_addmethod(canvas_class, (t_method)canvas_dirty,
......
......@@ -564,6 +564,7 @@ EXTERN void canvas_resortoutlets(t_canvas *x);
EXTERN void canvas_free(t_canvas *x);
EXTERN void canvas_updatewindowlist( void);
EXTERN void canvas_editmode(t_canvas *x, t_floatarg yesplease);
EXTERN void canvas_query_editmode(t_canvas *x);
EXTERN int canvas_isabstraction(t_canvas *x);
EXTERN int canvas_istable(t_canvas *x);
EXTERN int canvas_showtext(t_canvas *x);
......
......@@ -8049,6 +8049,14 @@ void canvas_editmode(t_canvas *x, t_floatarg fyesplease)
}
}
void canvas_query_editmode(t_canvas *x)
{
int edit = /*!glob_ctrl && */x->gl_edit;
gui_vmess("gui_canvas_set_editmode", "xi",
glist_getcanvas(x),
edit);
}
// jsarlo
void canvas_magicglass(t_canvas *x, t_floatarg fyesplease)
{
......
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