Jump to content
View in the app

A better way to browse. Learn more.

FGX Native

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Hello, to search and display information about a product I have the following scenario:

- a form from where a form is opened with a preview camera and a barcode scanner component:

              FCamera: = TFCamera.Create (nil);
              FCamera.OnReadCode: = ReturnOkCodigo;
              TfgAnimationHelper.ShowForm (FCamera);


- in the form where the image is captured and scanned, I have an accept button that executes this CloseForm (true) code:

 

procedure TFCamera.CloseForm (OK: boolean);
begin
  if OK and Assigned (FOnReadCode) and (fgLabCode.Text <> '-') then FOnReadCode (fgLabCode.Text);

  TfgAnimationHelper.HideForm (Self, [TfgAnimationOption.ReleaseOnFinish]);
  FCamera: = nil;
end;


 The FOnReadCode event helps me to retrieve the code that has been read. This works fine executing like this on click button : CloseForm(true); , but if I use a configuration flag (TConfig.JO.B ['closeonread']) to close the form automatically when a barcode is identified, with this code, a memory error occurs (attach log file):

procedure TFCamera.fgBarcodeScanDetected (Sender: TObject;
  const ABarcodes: TArray <FGX.Scanner.Barcode.TfgBarcode>);
begin
 fgLabCode.Text: = ParseaCodigo (ABarcodes [0] .RawData); //. SubString (HOST_FULL.Length);
 if TConfig.JO.B ['closeonread'] then CloseForm (true) else
  begin
   TThread.ForceQueue (nil, procedure begin
    fgBarcodeScan.Active: = False;
   end);
  end;
end;

 

error_camera_scan_01.png

error_camera_scan_02.png

error_camera_preview.txt

  • Author

Hello, Delphi version is 10.4.1, ReturnOkCodigo makes a http request to a rest service to retrive product info and fill a CollectionView, but as I said  if I call by button click the code CloseForm(true) there is no problem, the problem is when is executed on fgBarcodeScanDetected event.

 

error_events.txt

  • Administrators

Besides the bugfix, please fix the logic as follows:

procedure TFCamera.CloseForm (OK: boolean);
begin
  if FCamera = nil then
    Exit;

  if OK and Assigned (FOnReadCode) and (fgLabCode.Text <> '-') then FOnReadCode (fgLabCode.Text);

  TfgAnimationHelper.HideForm (Self, [TfgAnimationOption.ReleaseOnFinish]);
  FCamera: = nil;
end;

fgBarcodeScanDetected  and TfgAnimationHelper.HideForm both are called asynchronously. 

TfgAnimationHelper.HideForm with TfgAnimationOption.ReleaseOnFinish flag should not be allowed to call more than once, otherwise it will lead to double destruction of the form and memory corruption.

 

  • Author
8 часов назад, Viktor Akselrod сказал:

Besides the bugfix, please fix the logic as follows:


procedure TFCamera.CloseForm (OK: boolean);
begin
  if FCamera = nil then
    Exit;

  if OK and Assigned (FOnReadCode) and (fgLabCode.Text <> '-') then FOnReadCode (fgLabCode.Text);

  TfgAnimationHelper.HideForm (Self, [TfgAnimationOption.ReleaseOnFinish]);
  FCamera: = nil;
end;

fgBarcodeScanDetected  and TfgAnimationHelper.HideForm both are called asynchronously. 

TfgAnimationHelper.HideForm with TfgAnimationOption.ReleaseOnFinish flag should not be allowed to call more than once, otherwise it will lead to double destruction of the form and memory corruption.

 

  Hello, thanks for you reply. Closeform is called only once, either when detecting the barcode if the automatic closing flag is set or if the accept button of the form is pressed. Anyway, I add the verification that it tells me.

  • Administrators

Hello.

TfgAnimationHelper.HideForm(Self, [TfgAnimationOption.ReleaseOnFinish]) - this call does not close immediately form.

first plays the animation, then enqueues the deletion and only then deletes the form.
during this time fgBarcodeScanDetected may fire several more times.

so it is important to prevent for double form destruction.

  • Author
12 минут назад, Viktor Akselrod сказал:

Hello.

TfgAnimationHelper.HideForm(Self, [TfgAnimationOption.ReleaseOnFinish]) - this call does not close immediately form.

first plays the animation, then enqueues the deletion and only then deletes the form.
during this time fgBarcodeScanDetected may fire several more times.

so it is important to prevent for double form destruction.

Ok, I added the check if FCamera = nil then Exit, anyway the memory problem persist, I imagine it will solved with new release, thanks.

  • 3 weeks later...

Recently Browsing 0

  • No registered users viewing this page.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.