[prev in list] [next in list] [prev in thread] [next in thread] 

List:       haiku-bugs
Subject:    [haiku-bugs] Re: [Haiku] #6244: BTwoDImensionalLayout::AlignWith() segfaults
From:       "yourpalal" <trac () haiku-os ! org>
Date:       2010-06-29 16:56:03
Message-ID: 053.21180be12c87f65e5147c694a1b07b40 () haiku-os ! org
[Download RAW message or body]

#6244: BTwoDImensionalLayout::AlignWith() segfaults
----------------------------------+-----------------------------------------
 Reporter:  yourpalal             |       Owner:  axeld         
     Type:  bug                   |      Status:  new           
 Priority:  normal                |   Milestone:  R1            
Component:  Kits/Interface Kit    |     Version:  R1/Development
 Keywords:  TwoDimensionalLayout  |   Blockedby:                
    Patch:  1                     |    Platform:  All           
 Blocking:                        |  
----------------------------------+-----------------------------------------

Comment(by yourpalal):

 Replying to [comment:3 bonefish]:
 > Why that would fix anything isn't obvious to me. Can you explain,
 please.
 Certainly! The problem is that with the original code, the for loop moves
 forwards through the list, 0,1,2,3... n, but for each local layouter calls
 SetCompoundLayouter. LocalLayouter::SetCompoundLayouter() calls
 CompoundLayouter::RemoveLocalLayouter(this) on the compound layouter that
 is being replaced, which then removes this LocalLayouter from its
 fLocalLayouters BList. The problem is that when you remove an item from
 index 0, all the other items get shifted down an index, so now the
 LocalLayouter that had previously been at index n is now at index n-1.
 There is nothing at index n, so the BList will return NULL when you
 request something at index n. Another solution is to always work at index
 0, and use a while (other->fLocalLayouters.CountItems() > 0). Its a bit
 hard to see at first because of the different levels of abstraction in the
 AbsorbCompoundLayouters() method.

-- 
Ticket URL: <http://dev.haiku-os.org/ticket/6244#comment:4>
Haiku <http://dev.haiku-os.org>
Haiku - the operating system.


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic