octave-maintainers
[Top][All Lists]
Advanced

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

Re: Approach to error() and gh_manager::unlock ()?


From: John W. Eaton
Subject: Re: Approach to error() and gh_manager::unlock ()?
Date: Mon, 21 Dec 2015 11:57:01 -0600
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Icedove/31.5.0

On 12/21/2015 11:50 AM, Rik wrote:
12/21/15

All,

In graphics.cc it appears that there are some conflicts between the new
exception based error code and the lock code for gh_manager.  See the code
below.

-- graphics.cc:10808 --
if (args.length () == 1)
   {
     caseless_str val (args(0).xstring_value ("drawnow: first argument must
be a string"));

     if (val.compare ("expose"))
       do_events = false;
     else
     {
       gh_manager::unlock ();

       error ("drawnow: invalid argument, 'expose' is only valid option");
     }
   }
-- End Code --

It appears that the code desires to release the lock it has before issuing
an error.  But this won't necessarily happen because the xstring_value()
call will directly call error () if the first argument is not a string.
There are only 10 instances of gh_manager::unlock in graphics.cc so am
asking for someone familiar with that code to review each instance and see
if the input validation needs to be recoded.  In this case, the first test
might be written as

-- New Code --
if (! args(0).is_string ())
{
   gh_manager::unlock ();

   error ("drawnow: first argument must be a string");
}

caseless_str val = args(0).string_value ();
-- End Code --

This might again be a place to use unwind_protect to perform the unlock operation as long at the unlock just needs to be performed when control is transferred out of the function's scope.

jwe





reply via email to

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