[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Octave-bug-tracker] [bug #62343] 'zoom on' toggles instead of turning o
From: |
Rik |
Subject: |
[Octave-bug-tracker] [bug #62343] 'zoom on' toggles instead of turning on |
Date: |
Sat, 23 Apr 2022 00:02:54 -0400 (EDT) |
Follow-up Comment #4, bug #62343 (project octave):
The race condition is between the m-file zoom.m and the set___mouse_mode__
special updater in graphics.cc.
The function in graphics.cc is
figure::properties::set___mouse_mode__ (const octave_value& val_arg)
and the actual code is
if (m___mouse_mode__.set (val, true))
{
std::string mode = m___mouse_mode__.current_value ();
octave_scalar_map pm = get___pan_mode__ ().scalar_map_value ();
pm.setfield ("Enable", mode == "pan" ? "on" : "off");
set___pan_mode__ (pm);
octave_scalar_map rm = get___rotate_mode__ ().scalar_map_value ();
rm.setfield ("Enable", mode == "rotate" ? "on" : "off");
set___rotate_mode__ (rm);
octave_scalar_map zm = get___zoom_mode__ ().scalar_map_value ();
zm.setfield ("Enable", mode == "zoom" ? "on" : "off");
zm.setfield ("Direction", direction);
set___zoom_mode__ (zm);
mark_modified ();
}
If you look at the code for zoom.m it first enables the Zoom mode and then
calls update_mouse_mode
switch (option)
case {"on", "off", "xon", "yon"}
zm = get (hfig, "__zoom_mode__");
switch (option)
case {"on", "off"}
zm.Enable = option;
zm.Motion = "both";
case "xon"
zm.Enable = "on";
zm.Motion = "horizontal";
case "yon"
zm.Enable = "on";
zm.Motion = "vertical";
endswitch
set (hfig, "__zoom_mode__", zm);
update_mouse_mode (hfig, option);
Here is the code for update_mouse_mode.
function update_mouse_mode (hfig, arg)
if (strcmp (arg, "off"))
set (hfig, "__mouse_mode__", "none");
else
## Bug #62343: Need to directly turn off other graphical modes to
## avoid a race condition.
# pan (hfig, "off");
# rotate3d (hfig, "off");
set (hfig, "__mouse_mode__", "zoom");
endif
The original code had a FIXME note
## FIXME: Is there a better way other than calling these functions
## to set the other mouse mode Enable fields to "off"?
which suggests someone knew this wasn't the right way to do things.
I don't know why this is so complex and spread across three different m-files,
4 different hidden graphics properties, and one C++ special set_() routine.
My simple fix to comment out the calls to the m-files pan.m and rotate3d.m
works, but it is not clear if that is enough. Calling rotate3d ('off') does
more than just flip the "Enable" field of the structure. It also sets the
"Motion" field to "both".
This is weird because this field doesn't exist earlier. If I call
close all
gcf
get (gcf, '__rotate_mode__')
ans =
scalar structure containing the fields:
Enable = off
RotateStyle = box
FigureHandle = 1
But, then if I call rotate3d ('off') it gets a new field
rotate3d ('off')
get (gcf, '__rotate_mode__')
ans =
scalar structure containing the fields:
Enable = off
RotateStyle = box
FigureHandle = 1
Motion = both
Adding jwe to the CC list since he wrote these originally and may remember why
they are this way.
_______________________________________________________
Reply to this item at:
<https://savannah.gnu.org/bugs/?62343>
_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/