Jump to content

Lajos Juhász

Members
  • Content Count

    838
  • Joined

  • Last visited

  • Days Won

    11

Posts posted by Lajos Juhász


  1. 21 minutes ago, stijnsanders said:

    Let me know if this hits the mark or is way off...

    var
      a:TThing;
    begin
      a:=nil;//counter warning (I)
      try
        if //only in some cases
        begin
          a:=TThing.Create;
          //...
        end;
        //...
        if a<>nil then
        begin
          //use a for something
        end;
        //...
      finally
        if a<>nil then (II)
        begin
          a.Free;
          a:=nil;
        end;
      end;
    end;

    (I) Wrong comment. a is a local variable and doesn't have to be nil. Thus the nil is required to signal that there is no object assigned to variable a.

    (II) In this code a is nil or a valid reference thus it's not required to check if it's nil that will be done in the free method.  In the next line it's not required to assign nil to a. A is a local variable and finally after the finally it will go out of scope.


  2. 10 minutes ago, Der schöne Günther said:

    If that is all, how can you even have an opinion on that? What is there to talk about? Can somebody get me up to date with just one or two sentences?

     

    My guess is that they'll try to proove that you can use free instead of freeandnil. Often you can find code:

     

    var

      X: TMyImportantForm;

     

    begin

       x:=TMyImportantForm.create(self);

       try

         ... some boring code ....

       finally

          FreeAndNil(x);

       end;

    end;


  3. I've tested with fireDAC, the bookmark is never valid after reopen (however will find the record if you don't scroll the scrollbar). After every scroll I get:

    image.png.397aa1521d3db52735082b1f1a266ee0.png 

     

    with a call stack:

     

    :763ec3a2 KERNELBASE.RaiseException + 0x62
    FireDAC.Stan.Error.FDException(nil,???,26209084,???)
    FireDAC.Stan.Error.FDException($37E6CA0,???,200,???)
    FireDAC.Comp.DataSet.ErrorNoBmk
    FireDAC.Comp.DataSet.TFDDataSet.InternalGotoBookmark(???)
    FireDAC.Comp.DataSet.TFDDataSet.InternalGotoBookmark((144, 138, 137, 3, 81, 0, 0, 0, 5, 0, 0, 0))
    Data.DB.TDataSet.GotoBookmark((144, 138, 137, 3, 81, 0, 0, 0, 5, 0, 0, 0))
    Unit1.TForm1.Button1Click($37E6930)

     

    I know that this was the case with BDE, DBX and now FireDAC.

     

    For the reference my code is:

     

    procedure TForm1.Button1Click(Sender: TObject);
    var
     lbm: TBookmark;
    begin
      lbm:=fdquery1.Bookmark;
      fdquery1.Close;
      fdquery1.Open;

       if not FDQuery1.BookmarkValid(lbm) then
         ShowMessage('Not Valid!');

      fdquery1.Bookmark:=lbm
    end;
     


  4. 13 minutes ago, Incus J said:

    Naive question:  If they expect you to implement the form destruction event manually, what is the actual purpose of the OnDestroy event property in the object inspector?

    It's a bit different when the form is destroyed while application is running and when the application is closed / terminated. (The OS should/will clean up anything that is not freed by application.)


  5. 7 minutes ago, msd said:

    Delphi is not a problem; it works fine.

    Please send me a copy of D11.1 that works fine. I did my best to support highDPI unfortunately I see no way to do that with D11.1 maybe in D14 will work.

    • Like 1
    • Sad 1

  6. The text on the image that you've attached is not readable. As far as I can see you're using ODBC connection that is not configured on that PC. Be aware that windows have a 32 bit and 64 bit version of the ODBC Data Source Administrator and you have to create the data source in the one that matches your application. A 32 bit application cannot connect to 64 bit data source.

×