v1.7.8 main_panel.cpp:471:28 compile error on WxWidgets > 3 because SetVirtualSizeHints deprecated

Talk about building the software from source code, and any issues related.

Moderator: jesse

Post Reply
ericfont
Posts: 36
Joined: Fri Jun 25, 2021 11:08 am

v1.7.8 main_panel.cpp:471:28 compile error on WxWidgets > 3 because SetVirtualSizeHints deprecated

Post by ericfont »

Code: Select all

main_panel.cpp: In member function ‘void SooperLooperGui::MainPanel::init_loopers(int)’:
main_panel.cpp:471:28: error: ‘class wxScrolledWindow’ has no member named ‘SetVirtualSizeHints’; did you mean ‘SetVirtualSize’?
  471 |                 _scroller->SetVirtualSizeHints (bestsz.GetWidth(), -1);
      |                            ^~~~~~~~~~~~~~~~~~~
      |                            SetVirtualSize
the README.md says "wxWidgets -- It should work with the 2.6.x, 2.8, or 3.x versions."

I look at https://docs.wxwidgets.org/3.0/deprecated.html and see:
Member wxSizer::SetVirtualSizeHints (wxWindow *window)
This is exactly the same as FitInside() in wxWidgets 2.9 and later, please replace calls to it with FitInside().
attached is my autogen, configure, and make log.
Attachments
sooper-looper-compile-error-setvirtualsizehints.txt
(84.45 KiB) Downloaded 226 times

ericfont
Posts: 36
Joined: Fri Jun 25, 2021 11:08 am

Re: v1.7.8 main_panel.cpp:471:28 compile error on WxWidgets > 3 because SetVirtualSizeHints deprecated

Post by ericfont »

just googling and found https://docs.wxwidgets.org/3.0/classwx_scrolled.html which has written:
The most automatic and newest way is to simply let sizers determine the scrolling area. This is now the default when you set an interior sizer into a wxScrolled with wxWindow::SetSizer(). The scrolling area will be set to the size requested by the sizer and the scrollbars will be assigned for each orientation according to the need for them and the scrolling increment set by SetScrollRate(). As above, scrolling is only enabled in orientations with a non-zero increment. You can influence the minimum size of the scrolled area controlled by a sizer by calling wxWindow::SetVirtualSizeHints(). (Calling SetScrollbars() has analogous effects in wxWidgets 2.4 – in later versions it may not continue to override the sizer.)

Note that if maximum size hints are still supported by wxWindow::SetVirtualSizeHints(), use them at your own dire risk. They may or may not have been removed for 2.4, but it really only makes sense to set minimum size hints here. We should probably replace wxWindow::SetVirtualSizeHints() with wxWindow::SetMinVirtualSize() or similar and remove it entirely in future.

Todo:
review docs for this class replacing SetVirtualSizeHints() with SetMinClientSize().
I don't know if that is relevant. I'm going to poke around and see if using SetMinVirtualSize() or SetMinClientSize() works.

ericfont
Posts: 36
Joined: Fri Jun 25, 2021 11:08 am

Re: v1.7.8 main_panel.cpp:471:28 compile error on WxWidgets > 3 because SetVirtualSizeHints deprecated

Post by ericfont »

well changing that line 471 from

Code: Select all

_scroller->SetVirtualSizeHints (bestsz.GetWidth(), -1);
to

Code: Select all

_scroller->SetMinClientSize (bestsz);
seems to result in main_panel.cpp compiling. Though I see there is at least one more file which has that same issue:

Code: Select all

check_box.cpp: In constructor ‘SooperLooperGui::CheckBox::CheckBox(wxWindow*, wxWindowID, const wxString&, bool, const wxPoint&, const wxSize&)’:
check_box.cpp:94:9: error: ‘SetVirtualSizeHints’ was not declared in this scope; did you mean ‘SetVirtualSize’?
   94 |         SetVirtualSizeHints (6 + _boxsize + w, max(_boxsize, h));
      |         ^~~~~~~~~~~~~~~~~~~
      |         SetVirtualSize
check_box.cpp: In member function ‘void SooperLooperGui::CheckBox::set_label(const wxString&)’:
check_box.cpp:137:9: error: ‘SetVirtualSizeHints’ was not declared in this scope; did you mean ‘SetVirtualSize’?
  137 |         SetVirtualSizeHints (6 + _boxsize + w, max(_boxsize, h));
      |         ^~~~~~~~~~~~~~~~~~~
      |         SetVirtualSize

ericfont
Posts: 36
Joined: Fri Jun 25, 2021 11:08 am

Re: v1.7.8 main_panel.cpp:471:28 compile error on WxWidgets > 3 because SetVirtualSizeHints deprecated

Post by ericfont »

I'm also found via google that someone else tried to compile sooperlooper and experienced a similar issue: "SetVirtualSizeHints (deprecated) and FitInside" (https://forums.wxwidgets.org/viewtopic.php?f=1&t=46597) and they mentioned a workaround to turn that error into a deprecation warning by using --enable-compat28:
"I reconfigured wxWindows to add --enable-compat28 and I am not getting the error any more, just the deprecation warning."

ericfont
Posts: 36
Joined: Fri Jun 25, 2021 11:08 am

Re: v1.7.8 main_panel.cpp:471:28 compile error on WxWidgets > 3 because SetVirtualSizeHints deprecated

Post by ericfont »

I am noting that the line main_panel.cpp:471 comes from a
commit 16 years ago: https://github.com/essej/sooperlooper/b ... l.cpp#L398

and check_box.cpp:94 comes from the first commit of that file 16 years ago: https://github.com/essej/sooperlooper/b ... ox.cpp#L81

and same for check_box.cpp:137 https://github.com/essej/sooperlooper/b ... x.cpp#L111

ericfont
Posts: 36
Joined: Fri Jun 25, 2021 11:08 am

Re: v1.7.8 main_panel.cpp:471:28 compile error on WxWidgets > 3 because SetVirtualSizeHints deprecated

Post by ericfont »

well simply deleting the lines check_box.cpp:94 and check_box.cpp:137 results in compilation completing. I have absolutely no idea whether that is a good way to go about this cause I'm not familiar with wxwidgets...

ericfont
Posts: 36
Joined: Fri Jun 25, 2021 11:08 am

Re: v1.7.8 main_panel.cpp:471:28 compile error on WxWidgets > 3 because SetVirtualSizeHints deprecated

Post by ericfont »

well slgui runs and I don't notice anything off...though to be honest I wouldn't know what to look for beingoff, cause I'm not familar with your code or wxwidgets...

ericfont
Posts: 36
Joined: Fri Jun 25, 2021 11:08 am

Re: v1.7.8 main_panel.cpp:471:28 compile error on WxWidgets > 3 because SetVirtualSizeHints deprecated

Post by ericfont »

I did make a pull request...again this is my first time looking at wxwidgets so maybe I don't know what I'm doing: https://github.com/essej/sooperlooper/pull/16

ericfont
Posts: 36
Joined: Fri Jun 25, 2021 11:08 am

Re: v1.7.8 main_panel.cpp:471:28 compile error on WxWidgets > 3 because SetVirtualSizeHints deprecated

Post by ericfont »

looking at https://docs.wxwidgets.org/3.0/classwx_ ... 9e319e35e3 the description of "wxWindow::GetBestSize()" starts with:
This functions returns the best acceptable minimal size for the window."
So it sounds like to me on first reading that that would be an appropriate size to call _scroller->SetMinClientSize() with.


Post Reply