Jump to content

zed

Members
  • Content Count

    24
  • Joined

  • Last visited

Everything posted by zed

  1. zed

    DelphiLint v1.0.0 released!

    https://github.com/integrated-application-development/delphilint/releases/tag/v1.0.1
  2. zed

    Opensource scripting language?

    You can provide your own functions to work with regex in lua. Its API is very flexible. Look at this for example: https://www.geek.co.il/~mooffie/mc-lua/docs/html/modules/regex.html (the implementation is quite simple: regex.c)
  3. https://stats.uptimerobot.com/3yP3quwNW/780058619
  4. zed

    docwiki.embarcadero.com is not working

    And here we go again!
  5. https://github.com/kami-soft/ProtoBufGenerator
  6. zed

    for i := X to Y inclusive... how?

    Here is the answer:
  7. zed

    for i := X to Y inclusive... how?

    It's hard to understand what exactly you want. How about this: if (X in [0..7]) and (Y in [0..7]) then begin ... end
  8. zed

    ANN: Better Translation Manager released

    No, I mean what should I do in my Test.exe to make it possible to load translations from some subfolder? I don't like idea to keep this files in the application root folder.
  9. zed

    ANN: Better Translation Manager released

    Is possible to keep translations in sub folder? .\Test\Test.exe .\Test\lang\Test.fr-FR .\Test\lang\Test.de-DE
  10. zed

    Looking for a localization tool

    +1 for dxgettext, works like a charm!
  11. There are Delphi wrappers for libcurl (for example: mormot2), so you can easily port your existing C code to Delphi.
  12. zed

    HoursBetween

    Start of the next day is the end of the current day, so you can write: var a, b: TDateTime; begin a := StrToDateTime('17:30'); b := StrToDateTime('00:00') + 1; // 24:00 WriteLn(MinutesBetween(b, a)); // 390
  13. zed

    New TForm - Defaults

    In Delphi 11 they changes default font to "Segoe UI".
  14. My wrapper: https://github.com/zedxxx/libdeflate-pas
  15. zed

    Why does the form size change? (Delphi 11)

    Delphi 11.1 also changes the Form font size: - PixelsPerInch = 96 - TextHeight = 13 + TextHeight = 15
  16. A change in TThread breaks Windows XP compatibility
  17. @vfbb How about using a lock? Try this fix: diff --git a/Unit1.pas b/Unit1.pas index e0d57a2..a27eef0 100644 --- a/Unit1.pas +++ b/Unit1.pas @@ -6,7 +6,7 @@ interface uses System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants, FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, System.Threading, - FMX.Controls.Presentation, FMX.StdCtrls; + FMX.Controls.Presentation, FMX.StdCtrls, System.SyncObjs; type ITest = interface @@ -38,6 +38,7 @@ type FThreadsPool: TArray<TThreadPool>; FTest: ITest; FTestWeak: TArray<TWeakOfTest>; + FLock: TCriticalSection; public { Public declarations } end; @@ -54,6 +55,7 @@ implementation procedure TForm1.FormCreate(Sender: TObject); begin + FLock := TCriticalSection.Create; FTestControlThreadPool := TThreadPool.Create; FTestControlTask := TTask.Run( procedure() @@ -85,17 +87,32 @@ begin begin while (not FDestroying) and (not FCanceled) do begin - LTest := Form1.FTestWeak[(Length(Form1.FTestWeak) div 2)-1].FTestWeak; // Use a weak reference that is in the middle of the list of weak references + FLock.Acquire; + try + LTest := Form1.FTestWeak[(Length(Form1.FTestWeak) div 2)-1].FTestWeak; // Use a weak reference that is in the middle of the list of weak references + finally + FLock.Release; + end; if Assigned(LTest) then // Test if the strong reference is valid, that is, theoretically verify that the object has not yet been destroyed begin LTest.Test; // Just a useless call, because if the reference still exists and the object has been destroyed, this will give an exception - LTest := nil; // Removing the strong reference + FLock.Acquire; + try + LTest := nil; // Removing the strong reference + finally + FLock.Release; + end; end; end; end, Form1.FThreadsPool[I]); end; Sleep((Random(20) + 3) * 500); // Wait all tasks run many AddRef / Release simulating a stress test - Form1.FTest := nil; // Remove the strong ref to force the object destruction (Note: we don't know what task will destroy, will be the last that remove the strong ref) + FLock.Acquire; + try + Form1.FTest := nil; // Remove the strong ref to force the object destruction (Note: we don't know what task will destroy, will be the last that remove the strong ref) + finally + FLock.Release; + end; Sleep((Random(10) + 1) * 200); // Wait some seconds to ensure the object destruction // Cancel the test, check if have error, free all objects and get ready to repeat the next test loop @@ -137,6 +154,7 @@ begin FTestControlTask.Wait; FTestControlTask := nil; FTestControlThreadPool.Free; + FLock.Free; end; { TTest } To protect your data you need to use a lock every time you assign value to the LTest and Form1.FTest.
  18. zed

    How to extend CE licence?

    @Oberon82 I have just been informed that the problem has been fixed and you can request the key as usual: https://www.embarcadero.com/products/delphi/starter/free-download/
  19. zed

    How to extend CE licence?

    And how do you propose to get a new license?
  20. zed

    How to extend CE licence?

    License extension is broken at the moment. I have reported the problem to Embarcadero (thanks Cathy Hundley), so it remains to wait while they fix the bug. By the way, exactly the same problem with license extending was a year ago...
×