-
Content Count
277 -
Joined
-
Last visited
-
Days Won
2
Everything posted by Jacek Laskowski
-
The code is correct, compiles, but the editor highlights errors 😞
-
Strange thing in System.Generics.Defaults.pas
Jacek Laskowski posted a topic in RTL and Delphi Object Pascal
Quote: unit System.Generics.Defaults; [...] function GetHashCode_Class(Inst: PSimpleInstance; const Value: TObject): Integer; begin if Value = nil then Result := 42 else Result := Value.GetHashCode; end; What is this? Why 42? 🙂 ps. Delphi Tokyo, maybe other too -
Yes, quality lies and cries. Recently, I have been working a little in VSCode and the node.js ecosystem. Environmental quality is ahead of Delphi for ages. In addition, it works steadily and quickly, although behind the scenes everything is based on slow JS! I have serious doubts that Delphi will ever catch up with the world in this area.
-
Node modules with Delphi and Free Pascal
Jacek Laskowski replied to a topic in Tips / Blogs / Tutorials / Videos
great!- 6 replies
-
- delphi
- freepascal
-
(and 3 more)
Tagged with:
-
GExperts?
-
WebAssembly with Delphi and ChakraCore
Jacek Laskowski replied to a topic in Tips / Blogs / Tutorials / Videos
Chakra is open source, under the liberal MIT license, it doesn't have to die with Edge. -
Then try to debug the GZIP usage or place of parsing response headers. IMHO Rio has many errors in HTTPClient classes, see:
-
try to debug HTTPClient after exit from this event
-
Such a curiosity Code insight caused an exception in Delphi Tokyo, I pay attention to the path in the call stack. See screen:
-
Strange thing in System.Generics.Defaults.pas
Jacek Laskowski replied to Jacek Laskowski's topic in RTL and Delphi Object Pascal
"The number 42 is, in The Hitchhiker's Guide to the Galaxy by Douglas Adams, the "Answer to the Ultimate Question of Life, the Universe, and Everything", calculated by an enormous supercomputer named Deep Thought over a period of 7.5 million years. " Yes, I was looking for that! 🙂 -
I register classes and factories in Spring: container.RegisterType<TMyClass>; container.RegisterFactory<TMyClassFactory>; Then in the code I use: fClassFactory: TMyClassFactory; [...] begin lMyClass: = fClassFactory(); [some code] lMyClass.Free; <- who is responsible? end; Who is responsible for the release of the object? Spring or me?
-
10.3 Consumes 45% of my CPU
Jacek Laskowski replied to John Kouraklis's topic in Delphi IDE and APIs
I install WinDbg, but where is "Configure Symbols" window? -
GetIt: missing all the TurboPower component
Jacek Laskowski replied to gkobler's topic in Delphi IDE and APIs
FastReport is also missing... -
The REST Library in Delphi Rio has a serious error. I was last weekend at the world's largest HackYeah hackathon, where I needed to use the Delphi Rio to connect to the rest service. However, I could not. REST Debbuger did not return any error or response after calling the request (button Send Request). I lost a lot of time on the verification of network connections and the operation of the server itself (I thought that a heavy load on the hackatone participants "killed" the server) but it turned out to be a mistake in the REST Library. When I tried to call the request directly from Delphi (request.Execute ()) I got an error in KERNELBASE. There is no error in Delphi Tokyo, the same code worked there, but on my laptop I only had Rio. So I was looking for a solution. Eventually, I found the place and the reason, corrected RTL file (after copy to project directory) and the code runed, but the bad taste remained. Later I will publish where the error lies.
-
Rio has a broken REST Library
Jacek Laskowski replied to Jacek Laskowski's topic in RTL and Delphi Object Pascal
https://quality.embarcadero.com/browse/RSP-21770 -
Rio has a broken REST Library
Jacek Laskowski replied to Jacek Laskowski's topic in RTL and Delphi Object Pascal
Bug exist in System.Net.HttpClient.Win.pas file. This is not exactly REST Library like I wrote previous, but REST uses this subsystem too. Bad function with my changes: function ReadHeader(ARequest: HINTERNET; AHeaderFlag: DWORD; const AHeaderName: string = ''): string; var LSize: Cardinal; LFlags: DWORD; LHeaderName: PWideChar; begin LFLags := AHeaderFlag; if AHeaderName <> '' then begin LFLags := LFLags or WINHTTP_QUERY_CUSTOM; LHeaderName := PWideChar(AHeaderName); end else LHeaderName := WINHTTP_HEADER_NAME_BY_INDEX; LSize := 0; WinHttpQueryHeaders(ARequest, LFLags, LHeaderName, nil, LSize, WINHTTP_NO_HEADER_INDEX); if GetLastError = ERROR_WINHTTP_HEADER_NOT_FOUND then Result := '' else begin if GetLastError <> ERROR_INSUFFICIENT_BUFFER then raise ENetHTTPException.CreateResFmt(@SNetHttpHeadersError, [GetLastError, SysErrorMessage(GetLastError, TWinHttpLib.Handle)]); SetLength(Result, LSize div SizeOf(Char) - 1); // ---------------------- my changes begin if Length(Result) = 0 then begin SetLength(Result, 1); end; // ---------------------- my changes end if WinHttpQueryHeaders(ARequest, LFLags, LHeaderName, PChar(Result), LSize, WINHTTP_NO_HEADER_INDEX) = False then raise ENetHTTPException.CreateResFmt(@SNetHttpHeadersError, [GetLastError, SysErrorMessage(GetLastError, TWinHttpLib.Handle)]); end; end; The problem occurs when a zero-length string (SetLength) is created and passed by the PChar to the WinHttpQueryHeaders() method as Nil. SetLength(Result, LSize div SizeOf(Char) - 1); //when LSize = 2 then Result is empty string I can't reproduce this case now, because I don't have access to that site that caused the error on the hackathon, and on a few other ones that I checked right now, this situation doesn't occur (the header row with 2 characters). -
Delphi Bugs reported to QualityPortal
Jacek Laskowski replied to Lars Fosdal's topic in Community Management
Yes, it's good idea! -
Based on this thread: https://stackoverflow.com/questions/29958168/are-integer-reads-atomic-in-delphi it can be assumed that writing or reading Integer values (4 bytes) does not have to be atomic. It depends on the alignment. Questions: Is writing and reading 1 byte (type Byte) always atomic (and safe) operation? Is writing and reading 2 byte (type Word) always atomic (and safe) operation?
-
Inline Variables Coming in 10.3
Jacek Laskowski replied to Marco Cantu's topic in RTL and Delphi Object Pascal
Next example of use inline variable to improve code clarity: Instead of unclear: fRecipients := TCollections.CreateList<TRecipient>(True); we can write: fRecipients := TCollections.CreateList<TRecipient>(var OwnsObjects = True);