octave-bug-tracker
[Top][All Lists]
Advanced

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

[Octave-bug-tracker] [bug #60509] First initialization of graphics subsy


From: Rik
Subject: [Octave-bug-tracker] [bug #60509] First initialization of graphics subsystem switches graphics_toolkit when octave-cli used
Date: Mon, 3 May 2021 16:36:52 -0400 (EDT)
User-agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.72 Safari/537.36

Follow-up Comment #6, bug #60509 (project octave):

get_toolkit() is definitely the source of the issue.  The function is located
in gtk-manager.cc and I quote it in its entirety.


  graphics_toolkit
  gtk_manager::get_toolkit (void) const
  {
    graphics_toolkit retval;

    if (dtk.empty ())
      error ("no graphics toolkits are available!");

    auto pl = loaded_toolkits.find (dtk);

    if (pl == loaded_toolkits.end ())
      {
        auto pa = available_toolkits.find (dtk);

        if (pa == available_toolkits.end ())
          error ("default graphics toolkit '%s' is not available!",
                 dtk.c_str ());

        octave_value_list args;
        args(0) = dtk;
        feval ("graphics_toolkit", args);

        pl = loaded_toolkits.find (dtk);

        if (pl == loaded_toolkits.end ())
          error ("failed to load %s graphics toolkit", dtk.c_str ());

        retval = pl->second;
      }
    else
      retval = pl->second;

    return retval;
  }


One can see that if the default toolkit is not loaded, but is available, it
switches to the default toolkit by calling feval() to execute the m-file
"graphics_toolkit".

I checked at the interpreter immediately after starting Octave and
available_graphics_toolkits() returns { "fltk", "gnuplot" } while
loaded_graphics_toolkits() is empty.  After executing "graphics_toolkit
gnuplot" the new toolkit is listed by loaded_graphics_toolkits().  

The reason why Octave seems to work when "--no-gui" is used is that
loaded_graphics_toolkits() includes "qt" the moment Octave is started.  This
means the true branch of the if statement is not taken and feval of
"graphics_toolkit" is never called.  Just to prove that this is the correct
diagnosis, I tried


run-octave --no-gui-libs -f
__init_fltk__
graphics_toolkit gnuplot
h = figure
graphics_toolkit


This sequence works correctly because the call to __init_fltk__ creates the
entry "fltk" in loaded_graphics_toolkits and then the true branch is not
taken.



    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?60509>

_______________________________________________
  Message sent via Savannah
  https://savannah.gnu.org/




reply via email to

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