Opened 5 years ago

Closed 4 months ago

#14856 closed defect (fixed)

Streamline wxALWAYS_SHOW_SB handling in wxScrolled::Create()

Reported by: Mdx4 Owned by: vadz
Priority: low Milestone:
Component: wxOSX Version: stable-latest
Keywords: wxScrolledWindow wxALWAYS_SHOW_SB Cc:
Blocked By: Blocking:
Patch: no

Description (last modified by vadz)

If you use wxScrolledWindow with the wxALWAYS_SHOW_SB flag this leads to crash in initialization.

Probably could be related with "wxScrolled<> does not disable scrollbars when wxALWAYS_SHOW_SB is used" ?

GetClientSize is called too early and GetPeer() returns NULL.

How to reproduce it:

  • samples/caret/caret.cpp

    306306MyCanvas::MyCanvas( wxWindow *parent )
    307307        : wxScrolledWindow( parent, wxID_ANY,
    308308                            wxDefaultPosition, wxDefaultSize,
    309                             wxSUNKEN_BORDER )
     309                            wxSUNKEN_BORDER |  wxALWAYS_SHOW_SB )
    311311    m_text = (wxChar *)NULL;

Change History (5)

comment:1 Changed 5 years ago by csomor

  • Status changed from new to infoneeded_new

Vadim: can we just invert the order of Create and SetScrollbar ? I'll commit a fix for OSX but if it can be done for all platforms without issues, I'd favor that, I don't understand why MSW does not trigger either

comment:2 Changed 5 years ago by SC

(In [73041]) workaround, see #14856

comment:3 Changed 5 years ago by vadz

  • Priority changed from normal to low
  • Status changed from infoneeded_new to new
  • Summary changed from OSX: wxScrolledWindow & wxALWAYS_SHOW_SB leads to crash in constructor to Streamline wxALWAYS_SHOW_SB handling in wxScrolled::Create()

Actually, is ShowScrollbars() call needed at all? In wxGTK and wxMSW it almost surely isn't because wxWindow already respects wxALWAYS_SHOW_SB.

comment:4 Changed 4 months ago by vadz

  • Description modified (diff)
  • Owner set to vadz
  • Status changed from new to accepted

comment:5 Changed 4 months ago by Vadim Zeitlin <vadim@…>

  • Resolution set to fixed
  • Status changed from accepted to closed

In 27c399adb/git-wxWidgets:

Remove wxALWAYS_SHOW_SB-related code from wxScrolled

There is no need to handle this style specially here, it's supposed to
be handled at wxWindow level and is, indeed, at least in all the major

So revert 2119b213e378d69b8d13f4c8f6012b3aa381efe9 (see #13616) and the
workaround for it applied later for macOS (see #14856). And this also
removes the need for handling wx[HV]SCROLL in wxScrolled (see #17846).

Closes #14856, #17846.

Note: See TracTickets for help on using tickets.