Opened 11 years ago

Closed 10 years ago

#2101 closed defect (fixed)

[PATCH] Erroneous data sent to scrollbar code.

Reported by: Josh Owned by:
Priority: Should Have Milestone: Alpha 15
Component: Core engine Keywords: patch
Cc: sanderd17 Patch:

Description (last modified by Josh)

Steps to reproduce:

  1. Make sure you have no demo maps
  2. Open the single-player gamesetup screen
  3. Set the filters to show the empty list of demo maps
  4. Change the filters
  5. View warnings

I tried to find the source of the issues, and it seems that some piece of code is setting the area available to the scrollbar to a negative number through SetLength which should never happen.

Here are the places that call that function:

gui/CList.cpp

151: GetScrollBar(0).SetLength( rect.bottom - rect.top );

gui/COList.cpp

97: GetScrollBar(0).SetLength( rect.bottom - rect.top );

gui/CInput.cpp

719: GetScrollBar(0).SetLength(m_CachedActualSize.bottom - m_CachedActualSize.top);

749: GetScrollBar(0).SetLength(0.f);

753: GetScrollBar(0).SetLength( m_CachedActualSize.bottom - m_CachedActualSize.top );

952: GetScrollBar(0).SetLength( m_CachedActualSize.bottom - m_CachedActualSize.top );

993: GetScrollBar(0).SetLength(m_CachedActualSize.bottom - m_CachedActualSize.top);

gui/CText.cpp

123: GetScrollBar(0).SetLength(m_CachedActualSize.bottom - m_CachedActualSize.top);

179: GetScrollBar(0).SetLength( m_CachedActualSize.bottom - m_CachedActualSize.top );

Alright, it appears the problem is in gui/CList.cpp

Attachments (1)

CList-fix.diff (497 bytes ) - added by Josh 11 years ago.
Check our data validity before using SetLength.

Download all attachments as: .zip

Change History (13)

comment:1 by Josh, 11 years ago

Description: modified (diff)

comment:2 by fabio, 11 years ago

This looks the same issue of #2071.

comment:3 by Josh, 11 years ago

I think this is different, the errors here are:

WARNING: Minimum scrollbar size of 4 is larger than the total scrollbar size of -24

comment:4 by historic_bruno, 11 years ago

This isn't reproducible for me if r13773 is reverted.

comment:5 by sanderd17, 11 years ago

I believe Josh added the warning to show when faulty data is being send. It looks like the faulty data has been in for a very long time, but it's only visible now thanks to r13773.

in reply to:  4 comment:6 by Josh, 11 years ago

Replying to historic_bruno:

This isn't reproducible for me if r13773 is reverted.

My changes also added some warnings if the data to some stuff was totally wrong. This was intended to help debug issues when working with the moddable GUI code, but apparently some of the existing C++ code is calculating non-sensible data that had been ignored before but now is warned about. One option would be just removing the warning and hoping the code keeps working, but that is really hacky and should be avoided. The best solution would most likely just be fixing the original bug (not even mentioning that fixing the original bug should be really easy once we identify the source).

If someone could figure out where the bad calculation originates, I would happily try to fix it.

comment:7 by Josh, 11 years ago

Description: modified (diff)

by Josh, 11 years ago

Attachment: CList-fix.diff added

Check our data validity before using SetLength.

comment:8 by Josh, 11 years ago

Keywords: patch review added
Milestone: BacklogAlpha 15
Summary: Erroneous data sent to scrollbar code.[PATCH] Erroneous data sent to scrollbar code.

comment:9 by Josh, 11 years ago

Actually, on further thought, there are valid situations during normal use where the scrollbar length could be zero (Example: Make window smaller than the smallest default resolution). So I think it would be best to remove the warning.

comment:10 by Josh, 11 years ago

Fixed in the (yet to be merged) lobby fork.

comment:11 by historic_bruno, 11 years ago

Keywords: review removed

comment:12 by wraitii, 10 years ago

Resolution: fixed
Status: newclosed

Pretty sure this is fixed now since the lobby fork has been merged and I can't reproduce the issue.

Note: See TracTickets for help on using tickets.