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

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

[Octave-bug-tracker] [bug #53443] Variable Editor: openvar VAR should sh


From: Dan Sebald
Subject: [Octave-bug-tracker] [bug #53443] Variable Editor: openvar VAR should show the tab on which the variable editor is
Date: Mon, 9 Apr 2018 03:11:14 -0400 (EDT)
User-agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:55.0) Gecko/20100101 Firefox/55.0

Follow-up Comment #14, bug #53443 (project octave):

Ah, one level directory deeper than libgui/src/.  I probably didn't grep that
far down.

It's not necessarily true that the tabData() pointer usage should be the same.
 In the changeset I attached in Comment #11, neither the tabData information
nor the "this" pointer is used as a pointer for referencing data or a
function; it's merely a comparison of unique numbers.  As I see it, this is a
more legitimate use of such variables than is the static_cast<>.

The problem with static_cast used as an actual pointer is that it sort of
promotes programming outside the framework's concept.  That is, if we have
pointers and such, one starts programming the way they would with conventional
C++.  But if one avoids the casting, then it requires some thought and
redesign using Qt's features of signals/slots, virtual functions, etc.

For example in this function:


01  void webinfo::current_tab_changed (int index)
02  {
03    QVariant tab_data = _tab_bar->tabData (index);
04    _text_browser = static_cast<QTextBrowser *> (tab_data.value<void*> ());
05
06    _stacked_widget->setCurrentIndex (_stacked_widget->indexOf
(_text_browser));
07
08    if (_text_browser->font () != _font_web)
09      _text_browser->setFont (_font_web);
10
11    tab_state_changed ();
12  }


there really should be a check on index because it can be -1 if there are no
widgets in the QTabBar.  If that were the case, then there'd be either
out-of-range seg fault or a bad pointer seg fault.  And why the step of
setting the QStackedWidget index?  Doesn't that information come from the
QTabBar itself?  I.e., it's telling use what became the current widget.  And
the possible change of font: here the _text_browser is being used like a
pointer, but I wonder why the need to do this font change rather than doing so
at the point the QTextBrowser is created.

    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?53443>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/




reply via email to

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