home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!usc!zaphod.mps.ohio-state.edu!uwm.edu!spool.mu.edu!agate!stanford.edu!apple!applelink.apple.com
- From: GER.XSE0039@AppleLink.Apple.COM (Germany - C Brinkschulte Berlin,IDV)
- Newsgroups: comp.sys.mac.oop.macapp3
- Subject: Bug In TDynamicArray (MA3.0.1)
- Message-ID: <724440372.3097661@AppleLink.Apple.COM>
- Date: 15 Dec 92 17:19:00 GMT
- Sender: daemon@Apple.COM
- Organization: AppleLink Gateway
- Lines: 42
-
- Hi, MacAppers,
-
- There is a Bug in MacApp 3.0.1 in the class "TDynamicArray".
-
- The problem arises when a TDynamicArray is cloned while an Iterator which was
- used for the TDynamicArray is stil in scope. TDynamicArray has a field named
- fIteratorPtr, which contains a linked list of Iterators currently in use for
- the TDynamicArray. When a TDynamicArray gets cloned, both (the old and the
- cloned Array's) fIteratorPtrs point to the same Iterator. If the CArrayIterator
- is destructed, the fIteratorPtr of the cloned TDynamicArray points to an
- invalid Memory-Address.
-
- The solution is to override TObject::Clone in TDynamicArray and set the
- fIteratorPtr-field of the cloned Array
- to NULL.
-
- TObject* TDynamicArray::Clone () // override
- {
- TDynamicArray* clonedArray = (TDynamicArray*) inherited:Clone ();
- clonedArray->fIteratorPtr = NULL;
- return clonedArray;
- }
-
- A Workaround is to manually set the fIteratorPtr of the CDynamicArray to NULL
- after cloning a TDynamicArray.
-
- TDynamicArray* aDynamicArray = new TDynamicArray;
- aDynamicArray->IDynamicArray (0, sizeof (myStruct));
-
- [...]
-
- TDynamicArray* clonedArray = aDynamicArray->Clone ();
- clonedArray->fIteratorPtr = NULL;
-
-
- I am not part of MacAppTech$ anymore, because it has flooded my In-Box too
- much, so please send a copy of any replys directly to me (thanks).
-
-
- Carsten Brinkschulte
- GER.XSE0039
-
-