MultiColumnList::setItem problem in release mode

For help with anything that CEGUI doesn't offer straight out-of-the-box, e.g.:
- Implementation of new features, such as new Core classes, widgets, WindowRenderers, etc. ...
- Modification of any existing features for specific purposes
- Integration of CEGUI in new engines or frameworks and writing of new plugins (Renderer, Parser, ...) or modules

Moderators: CEGUI MVP, CEGUI Team

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

Re: MultiColumnList::setItem problem in release mode

Postby CrazyEddie » Fri Mar 11, 2005 09:20

Okay, thanks for the update. This new informations is actually super-useful. I have a suspicion of what this might be, but I'll not say more until I have checked.

I'll definately do this today, so expect a full report later on ;)

CE.

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

Re: MultiColumnList::setItem problem in release mode

Postby CrazyEddie » Fri Mar 11, 2005 13:43

I've done some checking, and was able to reproduce the issue, getting the odd return values as described. Since the only code in that whole section is STL calls, and the problem only happens with optimisations on, I can only conclude that some part of the code is being affected by one or more of the VC++ optimisation bugs.

To work around this issue, I have split the component parts of the line out into seperate lines.

Please try the following patch, and let me know how it goes.

Code: Select all

Index: src/elements/CEGUIMultiColumnList.cpp
===================================================================
RCS file: /cvsroot/crayzedsgui/cegui_mk2/src/elements/CEGUIMultiColumnList.cpp,v
retrieving revision 1.21
diff -u -r1.21 CEGUIMultiColumnList.cpp
--- src/elements/CEGUIMultiColumnList.cpp   27 Feb 2005 14:21:22 -0000   1.21
+++ src/elements/CEGUIMultiColumnList.cpp   11 Mar 2005 13:25:59 -0000
@@ -809,8 +809,12 @@
    // if sorting is enabled, insert at an appropriate position
    if (getSortDirection() != ListHeaderSegment::None)
    {
-      // insert item and get insert position index.
-      pos = (uint)std::distance(d_grid.begin(), d_grid.insert(std::upper_bound(d_grid.begin(), d_grid.end(), row), row));
+        // calculate where the row should be inserted
+        ListItemGrid::iterator ins_pos = std::upper_bound(d_grid.begin(), d_grid.end(), row);
+        // insert item and get final inserted position.
+        ListItemGrid::iterator final_pos = d_grid.insert(ins_pos, row);
+      // get final inserted position as an uint.
+      pos = (uint)std::distance(d_grid.begin(), final_pos);
    }
    // not sorted, just stick it on the end.
    else


Thanks,

CE.

User avatar
mac
Just popping in
Just popping in
Posts: 16
Joined: Wed Jan 12, 2005 12:06

Re: MultiColumnList::setItem problem in release mode

Postby mac » Fri Mar 11, 2005 14:51

Yes it was an "over-optimisation" from visual c++. The patch works great (better than my simply turning off the optimisation for the hole function...).

Thanks a lot! You are so quick...

mac

User avatar
spannerman
Home away from home
Home away from home
Posts: 330
Joined: Wed Jan 12, 2005 12:06

Re: MultiColumnList::setItem problem in release mode

Postby spannerman » Fri Mar 11, 2005 17:44

Yes, thanks Eddie. Sorry I wasnt so helpful in the end with this...but I guess its all part of my learning how to debug properly :roll:

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

Re: MultiColumnList::setItem problem in release mode

Postby CrazyEddie » Sat Mar 12, 2005 09:52

spannerman wrote:
Yes, thanks Eddie. Sorry I wasnt so helpful in the end with this...but I guess its all part of my learning how to debug properly :roll:


Hey, no problem. It's great that you came across this in the first place, since it's pretty obscure and could have gone unnoticed for much longer than what it did.

The fix is now in CVS.

CE.


Return to “Modifications / Integrations / Customisations”

Who is online

Users browsing this forum: No registered users and 14 guests