bug-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[bug #25612] NSMatrix Segmentation Fault when clicking a cell


From: Fred Kiefer
Subject: [bug #25612] NSMatrix Segmentation Fault when clicking a cell
Date: Wed, 18 Feb 2009 08:27:09 +0000
User-agent: Mozilla/5.0 (compatible; Konqueror/3.5; Linux) KHTML/3.5.10 (like Gecko) SUSE

Follow-up Comment #3, bug #25612 (project gnustep):

Your change highlights the similarities between the code in the two methods
_selectCell:atRow:column: and setState:atRow:column:. These methods surely
should share more code as in some cases they do almost the same thing.

I would say that your patch works around the current problem, we wont have a
segmentation fault any more, but the internal inconsistency still exists for
some time (From the NIB loading until the mouse down). The problem with this
approach is that we may just face the same issue in other places and when we
start to protect all of them from this inconsistency our code may get
cluttered.

For this reason I would prefere to stick with the current invariant:

((_selectedCell == nil) && (_selectedRow == -1) && (_selectedColumn == -1))
||
(_selectedCell == [self cellAtRow: _selectedRow column: _selectedColumn])

This condition will be implicitly true after any of the methods on NSMatrix
has run. (And apart from the init methods also before all methods)

The code you changed was correct. The _selectCell:atRow:column: already
checked that _selectedCell isn't nil so it "knows" that _selectedRow and
_selectedColumn aren't nil!

What we have to guarranty in our code is that this invariant is really valid
all the time and the only possible violation I found was in initWithCoder:, so
we need to fix that. With the original NIB file at hand it would be easy to
see what is going wrong here. Without it we just need to make sure we handle
every possible case correctly. This is best done by calling
selectCellAtRow:column: from initWithCoder: with the values read from the NIB
file.



    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?25612>

_______________________________________________
  Nachricht geschickt von/durch Savannah
  http://savannah.gnu.org/





reply via email to

[Prev in Thread] Current Thread [Next in Thread]