Icon View Thread

The following is the text of the current message along with any replies.
Messages 11 to 14 of 14 total
Thread TPaint / Canvas
Sun, May 22 2016 10:46 AMPermanent Link

Raul

Team Elevate Team Elevate

On 5/22/2016 6:36 AM, thomh wrote:
> I created a simple test application with just a form. I use this code to create some TBasicPanel controls.
> The FStartX and FStartY are just variables set in the OnMouseDown event of the form.
> I get the same error with or without assigning the .Parent property.

I suspect the issue is due to you freeing the panel while it's being
processed as sender for the event.

Tim can address as to why on framework level but one workaround i would
suggest is to use the async call to queue up the panel delete as next UI
thread event.

So something like this :

Add a new procedure DeletePanel that basically does the panel lookup by
tag and actual freeing :

procedure TForm1.DeletePanel(PanelTAG:integer);
var
   i:integer;
   c:TControl;
begin
  for i := Form1.ControlCount - 1 downto 0 do
  begin
    c := Form1.Controls[i];
    if (TControl(c) is TBasicPanel) and (TControl(c).Tag = PanelTAG) then
    begin
      TControl(c).free;
      Break;
    end;
  end;
end;

and then change the event you trigger this (i.e. mouseclick or whatever) :

  if Sender is TBasicPanel then
    async DeletePanel(TBasicPanel(Sender).Tag);



Raul
Sun, May 22 2016 12:33 PMPermanent Link

thomh

That was indeed the problem, Raul!

Thanks for your help everybody.

// Thom
Mon, May 23 2016 1:04 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Thom,

<< which results in error:

"Unable to get property 'tcomponent_fdestroying' of undefined or null reference
Line 12448" >>

Modify the WebUI unit as follows:

function TElement.TriggerEvent(ID: Integer; AElement: TElement): Boolean;
begin
  if Assigned(FController) and (not FController.Destroying) then <<<<< Changed !!!!
     begin
     if (ID=cdInput) then
        AElement.DoChanged(ecInputValueChanged);
     Result:=FController.DispatchEvent(ID,AElement);
     end
  else
     Result:=False;
end;

and let me know if that fixes the issue.

Either way, please send me a project that includes the code that you're using so that I can test it here.  This issue is one that "shouldn't occur" in a single-threaded environment, which is how the UI is running in a browser.

Tim Young
Elevate Software
www.elevatesoft.com
Tue, May 24 2016 9:47 AMPermanent Link

thomh

Tim Young [Elevate Software] wrote:

>>Modify the WebUI unit as follows:

>>function TElement.TriggerEvent(ID: Integer; AElement: TElement): Boolean;
>>begin
>>   if Assigned(FController) and (not FController.Destroying) then <<<<< Changed !!!!
>>      begin
>>     if (ID=cdInput) then
>>         AElement.DoChanged(ecInputValueChanged);
>>      Result:=FController.DispatchEvent(ID,AElement);
>>      end
>>   else
>>      Result:=False;
>>end;

Hi Tim,

Yes, this fix worked with my old code.

Thanks again.

// Thom
« Previous PagePage 2 of 2
Jump to Page:  1 2
Image