Leaderboard
Popular Content
Showing content with the highest reputation on 02/23/21 in Posts
-
A new version (1.1) of SVGShellExtensions (Open-Source) has been released with a new component (a very useful SVG Text Editor) and a context-menu to export an SVG file to multiple PNG files. The new Setup is always available on the project page: https://github.com/EtheaDev/SVGShellExtensions The preview panel now has a slider to change the "backlight" of the image and more settings (such as text color attributes, theme, use of native Direct2D). The SVG Text Editor is useful for developers who need to change certain aspects of the icons (such as element colors) or try to change the SVG language and see an instant preview of the changes. Any suggestions for improving these components are welcome!
-
- explorer
- svgiconimagelist
- (and 4 more)
-
Max string literal length = 255
Lars Fosdal replied to Lars Fosdal's topic in RTL and Delphi Object Pascal
Make sure you understand the core issue before posting a googled suggestion. Good luck filling an AnsiString with a string literal longer than 255 chars. Oh wait, you can't. If I don't want to split up and combine multiple literals, loading from a resource string is an option. It just irks me that I can't initialize a string variable that can literally hold billions of characters with a single constant longer than 255 chars. -
Hello all, I was trying to get my head around this for a while but I simply can not find the solution. In my project I have a frame which I create runtime on a TTabSheet. On this frame I have 2 TTreeView components. 1 is on the frame itself, the second one is on an inner tabsheet: Now, if the TreeView on the TabSheet has ANY items created if the application has a VCL style active, those items will not be freed up. I put a breakpoint in TTreeNode.Destroy and I can confirm that those are ONLY being called for nodes in the other TreeView. I even put TreeView2.Items.Clear in the frame's destructor, but as Owner.HandleAllocated is false at that stage, deleting all nodes never happen. So I put a breakpoint in the frame destructor and TTreeNode.Destroy, and the thing I quickly realized is that the nodes of the first TreeView are being freed before the destructor, because of a window message (TVN_DELETEITEMA or TVN_DELETEITEMW). This is actually deleting the nodes in Vcl.ComCtrls.pas : 11910. But, this message is sent only to the TreeView on the frame, not to the one in the PageControl. Again, only when VCL styles are active. I will try to send this message manually in the destructor (or explicitly deleting all nodes...?) to see if it solves my issue, but it bugs me to hell that I don't know what is happening. If I'd know where this message is sent, I could investigate why it is sent to / received by one TreeView only. Anyone has any ideas? Edit: Manually trying to delete nodes will fail, as TreeView.Items.Count shows 0 at the destructor already. Edit-edit: I have an event on the frame itself which is being called BEFORE the .Free is called upon the owning tabseet. If I move TreeView2.Items.Clear in that handler, the memory leak disappears. I guess it's an other quirk of the VCL styles but I'd still like to know the reason...
-
spinlock primitives
Anders Melander replied to dummzeuch's topic in Algorithms, Data Structures and Class Design
You are writing your own spinlock to get better performance - and then you use Sleep() which is guaranteed to cause a context switch...? Unless you really know what you're doing then you better of using the synchronization primitives provided by the OS. https://devblogs.microsoft.com/oldnewthing/20051004-09/?p=33923 http://joeduffyblog.com/2006/08/22/priorityinduced-starvation-why-sleep1-is-better-than-sleep0-and-the-windows-balance-set-manager/ Apparently this can't be repeated often enough. -
This is a two-year old post but I just want to say a big THANK YOU for this answer. I spent the better part of a day in anguish over this very problem where a demo program worked just fine but copying the code to my program did not. After comparing everything between the two projects and hunting around the internet for possible answers, I finally found this and it was solved immediately!
-
spinlock primitives
A.M. Hoornweg replied to dummzeuch's topic in Algorithms, Data Structures and Class Design
One problem I see is that on a single-core CPU, doLock will burn up all remaining CPU time of the time slice on contention. -
version 10.4.1 Found the answer!!! Grrhhh, silly me. I have a status bar on the form using it to write various things happening. I'd called it 'word' would you believe! Changed it to SayWord and all works fine.
-
Read and reapply design time properties to specific controls - runtime
Uwe Raabe replied to aehimself's topic in VCL
The problem with those ExplicitXXX values is that they are synched with their current XXX counterparts on several occasions. These are WM_SIZE, WM_MOVE and SetBounds. You cannot assume that these values contain the original DFM content, even if that was the case after loading the form. -
Read and reapply design time properties to specific controls - runtime
balabuev replied to aehimself's topic in VCL
This is not technically possible with TReader. However, I want to mention one different aspect: Such a solution will not be a kind of "professional" solution anyway, because controls are not developed having multiple re-loads in mind. Control's code may use different load process related flags, like csReading, csLoading and may override Loaded method. And the developer may (which is often the case) rely on the fact that the loading happens right after creation. -
Native Svg parsing and painting in Windows
Attila Kovacs replied to pyscripter's topic in RTL and Delphi Object Pascal
I did not feel the need to get PowerToys' preview criticized. It has nothing to do with the language it's written in. It's all about preferences. No. As I'm preparing the images for production and then it gets into a separate directory, and depending on the selected theme, dark or light, the colors in the SVG's are adjusted for all icons automatically on theme change. We sure not doing the same job. -
Read and reapply design time properties to specific controls - runtime
Attila Kovacs replied to aehimself's topic in VCL
I think this is what you need, you just have to adjust it a bit. // search in dfm resources by Attila Kovacs unit DFMSearch; interface uses System.Classes, System.Generics.Collections; type TDFMSearch = class private FFormClasses: TList<string>; FResourceNames: TList<string>; FSearchDictionary: TDictionary<string, string>; function GetFormClasses(AClass: TClass): TList<string>; procedure BuildStrings(AResources: TList<string>); procedure EnumClasses(AClass: TClass); public function Find(const ASearchString: string): TList<string>; constructor Create(AClass: TClass); overload; constructor Create(AClassNames: TList<string>); overload; destructor Destroy; override; end; implementation uses Winapi.Windows, System.Rtti, System.SysUtils, System.StrUtils; function EnumResNames(Module: HMODULE; ResType, ResName: PChar; Obj: Pointer): integer; stdcall; var ds: TDFMSearch; begin ds := TDFMSearch(Obj); if ds.FFormClasses.IndexOf(string(ResName)) > -1 then ds.FResourceNames.Add(string(ResName)); Result := 1; end; function TDFMSearch.GetFormClasses(AClass: TClass): TList<string>; var cl: TClass; ctx: TRttiContext; types: TArray<TRttiType>; typ: TRttiType; begin Result := TList<string>.Create; ctx := TRttiContext.Create; types := ctx.GetTypes; for typ in types do begin if typ.TypeKind = tkClass then begin cl := typ.AsInstance.MetaclassType; if (cl <> AClass) and cl.InheritsFrom(AClass) then Result.Add(UpperCase(cl.ClassName)); end; end; end; procedure TDFMSearch.BuildStrings(AResources: TList<string>); var i: integer; Flags: TFilerFlags; R: TReader; RS: Tresourcestream; vt: TValueType; Position: integer; text, PropName, CompClass, CompName, StrValue, ResStr: string; procedure ReadProperty; begin PropName := R.ReadStr; if ContainsText(PropName, 'caption') then begin vt := R.NextValue; case vt of vaWString, vaUTF8String: StrValue := R.ReadString; vaString, vaLString: StrValue := R.ReadString; else R.SkipValue; end; text := text + ' ' + StrValue; end else R.SkipValue; end; procedure ReadData; forward; procedure ReadComponent; begin R.ReadPrefix(Flags, Position); CompClass := R.ReadStr; CompName := R.ReadStr; ReadData; end; procedure ReadData; begin while not R.EndOfList do ReadProperty; R.ReadListEnd; while not R.EndOfList do ReadComponent; R.ReadListEnd; end; begin for i := 0 to AResources.Count - 1 do begin ResStr := UpperCase(AResources[i]); RS := Tresourcestream.Create(HInstance, ResStr, RT_RCDATA); try R := TReader.Create(RS, 4096); try text := ''; R.ReadSignature; ReadComponent; FSearchDictionary.AddOrSetValue(ResStr, text); finally R.Free; end; finally RS.Free; end; end; end; constructor TDFMSearch.Create(AClass: TClass); begin FSearchDictionary := TDictionary<string, string>.Create; EnumClasses(AClass); end; constructor TDFMSearch.Create(AClassNames: TList<string>); begin FSearchDictionary := TDictionary<string, string>.Create; BuildStrings(AClassNames); end; destructor TDFMSearch.Destroy; begin FSearchDictionary.Free; inherited; end; procedure TDFMSearch.EnumClasses(AClass: TClass); begin if not Assigned(FSearchDictionary) then begin FFormClasses := GetFormClasses(AClass); try FResourceNames := TList<string>.Create; try EnumResourceNames(HInstance, RT_RCDATA, @EnumResNames, NativeInt(Self)); BuildStrings(FResourceNames); finally FResourceNames.Free; end; finally FFormClasses.Free; end; end; end; function TDFMSearch.Find(const ASearchString: string): TList<string>; var i, j, slen: integer; sl: TArray<string>; pa: TPair<string, string>; begin Result := TList<string>.Create; sl := ASearchString.Split([' ']); slen := Length(sl); for pa in FSearchDictionary do begin j := 0; for i := 0 to High(sl) do begin if ContainsText(pa.Value, sl[i]) then inc(j); end; if j = slen then Result.Add(pa.Key); end; end; end. -
Undocumented language enhancements
David Heffernan replied to vfbb's topic in RTL and Delphi Object Pascal
The entire language is essentially undocumented. There is no formal specification, no documented grammar etc. -
Hi All I have been steadily working away on my package manager project - the latest update includes compile on install support. https://github.com/DelphiPackageManager/DPM When a package is first installed, it is automatically compiled (if the package spec has that support enabled) and then the project references the compiled version of the package. This speeds up builds on your own projects, since you are not compiling the dpm package sources each time. As an extreme example of this, the DPM build process (building for 12 versions of delphi!) previously took 13 minutes on my build server, after installing the latest dpm and running 2 builds (the first one compiled the packages), the build time is down to 2 minutes! Much of that speed up comes from the fact that older versions of delphi are quite slow at building Spring4D. I encourage everyone to check it out and provide feedback where possible. To get started using DPM, download the latest release from here : You will need to configure a package feed (folder) and download some packages - see the Getting started page Most of my open source projects have package files available under the releases tab on github - https://github.com/vsoftTechnologies/ I have also added a mirror project for Spring4D on github so that I could publish packages (bitbucket doesn't support that) - https://github.com/VSoftTechnologies/Spring4DMirror Same for JsonDataObjects - Andreas ignored my pull request for over a year so I closed it and just forked the project - https://github.com/VSoftTechnologies/JsonDataObjects I'm still working on getting design time packages loaded.. need to get proper project group support going first. Previous updates here :
-
I've never been in contact with Lasse (the original author) but as far as I remember the pieces of SynEdit that I found were significant enough that I could recognize them as coming from SynEdit. As far as I remember it was some of the syntax definitions. I don't know what interaction other people have had with him so I can't speak to that. The code copied might have been trivial and it might not have been that much but I still don't think it's acceptable to remove the license/attribution header and keep the code. Anyway, it's nothing compared to what Niels Hoyer did after he forked the code so regardless of SynEdit/TBCEditor the current TBCEditor forks are definitely in violation of Lasse's copyright. It's a damned pity as the code looked really promising but I can sympathize with Lasse burning out over the amount of pure crazy directed at him.