Jump to content

Jacek Laskowski

Members
  • Content Count

    267
  • Joined

  • Last visited

  • Days Won

    2

Posts posted by Jacek Laskowski


  1. Okay, I didn't know that Invalidate() would send a separate wm_paint message. It changes a lot.


    Sending a message from the work thread to the main one was an idea to communicate with the main thread, one of the possible ones. But actually the timer will be better. The data is already written to the appropriate structure, and it is enough to read and draw it periodically.

    Thank you all for your comments.


  2. 33 minutes ago, David Heffernan said:

    Dude, it was you that wanted to have the worker thread notify the main thread! That's literally what you asked in the OP. 

    There is a big difference between notifying the main thread about the event and calling the drawing method in the main thread (from working thread). In the first case I can decide what I will do, I can even do nothing, in the second case drawing will ALWAYS be forced.


  3. 4 hours ago, David Heffernan said:

    You'd have to post the message to the parent. But why bother. Just use TThread.Queue.  

    Calling Queue from the thread is a bad idea here. There are several threads, each of them processes some data, and one visual control displays them. If each thread is forcing a refresh, it will be a heavy load. And if the light gets messages, even from a few threads, it will decide how to refresh itself.

     

    ps. How to handle the message the parent got? I don't know who the parent will be?


  4. 6 hours ago, Vincent Parrett said:

    Or avoid Synchronize and send custom message to the control using PostMessage(control.handle,...) and call invalidate in the message handler. 

    Thanks, this idea seems interesting to me, because it focuses drawing in one place (several threads can add data). But there is a problem. The control inheriting from TPaintBox does not have Handle.

    How to get around it?


  5. On 5/20/2020 at 9:19 PM, Attila Kovacs said:

    you have to edit VTV sources and before every DrawText(W) do a

    DrawFormat := DrawFormat or DT_EXPANDTABS or DT_TABSTOPS;

    DrawFormat := DrawFormat or (FTabwidth shl 8);

    and you can create a property of FTabwidth, (plus one for Expandtabs yes/no).

     

    Thanks, this works!


  6. Is possible to send message to PaintBox?

    PaintBox inherits from TGraphicControl:

     

      TGraphicControl = class(TControl)
      private
        FCanvas: TCanvas;
        procedure WMPaint(var Message: TWMPaint); message WM_PAINT;
      protected
        procedure Paint; virtual;
        property Canvas: TCanvas read FCanvas;
      public
        constructor Create(AOwner: TComponent); override;
        destructor Destroy; override;
      end;
    

    As can be seen TGraphicControl receives a WM_PAINT message. But how to send it? Where to get the handle for the control? I need to notify the TPaintBox control of the need to repain from the worker thread.


  7. 8 minutes ago, Pierre le Riche said:

    Yes, the CFastMM_StackTraceEntryCount constant. If there is a big demand for it I could make it adjustable, but v5 is already approaching double the number of entries of v4 so I reckon it should be sufficient.

    I've got a callstack in FastMM4 set to 25, because that's the value that didn't cut off my log.


  8. 27 minutes ago, Fred Ahrens said:

    My brain would detect this as an error while reading the code. I always expect to see in the source code the characters I did type and not the characters the IDE "thinks" might look better.

    Try to work with JS in the VSC editor, you will quickly change your mind.

    • Like 1

  9. 1 minute ago, Stefan Glienke said:

    As far as I know the editor control does not support ligatures 

    It just handles, only in specific situations, so I asked if it could be switched on permanently.

     

    image.thumb.png.8c9ca2feb26423cf8a6e3435a99eacc7.png

     

    I discovered it by accident, it only works if the text is a commentary and only if there is some unicode character pasted in the same line, here unicode ENVELOPE.

     


  10. I'm working with Delphi on a VMware machine, where I have a disk (with sources) connected from the host via "Folders sharing" mechanism. It's not too fast, but it usually works well.
    Sometimes Delphi can slow down a lot, e.g. I click the dot after the name of an object and wait a long time for a list of methods. So I fired a process manager called Process Hacker. And I watched what happens when Delphi "hangs and thinks".
    Here's the PH screenshot:

     

    vps_2020_05_05_01.thumb.png.b5150ed018de22906eae4c19fac1a954.png

     

    It turned out that during the hanging, the I/O rate increases very much. But the Disk and Network ratios are not increasing. What could this I/O be?

     


  11. Simple example:

     

    program leak;
    
    {$APPTYPE CONSOLE}
    
    {$R *.res}
    
    uses
      FastMM4,
      System.SysUtils;
    
    
    type
     TRx = record
            s : string;
            v : Variant;
          end;
    
     TAx = TArray<TRx>;
    
    procedure Test;
    var
      lA : TAx;
    begin
      SetLength(lA, 3);
      lA[0].s := 'test2';
      lA[0].v := 888;
      lA[1].s := 'test1';
      lA[1].v := Now;
      lA[2].s := 'test3';
      lA[2].v := 'str';
    end;
    
    begin
      try
        Test;
      except
        on E: Exception do
          Writeln(E.ClassName, ': ', E.Message);
      end;
    end.

    When I don't assign TDateTime to a Variant field, the debugger shows the array and all records correctly, as in the picture on the left. And there is no leakage.

     

    vps_2020_04.28_07.thumb.png.4d3bbb901768559106d03be1d890109f.png

     

    But when I assign TDateTime type to Variant field, as on the right side of the picture, the debugger does not show "plus" in hint window and I get a memory leak at the end.

     

    What is wrong with this code?

     

     

×