Jump to content

JonRobertson

Members
  • Content Count

    171
  • Joined

  • Last visited

  • Days Won

    3

Posts posted by JonRobertson


  1. I installed it but I was not able to use it.

     

    The first issue is that the BPL is not signed and our corporate policy would not allow Delphi to load the BPL. I worked around the issue by signing the BPL with our code signing certificate.

     

    The next issue is that DelphiLint is unable to download SonarDelphi from GitHub. A better error message would be appreciated. The dialog simply says to check my internet connection, which is definitely working at the moment.

     

    I am about to download SonarDelphi manually. Hopefully the documentation will have instructions on configuring DelphiLint so it "knows" that SonarDelphi is installed.


  2. 4 hours ago, Clément said:

    If I [...] rename the unit the project doesn't compile.

    That is why I would rename the unit. When the project fails to compile, the error should occur in the unit that is "using" the unwanted unit. Note that it often requires a Build rather than just a Compile to locate the unit containing the reference.


  3. 6 minutes ago, shineworld said:

    So, to use a 3rd part DLL made with C++, eg: MSVC or C++Builder itself,  it is necessary to create a Proxy C DLL with C++ Builder.
    https://blogs.embarcadero.com/how-to-use-a-c-dll-in-any-delphi-program/

    Yes, unless you have the C++ source and wanted to create a C++ DLL that could be used from Delphi using a COM interface.

    http://rvelthuis.de/articles/articles-cppobjs.html


  4. 16 minutes ago, Uwe Raabe said:

    Using the same TVirtualImageList for several forms will fail if these forms are placed on monitors with different DPI

    Thanks for letting me know. I do not have much experience with the various DPI issues.


  5. 6 hours ago, Der schöne Günther said:

    The IDE supports placing frames at design time. While that enables sharing or referencing components like ImageLists

    Not sharing components, or sharing a single instance of a component. If a frame contains an ImageList and is used on multiple forms, each form creates a separate instance of the frame and all components on the frame. So you have multiple copies of the same ImageList, but those forms are not "sharing" the ImageList.

     

    I use a TDataModule for resources and components, such as TImageCollection and TVirtualImageList, that are used by multiple forms.


  6. 4 hours ago, Rollo62 said:

    It worked for me too, but placing a SubForm on a main form turns out to assign (copy) all components parents from the SubForm to the main form.

    I don't agree with this.

              frmView := TfrmView.Create(Self);
              frmView.Parent := tsView;

    This makes the tabsheet the parent of the form. So now all controls on the form have the tabsheet as a grandparent, if you will. But the parent of each control on the subform is not changed to the tabsheet.


  7. 3 hours ago, Lajos Juhász said:

     

    I don't know what the IDE uses, but it is not usable on a mixed DPI multi monitor systems. I was forced to debug an aplication in such a scenario. Both the application and the IDE failed.

    My laptop's "recommended" scaling is 125%. At the office, I have two external monitors, each has recommended scaling of 150%.

     

    I started this position eight months ago. The first project that I worked on uses a "tabbed interface", similar to web browsers, where each form is created and parented to a TTabSheet. Nothing more than setting frmSomeForm.Parent := tsSomeForm. Every form, except a few "dialog box" forms, are embedded in the app's main form.

     

    Two of the forms in that application also contain a TFrame, which is on the form at design-time rather than created and attached at run-time.

     

    I have not seen any DPI related issues since switching to DPI Unaware mode when launching BDS.


  8. 4 minutes ago, Kas Ob. said:

    Delphi/Pascal is easier to produce memory safe code and executables.

    I would agree that it is easier than using C++, among others.

     

    But Delphi is also just as capable of generating executables that overwrite memory or have vulnerabilities, due to poor or improper memory handling. In that sense, I don't think Delphi has better memory safety than C++.

     

    And certainly capable of being used to intentionally expose memory related vulnerabilities.


  9. The one difference that I encounter is that a "SubForm" is not linked to anything at design-time. If you have placed a TFrame anywhere in the project, the frame is now linked and "in use" by the designer.

     

    I often encounter "has open descendents [sic] or linked modules. Cannot close." dialogs when trying to modify a frame, TDataModule descendant, or a base form (when using form inheritance). This often happens when I try to switch between form designer and DFM text editing. I can close every unit that the editor/designer has open, re-open the "linked" unit, and still can't switch to text DFM. At that point, I could just edit the DFM in my favorite text editor, except Delphi will not reload the DFM once my edits are finished. So I typically restart the IDE.

     

    I still use D7 occasionally. While this does happen in D7, and I remember it in D6, there seem to be more scenarios where D11 refuses to switch and D7 doesn't.


  10. 16 hours ago, Stefan Glienke said:

    This would be called Tracing garbage collection

    Although I've been programming for 42 years, I know so little compared to how much there is to know. So thanks for the link.

     

    My preference is to handle/control the lifetime of memory allocations based on the purpose and usage, rather than leaving it to algorithms that attempt to figure that out.

     

    The code below is a hand-slap, don't ever do that. It was also the first thought I had to show that the memory manager does not "know" anything, unless it is told.  Algorithms may be written to read my mind. But I digress...

    function BadAlloc(Size: NativeInt): String;
    begin
      var pStr: PChar;
      GetMem(pStr, Size);
      StrPCopy(pStr, 'bad code');
      Result := IntToStr(Integer(pStr));
    end;
    
    procedure BusyProc;
    begin
      var myBad := BadAlloc(20);
      // lots of other busy code...
      ShowMessage(PChar(StrToInt(myBad)));
    end;

    My expectation is that tracing garbage collection could release the 20 byte block immediately after BadAlloc returns, or any other time before the ShowMessage is executed.


  11. 11 minutes ago, FaFaFooey said:

    Can a memory manager for Delphi be modified or written to be as close to a garbage collector without being one?

    The memory manager would have to "know" when the memory was no longer needed, otherwise it would release allocated memory too soon.

     

    Unless I don't understand the question, it sounds like Automatic Reference Counting, which was already attempted. And it was later removed for a few reasons.


  12. 1 hour ago, Rollo62 said:

    Who cares, it sounds good anyway

    I do, and I suspect many others do as well. What I was mostly disappointed about was the statement below.

    Quote

    the use of formal methods for static code analysis, in particular focused on security. We have been seeing a growing interest in this area also for Delphi, and we have been promoting third party tools that help in this space.

    The company promoted in that link and the accompanying webinar was DerScanner. I watched the webinar last September and it intrigued me enough to ask approval to pursue having a small project analyzed and review the results.

     

    Their home page had a short form to request a trial. Instead of providing a trial, I received an email that I will share, since it is typical marketing:

     

    Quote

    Our DerScanner product is a high-tech comprehensive application security solution that combines static (SAST), dynamic (DAST) and software composition (SCA) analysis methods in a single interface. DerScanner allows to identify vulnerabilities and undocumented features in the code of mobile and web applications. DerScanner is a unique tool that is able to analyze both source and binary code. It is the world leader in the number of supported programming languages (36 languages) that can also understand polyglot applications and significantly reduces false positives with its own Fuzzy Logic Engine patented technology Please let me know what exactly you are interested in so we may assist you in the best way.

     

    I responded that I requested a trial from their home page. The reply was that my request for a trial was forwarded and included a whitepaper that "describes the key features of DerScanner". One of the key features was that DerScanner could analyze 36 programming languages, "even obsolete Delphi, COBOL and Visual Basic 6.0". I also noticed that the short form on their home page was changed from a trial request to "Get a Demo".

     

    They did provide a trial account and I submitted the project along with a couple third-party libraries (with each vendor's permission). The resulting report contained thousands of incorrect analysis. One of the more prominent and obnoxious was “hardcoded encryption key”, for code such as "ctrlKey := GetKeyState(VK_Control) < 0", and every other line of code that contained these three characters in sequence: k e y, including static text.

     

    The analysis that DerScanner provided was a complete joke and a total waste of time. The trial included two scans for free (I only used one), additional scans after the trial were $1,000 per scan. Sure, my employer can say "Yes, we are concerned about security. We had our application analyzed by a third-party that specializes in code analysis. They used a highly sophisticated tool named grep to analyze our code for vulnerabilities."

     

    I am particularly disappointed in the recent statement because I had direct contact with Ian regarding my frustrating experience, and the laugh that I had after reviewing the generated report.

    • Like 1
    • Thanks 2
    • Haha 4

  13. I would suspect it depends on your usage and needs. I used to configure and manage VMs for a dev/QA test environment, initially using VirtualPC and later migrating to Hyper-V.

     

    Today I do not use VMs as often as I used to. I use Parallels Desktop on my MacBook Pro and VirtualBox on my other laptops.


  14. 4 hours ago, jesu said:

    Closing Delphi and deleting dcus so far has solved it, but it doesn't improve chances that we upgrade. Is this a known problem?

    Does it occur again on the same project? DCUs are Delphi version specific (with a couple of notable exceptions). If Delphi 12 successfully your project after you manually deleted DCUs, but this error occurs again in Delphi 12 building the same project, then something is wrong. Perhaps something is off with your Delphi 12 install or environment. Or perhaps it is a defect in the compiler. Open a support ticket as DelphiUdIT suggested.

     

    An online search reveals a couple other things to try in the meantime. If it is a large project, go to Project Options, Building, Delphi Compiler, and set "Use MSBuild externally to compile" to true and see if that helps. Another suggestion is to disable the compiler's use of an unit cache. This is done by modifying the registry entry HKEY_CURRENT_USER\SOFTWARE\Embarcadero\BDS\22.0\Compiling\Enable Unit Directory Cache.


  15. 6 hours ago, David Schwartz said:

    While Pascal has Pointers, they have pretty much disappeared from use

    Not on my system. A simple grep of 51,132 .pas files tells a different story. (Just a whole word search with no context).

    pointer, 150,825 hits in 7,939 files

    ^,  110,934 hits in 6,326 files

     

    Searching a few more popular (and current) open source libraries reveals significant use in current code. 8,625 hits was the highest I found in a single open source library on my system.

     

    Delphi 12 source\rtl\sys - 2,837 hits. 1,871 hits in system.pas alone.

    Delphi 12 source\rtl\common - 2,951 hits

    Delphi 12 source\rtl\win - 6,442 hits. I was surprised to see 2,243 of those are in the winrt subfolder.

    Delphi 12 source\rtl\osx - 4,751 hits

     

    Then there are thousands of casts using TObject(), such as storing object references in the legacy TList or, ahem, storing references or pointer values in TComponent.Tag.

     

    If I overlook RTL usage, VCL usage, and poor coding practices, every day Delphi coding uses pointers. At least I do.

     

    // lstOfItems is a pointer. You may say it is a "typed pointer", but it is still a pointer. ;)
    var lstOfItems := TStringList.Create;

     


  16. On 3/4/2024 at 1:23 PM, Stano said:

    Setting it while running doesn't help?

    From the docs, KeepDesignConnected is not about auto connecting to the design-time connection. If the project is built with Connected set to True, then loading the form/datamodule/components will set the property's state to True when the form is loaded, making (or trying and failing) to make the connection before your code starts. That is standard VCL component behavior for published properties.

     

    By setting KeepDesignConnected to False, the component will not make a connection during form load, even if the Connected property was saved as true.

     

    There are several other workarounds. There are add-ons that will set various property values every time the form is saved. Personally, I derive a component and change the stored attribute of the property, like so

     

      TmyADOConnection = class(Data.Win.ADODB.TADOConnection)
      published
        property Connected stored False;
        property LoginPrompt stored False;
      end;

     


  17. 2 hours ago, DelphiUdIT said:

    LOL, I miss we are in a P4D section, sorry.

    Same LOL here. My first reply would have been much shorter had I paid attention to the forum. One of the dangers of reading from Recent Activity, I suppose. :classic_wink:

×