-
Content Count
267 -
Joined
-
Last visited
-
Days Won
2
Everything posted by Jacek Laskowski
-
FastMM5 now released by Pierre le Riche (small background story)
Jacek Laskowski replied to Günther Schoch's topic in Delphi Third-Party
I can't find a link to the FastMM4Options.inc file. Is FastMM5 no longer a configuration file? -
Issue with variant in record in array
Jacek Laskowski posted a topic in RTL and Delphi Object Pascal
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. 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? -
Issue with variant in record in array
Jacek Laskowski replied to Jacek Laskowski's topic in RTL and Delphi Object Pascal
In fact, when I'm not debuging, there is no leak. But is it an IDE error to show the record array (without the record expansion plus) in a hint debugger? Because I was afraid it was a problem in my record and array memory management. I do some tricks there. -
How to set the generic class field to the value provided by Variant? The following code is not compiled. ToField<T> = class private fData : T; protected procedure SetFromVariant<T>(const aValue : Variant); [...] procedure ToField<T>.SetFromVariant<T>(const aValue : Variant); var val: TValue; begin val := TValue.FromVariant(aValue); fData := val.AsType<T>; <=== [dcc32 Error] E2008 Incompatible types [dcc32 Error] E2008 Incompatible types
-
Variant to generic T, how?
Jacek Laskowski replied to Jacek Laskowski's topic in RTL and Delphi Object Pascal
@Remy Lebeau I cannot use this constraint because it blocks the use of string types (because it is not a valuable type). -
Variant to generic T, how?
Jacek Laskowski replied to Jacek Laskowski's topic in RTL and Delphi Object Pascal
@Remy Lebeau That's impossible, fData is generic: [dcc32 Error] E2010 Incompatible types: 'T' and 'Variant' -
I got a Chad Z. Hower article: https://www.codeproject.com/Articles/1252175/Fixing-Delphis-Interface-Limitations The author is very critical about the interfaces in Delphi. But he gives examples where he mixes interface and object access, which is doomed to failure in advance. I use interfaces very much, and I don't agree with the statement that there is more trouble with them than good. I don't know e.g. C++ and I don't know how interfaces are solved there, probably my ignorance limits my understanding of the problem. Can someone enlighten me if the interfaces in Delphi are really that badly done?
-
Variant to generic T, how?
Jacek Laskowski replied to Jacek Laskowski's topic in RTL and Delphi Object Pascal
I'm blind, sorry and thx! 🙂 -
Variant to generic T, how?
Jacek Laskowski replied to Jacek Laskowski's topic in RTL and Delphi Object Pascal
Your code is identical to mine, don't I notice anything? I still get compilation error on Delphi 10.3 -
The interfaces in Delphi are bad?
Jacek Laskowski replied to Jacek Laskowski's topic in RTL and Delphi Object Pascal
Very common, basically always, used database classes like TDataset, etc. I create in runtime, they are for example part of business classes, as "Owner" I give them nil. There I would like to use them in the interface model, not in the VCL management model. -
Do you name your Threads for debugging?
Jacek Laskowski replied to Darian Miller's topic in Tips / Blogs / Tutorials / Videos
Unfortunatelly I don't. When it comes to the order of starting the "initialization" section it's not always the same, it all depends on the uses section, in my case your code is launched before RTL/VCL threads. I bypassed this problem by adding a anonymous thread with delay: procedure NameDelphiThreads(const pMainThreadId : THandle); begin TThread.CreateAnonymousThread( procedure var vSnapshot:THandle; vProcessId:THandle; vTE32:TThreadEntry32; i:Integer; begin Sleep(100); vProcessId := GetCurrentProcessId(); vSnapshot := CreateToolhelp32Snapshot(TH32CS_SNAPTHREAD, vProcessId); if vSnapshot <> INVALID_HANDLE_VALUE then begin [...] end; end ).Start; end; -
The interfaces in Delphi are bad?
Jacek Laskowski replied to Jacek Laskowski's topic in RTL and Delphi Object Pascal
But try this "trick" on TComponent or it's descendants... no way. -
Do you name your Threads for debugging?
Jacek Laskowski replied to Darian Miller's topic in Tips / Blogs / Tutorials / Videos
@Darian Miller Your code starting with initialization is not perfect, because it fires up before all native threads are created. -
I'm looking for a library/class to minify (compress) HTML files. Is there such a thing?
-
You can: - delete end of lines (CR, CRLF) - delete spaces between fields in css: style="color: white; border: 5px" => style="color:white;border:5px" - delete all spaces and tabs of which there is more than one next to each other (except the <pre></pre> tag) - if the styles are defined within HTML in <style type="text/css"> then all long style names like bold_red_important_text can be replaced by short names
-
ANN HTML Library 4.1 released
Jacek Laskowski replied to Alexander Sviridenkov's topic in Delphi Third-Party
I know that the attribute will not be removed because the library does not know that it is unnecessary. But notice that in the example I gave you, the alt="nothing" attribute appears twice in one tag! This is an example of ugly, junk HTML code that I have to clean up. I would like to do it as automatically as possible, because manual work is very tedious. I imagined that your parser could make it easier for me. -
ANN HTML Library 4.1 released
Jacek Laskowski replied to Alexander Sviridenkov's topic in Delphi Third-Party
But I mean AUTOMATIC removal of duplicate or unnecessary attributes by library. That's what I'm asking. A library that parses HTML and CSS and creates object-oriented structure (DOM) does it automatically, right? -
ANN HTML Library 4.1 released
Jacek Laskowski replied to Alexander Sviridenkov's topic in Delphi Third-Party
No, I don't need runtime. But I didn't find a web tool. If you know one, please give me a link. -
ANN HTML Library 4.1 released
Jacek Laskowski replied to Alexander Sviridenkov's topic in Delphi Third-Party
I have one question, is it possible to optimize HTML and CSS code with your library, i.e. remove unnecessary attributes? For example, I have a code: <img src="logo.jpg" alt="nothing" style="color: white; border: 50px; color: black" alt="nothing" ><div> This tag has an unnecessary attribute alt="nothing" and one of the CSS attributes: "color: white" because both are overwritten. To remove such redundant attributes you would need to parse HTML and CSS (what your library does) and build HTML and CSS from the metadata again. Is this possible in the HTML Library? -
I need this for html mailing (e-mail in html format)
-
Delphi Rio IDE hangs again and again
Jacek Laskowski replied to microtronx's topic in Delphi IDE and APIs
What IDE add-ons/experts do you use? -
TFDMemTable - how to clear structure?
Jacek Laskowski replied to Jacek Laskowski's topic in Databases
This is not a very sophisticated solution 🙂 I was hoping for something better. But... thanks. -
I have a strange problem with FireDAC (Delphi 10.3.2) I create TFDMemTable dynamically, then I create its structure and index on base key (by memTable.Indexes.Add()). Next, I import data from JSON file (saved previously by TFDQuery object): memTable.LoadFromStream(x, sfJSON); AV is raised in this FD code: procedure TFDDatSView.RemRef; begin FRefs.RemRef; end; And on this import I get access violation in FireDAC code, because internal TFDDatSView field is nil (see attached screenshot)! When I remove the creation of the index there is no error. But I can't do it, because it's part of a big, generic mechanism and it's needed. The index is created when MemTable is in dsInactive mode, can it be the cause? I also noticed that when I do Open/Close this MemTable, there is no error either. What is the cause and how to avoid it without performing spells (like close/open)?
-
FireDAC and AV in TFDDatSView.RemRef()
Jacek Laskowski replied to Jacek Laskowski's topic in Databases
OK, the problem is not in FireDAC, but in the code associated with Spring4D. Injected interface for reasons I don't know yet reduces the reference counter to zero and is released, and with it FD objects. -
Ok, now it's correct, sorry for the false report