The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 1,862 other subscribers

Archive for the ‘Delphi’ Category

One more reason to have an ARC win32 compiler: tracking down memory leaks efficiently

Posted by jpluimers on 2018/06/07

One of the reasons it is so hard to write ARC a compatible source base is that there is no Delphi ARC win32 compiler. So you have to debug your memory issues using the remote debugging capabilities which – besides very slow – are unstable at best.

This is the number 1 reason I have been asking for a Delphi ARC win32 compiler integrated with the native Delphi win32 debugger (in addition to the current Win32 non-ARC compiler). Hopefully [WayBack] A second example of memory usage/leaks on linux using TTask (but only running one at a time) inside a loop will show memory usage increasing depending o… – Andrew Pratt – Google+ will give Embarcadero more motivation to eventually develop one.

This besides the fact that anyone writing for ARC should buy+read [WayBack] Delphi Memory Management eBook for classic and ARC compilers via [WayBack] I have some questions about Linux & ARC and I’m hoping some experts can share their expertise because I’m not understand the results I’m seeing. For th… – Andrew Pratt – Google+

(see also [WayBack] How to free a component in Android / iOS – Stack Overflow and Delphi ARC: Free versus DisposeOf (via: Ondrej Pokorny – Google+))

–jeroen

Posted in Delphi, Development, Software Development | 3 Comments »

High DPI Patches For Delphi | The Art of Delphi Programming

Posted by jpluimers on 2018/06/06

