[Valentina] M:M problems
Eric Forget
forgete at cafederic.com
Tue Jan 21 22:47:57 CST 2003
>> void
>> CDatabase::UpdateGroupArray()
>> {
>> FBL_BitSet *allSet;
>>
>> delete mGroupArray;
>> allSet = mGroup.SelectAllRecords();
>> mGroupArray = mGroup.Sort(allSet, mGroup.mName, true);
>>
>> delete allSet;
>>
>> if (mGroupArray != NULL) {
>>
>> mGroupArray->GetCount();
>> }
>> }
>>
>> I always crash on mGroupArray->GetCount(); ?
>>
>> If I comment out delete allSet; it doesn't crash!
>
> Hmm, no idea.
>
> Sources of AffraySet are open. Try go into GetCount and see what exactly
> crashes...
Now I know. Sort() delete allSet which make it a weird API... That's why it
crashes. For this API it may be too late (or for v2?) but you should avoid
to hide those kind of "feature". If I wanted this feature I would have
called the function SortAndDeleteSet() not Sort()... ;-)
As a rule of thumb, all implicit delete should be avoided. Even you, you've
forgot it when you've read my code... ;-)
Éric
___________________________________________________________________
Eric Forget Cafederic
ForgetE at cafederic.com <http://www.cafederic.com/>
Fingerprint <86D5 38F5 E1FD 5D9C 71C3 BAA3 797E 70A4 6210 C684>
More information about the Valentina
mailing list