octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Updaters and default property values


From: Rik
Subject: Re: Updaters and default property values
Date: Mon, 12 Mar 2012 10:08:28 -0700

On 03/12/2012 08:48 AM, Ben Abbott wrote:
> On Mar 12, 2012, at 10:10 AM, Michael Goffioul wrote:
>
>> On Mon, Mar 12, 2012 at 2:04 PM, Ben Abbott <address@hidden> wrote:
>>
>>> On Mar 12, 2012, at 5:41 AM, Michael Goffioul wrote:
>>>
>>>> On Mon, Mar 12, 2012 at 1:48 AM, Ben Abbott <address@hidden> wrote:
>>>>> Rik,
>>>>>
>>>>> I just realized the images produced for the docs are modifying the default paperorientation to "landscape". The entire sequence is ...
>>>>>
>>>>> function set_print_size ()
>>>>> image_size = [5.0, 3.5];
>>>>> border = 0;
>>>>> set (0, "defaultfigurepapertype", "<custom>");
>>>>> set (0, "defaultfigurepaperorientation", "landscape");
>>>>> set (0, "defaultfigurepapersize", image_size + 2*border);
>>>>> set (0, "defaultfigurepaperposition", [border, border, image_size]);
>>>>> endfunction
>>>>>
>>>>> And when the defaults are populated into a new figure the updating of the property values are not working as intended.
>>>>>
>>>>> This is causing the images for the figures to be rotated and cropped.
>>>>>
>>>>> I'm unfamiliar with how the initialization of an objects properties works.
>>>>>
>>>>> Can someone explain the process to me, or point me to code that does this?
>>>>
>>>> This is achieved in base_properties::set_from_list. This ends up
>>>> calling base_graphics_object::set, which will should end up calling
>>>> set_<property>.
>>>>
>>>> Michael.
>>>
>>> I took a quick look. I think I'm following the part below
>>>
>>> graphics.cc (base_properties::set_from_list)
>>>
>>> But I don't see where base_graphics_object::set is defined.
>>
>> In the auto-generated graphics-prop.cc file.
>
> Do you mean to refer to base_properties::set() ?
>
>>> In any event, set_<property>() should call the updaters correct ?

3/12/12

Ben, Michael,

We should put some thought into how to address this issue.  The interaction between default properties and functions with updaters is already broken.  See this bug report (https://savannah.gnu.org/bugs/?35662).

Briefly, Octave does traverse down through the C++ code and eventually calls set_<property>() for each default.  However, at the time the code is called the axes are not completely set up and therefore the update_<property> functions can fail when they rely on a second property which has not yet been initialized.  A second issue is that I don't believe there is any guaranteed order of execution for the default properties.  Even though the defaults may have been coded in the order 1,2,3 in an m-file the actual routines could be called in the order 2,1,3 or whatever.

This sort of Catch-22 seems like a common coding problem and maybe there is a common solution to apply in this regard.

My thought had been to preserve the set functionality of set property but disable updaters while initializing an axis (or figure).  For example, the code of an average set_<property> function WITH an updater looks like this

void set_<property> (const octave_value& val)
{
  if (! error_state)
    {
      if (<property>.set (val, true))
        {
          update_<property> ();
          mark_modified ();
        }
    }
}

I was thinking of modifying the if conditional to

if (<property>.set (val, true) && ! init_axes)

where init_axes would choke off the further call to update_<property>.

Is there a better way?

--Rik


reply via email to

[Prev in Thread] Current Thread [Next in Thread]