Reminder to self to install the [WayBackHigh DPI Patches For Delphi | The Art of Delphi Programming from the [WayBack] download zip.

–jeroen

Via: [WayBack] Some things just need their time: – Uwe Raabe – Google+

Posted in Delphi, Development, Software Development | Leave a Comment »

Delphi 10.2 Tokyo: they did not fix the broken documentation tab in 10.2.2 2004, but it is an “easy” fix to do yourself

Posted by jpluimers on 2018/06/06

Since the fix is on the forums server (singular!) and that one tends to be squirrel driven lately, here it is in full via [WayBack] I see they didn’t fix the broken documentation tab in 10.2.2 2004 (professional). It’s not a show stopper but a nuisance to fix oneself. And for new dev… – Herbert Sauro – Google+ and [WayBack] I have installed Delphi 10.2.2 and the Documentation tab is all stuffed up ( see picture ). I know there is a html template page for the welcome tab, bu… – Tony Danby – Google+

In C:\Program Files (x86)\Embarcadero\Studio\19.0\Welcomepage\en

Edit Documentation.htm and insert the one piece about the innerWidth

function setFrameURL(url)
        {
            if(url){
                document.getElementById('load_html').src = url
                $("#load_html").css("display", "block");
                var height = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight;         
                $("#load_html").css("height",(height)+"px");    
                var width = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;         
                $("#load_html").css("width",(width)+"px");  

It works and takes up the entire page after you restart the IDE.

If it gets up: https://forums.embarcadero.com/thread.jspa?threadID=271798

–jeroen

 

Posted in Delphi, Delphi 10.2 Tokyo (Godzilla), Development, Software Development | Leave a Comment »

Delphi versions that can convert .bpg to .groupproj files

Posted by jpluimers on 2018/06/05

Reminder to self: extend the below very incomplete list of Delphi versions that can open a Borland Project Group file with extension .bpg (from the Delphi <= 7 era) and convert it to an XML based Group Project file with extension .grouproj (from the Delphi >= 2007 era).

  • Delphi 2007

Notes:

The .bpg file is actually a makefile, see for instance [WayBackbuild – How to compile a Delphi 7 project group file (.bpg) using the command line? – Stack Overflow

Delphi 2006 and 2005 use .bdsgroup files:

The .bdsgroup files are not compatible with .groupproj files in Delphi 2007 and up: [WayBackdelphi – How to convert a D2009 .groupproj file to a D2006 .bdsgroup file? – Stack Overflow.

A .grouproj file is basically an msbuild 2013 subset, see the below links for more info:

I needed this so I could make this conversion:

–jeroen

PS: Searching for the .groupproj links also got me this: [WayBackParallel compilation of delphi projects through MSBuild – Stack Overflow

Posted in Delphi, Development, Software Development | Leave a Comment »

“Unknown function at TMethodImplementationIntercept”

Posted by jpluimers on 2018/06/01

Reminder to self: when you get Unknown function at TMethodImplementationIntercept in a Delphi stack trace from the Exception.StackTrace property or FastMM memory report:

  1. Ensure you generate a .MAP or .TDS file with full debug information
  2. Copy the .MAP or .TDS files to directory of your EXE.

Via:

The Exception.StackTrace was introduced in Delphi 2009 that extended these [WayBackException Members:

Some notes:

  • Fields where you can put hooks in; if there is no hook in place, they won’t be used:
    • [WayBackException.GetExceptionStackInfoProc Field GetExceptionStackInfoProc: function (P: PExceptionRecord): Pointer;
      • This function is called to return an opaque data structure that contains stack information for the given exception information record. This function will be called when the exception is about to be raised or if this is an external exception such as an Access Violation, called soon after the object is created.
    • [WayBackException.CleanUpStackInfoProc Field CleanUpStackInfoProc: procedure (Info: Pointer);
      • This function is called when the destructor is called to clean up any data associated with the given opaque data structure.
    • [WayBackException.GetStackInfoStringProc Field GetStackInfoStringProc: function (Info: Pointer): string;
      • This function is called to return a string representation of the opaque data structure returned by GetExceptionStackInfoProc

TMethodImplementationIntercept was introduced in the System.Rtti unit of Delphi XE6 [WayBack]:

–jeroen

Example code:


unit ExceptionHelperUnit;
interface
uses
System.SysUtils;
type
ExceptionHelper = class helper for Exception
public
function Describe: string;
class procedure RaiseNotImplementedException(const aClass: TClass; const aMethodName: string);
class function GetStackTrace: string;
end;
implementation
uses
System.RTLConsts,
System.SysConst;
type
EStackTraceException = class(Exception); // EProgrammerNotFound to make it really clear this is only to be used in very limited places ??
{ ExceptionHelper }
function ExceptionHelper.Describe: string;
var
lStackTrace: string;
begin
Result := inherited ToString();
if Self is EInOutError then
if Result = System.RTLConsts.SInvalidFileName then
Result := System.SysConst.SInvalidFileName;
if Assigned(StackInfo) then
lStackTrace := StackTrace
else
lStackTrace := 'empty';
Result := Format('Exception'#13#10'%s at $%p: %s'#13#10'with StackTrace'#13#10'%s', [ClassName, ExceptAddr, Result, lStackTrace]);
end;
class function ExceptionHelper.GetStackTrace: string;
begin
try
Result := 'Get StackTrace via Exception.';
raise EStackTraceException.Create(Result) at ReturnAddress;
except
on E: EStackTraceException do
Result := E.StackTrace;
end;
end;
class procedure ExceptionHelper.RaiseNotImplementedException(const aClass: TClass; const aMethodName: string);
begin
raise ENotImplemented.CreateFmt('Method %s.%s is not implemented.', [aClass.ClassName, aMethodName]);
end;
end.

Posted in Delphi, Development, FastMM, Software Development | Leave a Comment »

Delphi needs a few more wizards – verify dpr against dproj and check both against files on disk

Posted by jpluimers on 2018/05/31

There are a few experts Delphi needs for project management:

  • verify the .dproj against the .dpr as these get out of sync often, especially in multi-person or multi-branch projects
  • verify .dproj and .dpr against files on disk (often there are files on disk not in the Project Manager; Visual Studio has this nice [WayBack“Show All Files” button that helps fixing this there)

via [WayBackIs there a way to export the file structure of a Project from the Project Manager view to a txt file? – John Kouraklis – Google+

Atilla Kovaks posted a small bash script to get started: [WayBackhttp://pisil.de/prfiles.sh.txt

–jeroen

Read the rest of this entry »

Posted in Delphi, Development, Software Development | 3 Comments »

Class Constructors/Destructors are special initialization/finalization sections – via Popping the hood. – Community Blogs – Embarcadero Community

Posted by jpluimers on 2018/05/30

I wasn’t sure what the order of class constructors/destructors was with respect to initialization/finalization sections. [WayBackClass Constructors. Popping the hood. – Community Blogs – Embarcadero Community explains that there is more to it than below summary, but it is a good start:

If a given class constructor is eligible to be invoked (ie. it was linked into your application), it will run immediately before the initialization section for the unit in which the class is implemented. The class destructors will be invoked immediately after the finalization section for the unit in which the class is implemented.

–jeroen

Posted in Delphi, Development, Software Development | Leave a Comment »

Via G+: I’m having some trouble with high DPI support and popup menus…

Posted by jpluimers on 2018/05/29

Hopefully Uwe Raabe will publish his VCL patches soon: [WayBack] I’m having some trouble with high DPI support and popup menus (using Delphi 10.2.3). Everything scales correctly except for the popup menus which still … – Dominic De Chasteigner Dumée – Google+

HiDPI with VCL still needs quite a bit of work, even on running one monitor (mixing regular DPI and HiDPI monitors will likely always be a pain for any pixel based environment)…

Note figuring out errors is not always easy, as Delphi 2009 introduced the System.TMonitor record for thread synchronisation, next to the existing Forms.TMonitor class that had monitor settings.

Related:

–jeroen

Posted in Delphi, Development, Software Development | Leave a Comment »

Use DelphiAST – via TPersistent.com » Blog Archive » The Parsing Problem

Posted by jpluimers on 2018/05/29

Stefan Glienke Says:

FWIW DelphiAST is the most up to date parser for Delphi (at least that is open source) because Roman Yankovsky is fixing bugs in a timely manner and is using it for his own plugin (FixInsight) that needs to parse all kinds of source code. It is also derived from the Castalia parser but many fixes and changes have been applied since.

In addition, TestInsight (by Stefan Glienke) also uses DelphiAST and Stefan is quite well at bugging people fixing bugs in open source projects.

DelphiAST works from Delphi XE and up (parts might work in Delphi 2010 and 2009), so ancient Delphi is out.

--jeroen

via: [WayBackTPersistent.com » Blog Archive » The Parsing Problem

Posted in Castalia, Delphi, Development, Software Development | Leave a Comment »

Indy Sockets and getting a description on the connection depends on the direction

Posted by jpluimers on 2018/05/29

From my Indy gitter archive:

@jpluimers
From a TIdIOHandlerSocket or TIdSocketHandle: is it possible to see who has initiated the connection? i.e. if it’s Binding.Peer that initiated to Binding.IP or the other way around?

@rlebeau
A socket is bidirectional, it doesn’t know or care which direction the connection was initially established. You will have to keep track of that yourself based on whether the socket is coming from a client component or a server component.

@jpluimers
I was afraid so. No problem: thanks for confirming.

So I made a helper class for TIdSocketHandle that gets you a SummaryString based on a direction enumeration: TIdSocketHandleHelper.

Notes:

–jeroen

Read the rest of this entry »

Posted in Delphi, Development, Indy, Software Development | Leave a Comment »