Jump to content


Photo

AV while destroying NextInspector 4


  • Please log in to reply
2 replies to this topic

#1 Markus

Markus
  • Members
  • 54 posts

Posted 10 May 2006 - 05:19 PM

Problem:

There's a problem with the latest version of NextInspector. When there's an open InplaceEditor while closing your form (destroying NextInspector) you'll get an access violation.


Cause:

In TNxCustomInspector.DoExit() there's a call to ApplyTextBox(true) to cancel editing a specific item. At the time ApplyTextBox(true) gets called the item's editor has already been destroyed by TNxPropertyItem.Destroy(). In consequence there's an access violation at the marked line.

CODE
procedure TNxCustomInspector.ApplyTextBox(Cancel: Boolean);

var

 Accept: Boolean;

begin

 // ...



 if Assigned(FEditingItem) then

 begin

   if FEditingItem.AsString <> FEditingItem.Editor.AsString then // * AV

   // ...

 end;

end;


It seems like TNxCustomInspector.FEditingItem does not get updated when the corresponding item has been deleted.

Can someone confirm/reproduce this bug?

Markus

#2 Bosko (Berg)

Bosko (Berg)
  • Members
  • 7 posts

Posted 10 May 2006 - 05:46 PM

Hello Markus,

Boki 'll review and fix it today.

Thank you.

Best regards,
Bosko
bosko@bergsoft.net , www.bergsoft.net

#3 Markus

Markus
  • Members
  • 54 posts

Posted 10 May 2006 - 06:23 PM

Hi Bosko,

thanks for your fast response.

The bug is due to an improper software design! ;-)
If you take a look at TNxCustomInspector's constructor, you'll see that NextInspector internally uses TNxPropertyItems' public OnItemChange event.

CODE
constructor TNxCustomInspector.Create(AOwner: TComponent);

begin

 // ...

 FItems.OnItemChange := DoItemChange; { catch when single item is changed }

 FItems.OnChange := DoItemsChange; { catch when Items are changed }

 // ...

end;


In my application I'm making use of the OnItemChange event myself and so I'm "overwriting" TNxInspector's DoItemsChange address with mine. Unfortunately this means that TNxInspector won't get notified by TNxPropertyItems.DoItemChange when an item is about to get destroyed (ckDestroy).

Markus




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users