Fixed dealloc so that it can dealloc a layout manager which has not been

-init


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@12484 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Nicola Pero 2002-02-11 02:42:12 +00:00
parent 8e7bfb06a7
commit 90f3074971

View file

@ -585,7 +585,9 @@ _Sane(NSLayoutManager *lm)
*/
- (id) init
{
if ([super init] != nil)
self = [super init];
if (self != nil)
{
GSIArray a;
@ -603,7 +605,7 @@ _Sane(NSLayoutManager *lm)
GSIArrayInsertItem(glyphChunks, (GSIArrayItem)_currentGlyphs, 0);
_chunkIndex = 0;
_glyphIndex = 0;
/*
* Initialise storage of gaps in the glyph stream.
* The initial glyph stream is one big gap starting at index 0!
@ -621,24 +623,34 @@ _Sane(NSLayoutManager *lm)
{
unsigned i;
/*
* Release all glyph chunk information
/* We check that the _glyphData and _glyphGaps are not NULL so that
* we can dealloc an object which has not been -init (some
* regression tests need it).
*/
i = GSIArrayCount(glyphChunks);
while (i-- > 0)
/*
* Release all glyph chunk information.
*/
if (_glyphData != NULL)
{
GSGlyphChunk *chunk;
chunk = (GSGlyphChunk*)(GSIArrayItemAtIndex(glyphChunks, i).ptr);
GSDestroyGlyphChunk(chunk);
i = GSIArrayCount(glyphChunks);
while (i-- > 0)
{
GSGlyphChunk *chunk;
chunk = (GSGlyphChunk*)(GSIArrayItemAtIndex(glyphChunks, i).ptr);
GSDestroyGlyphChunk(chunk);
}
GSIArrayEmpty(glyphChunks);
NSZoneFree(NSDefaultMallocZone(), _glyphData);
}
GSIArrayEmpty(glyphChunks);
NSZoneFree(NSDefaultMallocZone(), _glyphData);
_glyphData = 0;
GSIArrayEmpty((GSIArray)_glyphGaps);
NSZoneFree(NSDefaultMallocZone(), _glyphGaps);
if (_glyphGaps != NULL)
{
GSIArrayEmpty((GSIArray)_glyphGaps);
NSZoneFree(NSDefaultMallocZone(), _glyphGaps);
}
RELEASE (_textContainers);
[super dealloc];