

Lajos Juhász
Members-
Content Count
1112 -
Joined
-
Last visited
-
Days Won
15
Everything posted by Lajos Juhász
-
[DCC Warning] W1013 Constant 0 converted to NIL
Lajos Juhász replied to dummzeuch's topic in RTL and Delphi Object Pascal
The exact same is with Delphi 11. Tested with: procedure TForm1.FormCreate(Sender: TObject); var f: pointer; begin f:=0; end; [dcc32 Warning] Unit1.pas(29): W1013 Constant 0 converted to NIL Here is what helps says about this warning: The Delphi compiler now allows the constant 0 to be used in pointer expressions in place of NIL. This change was made to allow older code to still compile with changes which were made in the low-level RTL. program Produce; procedure p0(p : Pointer); begin end; begin p0(0); end. In this example, the procedure p0 is declared to take a Pointer parameter yet the constant 0 is passed. The compiler will perform the necessary conversions internally, changing 0 into NIL, so that the code will function properly. program Solve; procedure p0(p : Pointer); begin end; begin p0(NIL); end. There are two approaches to solving this problem. In the case above the constant 0 has been replaced with NIL. Alternatively the procedure definition could be changed so that the parameter type is of Integer type. -
After you save the data to the file. Someone can edit the file or the original data in the database, thus the program should figure out how to merge back the data.
-
FreeAndNil() - The Great Delphi Developer Debate
Lajos Juhász replied to AlexBelo's topic in Tips / Blogs / Tutorials / Videos
In this case we were discussing object vs interfaces. If those were interface references it would be a bit different outcome. -
FreeAndNil() - The Great Delphi Developer Debate
Lajos Juhász replied to AlexBelo's topic in Tips / Blogs / Tutorials / Videos
My first suggestion was and still is to learn how to write a correct code. Interface is much better than constantly using FreeAndNil as band-aid solution. For example free and nil will not save you here: var x1, x2: TMyClass; begin x1:=TMyclass.create; ..... x2:=x1; ...... FreeAndNil(x1); x2.SaveTheWorldAndMakeItABetterPlace; end; Here maybe you will think you have an excellent code as there is FreeAndNil, however that will not help and x2 is still a stale reference. -
FreeAndNil() - The Great Delphi Developer Debate
Lajos Juhász replied to AlexBelo's topic in Tips / Blogs / Tutorials / Videos
No, you missed the part that you have only to learn how to manage objects. Using FreeAndNil you solve nothing. If you're unsure how to write quality code I suggest use always interfaces. -
DBGrid selected row does not highlight the selected row when ClientDataSet is Closed and Open again
Lajos Juhász replied to ChrisChuah's topic in Databases
This was my first suggestion as that is the way that always works. -
FreeAndNil() - The Great Delphi Developer Debate
Lajos Juhász replied to AlexBelo's topic in Tips / Blogs / Tutorials / Videos
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. -
Delphi help: https://docwiki.embarcadero.com/Libraries/Sydney/en/Vcl.ImageCollection.TImageCollection.Add
-
FreeAndNil() - The Great Delphi Developer Debate
Lajos Juhász replied to AlexBelo's topic in Tips / Blogs / Tutorials / Videos
I never saw this kind of code, I saw: if Assigned(obj) then obj.free; Most of the time I only saw that a "developer" refuses to use free instead of FreeAndNil. -
FreeAndNil() - The Great Delphi Developer Debate
Lajos Juhász replied to AlexBelo's topic in Tips / Blogs / Tutorials / Videos
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; -
FreeAndNil() - The Great Delphi Developer Debate
Lajos Juhász replied to AlexBelo's topic in Tips / Blogs / Tutorials / Videos
Why not? Until it's removed from the language this topic will remain important. Unfortunately I believe even if it will be eventually removed everyone will create a private copy and continue to use that as an "important tool". -
DBGrid selected row does not highlight the selected row when ClientDataSet is Closed and Open again
Lajos Juhász replied to ChrisChuah's topic in Databases
Tested with a persistent field and set the PK. It doesn't make a difference I still get: Project Project1.exe raised exception class EFDException with message '[FireDAC][Comp][DS]-200. Bookmark is not found for dataset [FDQuery1]'. Maybe UniDAC has a different implementation for bookmarks. -
DBGrid selected row does not highlight the selected row when ClientDataSet is Closed and Open again
Lajos Juhász replied to ChrisChuah's topic in Databases
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: 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; -
DBGrid selected row does not highlight the selected row when ClientDataSet is Closed and Open again
Lajos Juhász replied to ChrisChuah's topic in Databases
Since Delphi 1. If you close and reopen the query the bookmark is invalid. -
DBGrid selected row does not highlight the selected row when ClientDataSet is Closed and Open again
Lajos Juhász replied to ChrisChuah's topic in Databases
When you refresh the data the bookmark will no longer be valid. It's a pure luck if you don't see an error message. You shold remember the key of the active record before the refresh and call locate for it. -
DBGrid sort descending on Column Title Click
Lajos Juhász replied to ChrisChuah's topic in Databases
In that case you use the AddIndex merhod. For more information: https://docwiki.embarcadero.com/Libraries/Sydney/en/Datasnap.DBClient.TCustomClientDataSet.AddIndex here you can find a helper procedure https://edn.embarcadero.com/article/29056 to sort. -
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.)
-
You have to set a flag inside the button3 onclick event handler. Later when needed you can check that flag and reset it.
-
Of course I don't have. I am a Delphi developer.
-
Code Insight can't find certain units (app compiles OK)
Lajos Juhász replied to Incus J's topic in Delphi IDE and APIs
You can upload a zip file with a project and or a txt file with the description that will be not altered by the site. -
Parallels on MacOS, Designer problems
Lajos Juhász replied to patrik-xyndata's topic in Delphi IDE and APIs
Since the per-monitor dpi (v1) was introduced in Win 8.1 there should programs also work. -
SynEdit is not part of the Delphi so it's hardly changed with Delphi upgrade.
-
MIT researchers uncover ‘unpatchable’ flaw in Apple M1 chips
Lajos Juhász replied to PeterPanettone's topic in General Help
Maybe you have an unpatched M1 chip. Working fine here in Chrome, Firefox and Edge. -
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.
-
$Variable for Styles directory?
Lajos Juhász replied to PeterPanettone's topic in Delphi IDE and APIs
You can try $(BDSCOMMONDIR)\styles or $(BDSUSERDIR)\styles