Jump to content

Navid Madani

Members
  • Content Count

    41
  • Joined

  • Last visited

Everything posted by Navid Madani

  1. Navid Madani

    Problems closing IDE

    The Parnassus plugins are still maintained by David Millington, who probably has his hands full with C++ Builder's Clang adoption. I don't think many existing C++ projects will be transitioned to C++ Builder, if not only for cost and C++ Builder's maintenance history. Meanwhile, the global C++ to Rust transition gaining momentum is a different story.
  2. Navid Madani

    Problems closing IDE

    I, too, noticed that my IDE is significantly faster and more responsive without the Parnassus plugins. I have not had any crashes after a fresh install with the avoidance of all Parnassus plugins. Meanwhile, MMX has always been as solid as possible - thanks to Uwe Raabe.
  3. I cannot tell what your code is doing for sure. However, your question is also general about how to tackle asynchronous programming in Object Pascal. You are calling procedures in your class that do not return any values, where a more functional approach might be better suited for your needs. Assuming the consumer is in the main thread that you do not want to lock, you have a couple of options: You could use a TThread descendent class and set its OnTerminate even to a TNotifyEvent in your main thread (i.e., a method with the procedure(Sender: TObject) signature) that will receive the TThread descendent before its destruction and allow you to extract the necessary data. Alternatively, you could use an IFuture<T> (System.Threading) and query its value when you are ready, but this can be a blocking call if your future result is not yet available.
  4. Is anyone else experiencing frequent (~ hourly), random IDE freezes, and unresponsiveness on Windows ARM, even with small and new projects? Task Manager shows 0% CPU activity. The only recourse has been to force-quit the IDE using the Windows Task Manager and restart. A lot of productivity has been lost as a result. I have installed Navigator, Bookmarks, TwineCompile, Bonus KSVC, Radiant Shapes, and MMX Code Explorer. Oddly, GetIt claims that the "12.1 Patch 1 1.0" previously applied is not installed, and clicking "Install" does nothing. I have already tried removing the IDE plugins without resolution. And just to add a rant, this is now my second uninstall/reinstall cycle of 12, which is enough for me. What is the best way to investigate (log files, etc.)? Thanks in advance.
  5. Navid Madani

    RAD Studio 12 Update 1 IDE Instability

    Just an update: I went the long way: after a fresh installation of Windows ARM via Parallels, RAD Studio 12.1, and MMX Code Explorer (and avoided all Parnassus plugins), it looks like a fix. The IDE is faster, and no longer sluggish. Thanks again to everyone for your suggestions.
  6. Navid Madani

    RAD Studio 12 Update 1 IDE Instability

    Thank you to every one. I changed the emulation settings to strict execution: I think it did cause some improvement. I had already checked all paths and they were good. I also have no networked drives in any of the library paths, which can cause problems. I do not not believe that those Parnassus terms still apply. The new terms are Embarcadero's and can be found at https://getitnow.embarcadero.com/Navigator-12-1.6.5.2/ I am so used to Navigator's ctrl-G for jumping around the code ... what do you use? As mentioned, I uninstalled all plugins and still had a freeze. But I can't disagree that the freeze might be due to network activity. Thank you all again!
  7. Navid Madani

    RAD Studio 12 Update 1 IDE Instability

    Thanks. My main concern is the IDE freezing. The 'Problem Reports' Control Panel does not include the freezes, and I could not find any entries in Windows 'Event Viewer' either. Does anyone have any thoughts as to how I could investigate further?
  8. RAD Studio 11.3 (2024 build) was posted on my.embarcadero.com on 2/20/2024. Does anyone have further details about this re-release? Thanks in advance.
  9. Navid Madani

    When will be binding to Swift libraries possible ?

    Looking at Swift 5.9 release notes, there is talk of bidirectional C++ interoperability. Has anyone tried it? https://www.swift.org/documentation/cxx-interop/
  10. TDirectory.GetFiles in System.IOUtils has a bug on macOS: In the returned dynamic string array, valid files with names that contain three or four consecutive periods are not included. I ended up having to use macOS system functions instead. If it would help others who could run into this problem, my solution is below. Please post if you find any errors. macOS programming is certainly not my forte. unit Nm.IOUtils; interface uses System.SysUtils , System.Types {$IFDEF MACOS} , Macapi.ObjectiveC , Macapi.CocoaTypes , Macapi.Foundation , Macapi.Helpers {$ENDIF} ; {$IFDEF MACOS} type EItemType = (itFiles, itDirectories); EItemTypes = set of EItemType; function macOS_GetDirectoryContents(const DirectoryPath: string; const ItemTypes: EItemTypes): TStringDynArray; {$ENDIF} implementation {$IFDEF MACOS} function macOS_GetDirectoryContents(const DirectoryPath: string; const ItemTypes: EItemTypes): TStringDynArray; const ARRAYSIZEINCREMENT = 32; var FileManager: NSFileManager; URL, FileURL: NSURL; FileEnum: NSDirectoryEnumerator; Options: NSDirectoryEnumerationOptions; Error: NSError; IsDirectoryVal: Pointer; IsDirectory: Boolean; Candidate: string; i: Integer; ArraySize: Integer; begin FileManager := TNSFileManager.Wrap(TNSFileManager.OCClass.defaultManager); URL := TNSURL.Wrap(TNSURL.OCClass.fileURLWithPath(StrToNSStr(DirectoryPath), True)); Options := NSDirectoryEnumerationSkipsSubdirectoryDescendants; FileEnum := FileManager.enumeratorAtURL(URL, nil, Options, nil); FileURL := TNSURL.Wrap(FileEnum.nextObject); ArraySize := ARRAYSIZEINCREMENT; SetLength(Result, ArraySize); i := 0; while Assigned(FileURL) and FileURL.isFileURL do begin IsDirectoryVal := nil; if FileURL.getResourceValue(@IsDirectoryVal, StrToNSStr('NSURLIsDirectoryKey'), @Error) and Assigned(IsDirectoryVal) then begin if i >= ArraySize then begin Inc(ArraySize, ARRAYSIZEINCREMENT); SetLength(Result, ArraySize); end; Candidate := UTF8ToString(FileURL.path.UTF8String); IsDirectory := TNSNumber.Wrap(IsDirectoryVal).boolValue; if IsDirectory then begin if (itDirectories in ItemTypes) then begin Result[i] := Candidate; Inc(i); end; end else begin if (itFiles in ItemTypes) then begin Result[i] := Candidate; Inc(i); end; end; end; FileURL := TNSURL.Wrap(FileEnum.nextObject); end; SetLength(Result, i); end; {$ENDIF} end.
  11. I have encountered a strange problem: Delphi Athens is running via Parallels on Apple Silicone. In the following demo, none of the destroyers are called when targeting macOS ARM 64, while everything works OK targeting Windows). Also, I can get the Windows target to report the memory leak when I comment out fDebug.Free in FormDestroy, but not with macOS ARM 64. Can anyone else reproduce this? Am I missing something? Thanks! unit Unit1; interface uses System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants, FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs; type TForm1 = class(TForm) procedure FormDestroy(Sender: TObject); procedure FormCreate(Sender: TObject); private fDebug: TObject; public destructor Destroy; override; end; var Form1: TForm1; implementation {$R *.fmx} // TForm1.FormDestroy is not called when Target is macOS ARM 64-bit procedure TForm1.FormDestroy(Sender: TObject); begin ShowMessage('FormDestroy Called'); fDebug.Free; end; // TForm1.Destroy is not called when Target is macOS ARM 64-bit destructor TForm1.Destroy; begin ShowMessage('Destroy Called'); inherited; end; procedure TForm1.FormCreate(Sender: TObject); begin fDebug := TObject.Create; end; end.
  12. https://quality.embarcadero.com/browse/RSP-26436 Such a fundamental pattern being broken, it could be a sign of more ominous problems.
  13. In the DUnitX tests below, the first 4 cases fail: the last character is omitted. It seems that for each hyphen added after the first, an extra character from the end is not written to the TClientDataSet field. Is this normal behavior? Thanks in advance. unit uCDSTest; interface uses DUnitX.TestFramework , Data.DB , Datasnap.DBClient ; type [TestFixture] TClientDataSetTest = class private fCDS: TClientDataSet; public [Setup] procedure Setup; [TearDown] procedure TearDown; [Test] [TestCase('Test0','S0002-9270(99)00035-0')] [TestCase('Test1','S0002-9270(99)00035-1')] [TestCase('Test2','S0002-9270(99)00035-2')] [TestCase('Test3','S0002-9270(99)00035-3')] [TestCase('Test4','S0002-9270(99)000353')] [TestCase('Test5','S00029270(99)00035-3')] [TestCase('Test6','S00-02-9270(99)00035-3')] [TestCase('Test7','S00-02-92-70(99)00035-3')] procedure TestCDS(const AValue : string); end; implementation const cFieldname = 'AFieldName'; procedure TClientDataSetTest.Setup; var fd: TFieldDef; begin fCDS := TClientDataSet.Create(nil); fd := fCDS.FieldDefs.AddFieldDef; fd.Name := cFieldname; fd.DataType := ftString; fCDS.CreateDataSet; end; procedure TClientDataSetTest.TearDown; begin fCDS.Free; end; procedure TClientDataSetTest.TestCDS(const AValue : string); begin fCDS.Insert; fCDS.Edit; fCDS.FieldByName(cFieldname).AsString := AValue; fCDS.Post; Assert.AreEqual(AValue, fCDS.FieldByName(cFieldname).AsString, 'Assignment failed.'); end; initialization TDUnitX.RegisterTestFixture(TClientDataSetTest); end.
  14. Navid Madani

    TClientDataSet's odd behavior with hyphens in string fields

    Duh! Thank you! I should have tested adding other characters on the tests. When the REST API added the hyphens, that's when everything broke down ...
  15. Thanks, David. No, I don't shun any value types, but we're talking about large record sets, too large for the stack. I was referring to bugs that creep in when the integrity of (mutable) data on the heap is not guaranteed, when variables are mutable. Certainly, records can emulate data integrity patterns with private fields, but that approach is not front and center with Delphi records. Interfaces too can cause memory leaks, and be complicated when weak references are needed. But again, it's an overall safer pattern in Delphi, at least in my experience. Interfaces also help write testable and more easily maintainable code by keeping things decoupled. And yes, try-finally blocks are written by the compiler, but compilers ultimately write machine code. That's the whole purpose of using a high-level language: so we don't have to write all that code. It helps keep things readable. I agree that it's the same basics with memory allocation and release patterns. But again, different languages implement them in different ways, and some patterns are more idiomatic for a specific language, as in this case. I think our discourse is more over language semantics than technical. While I understand and appreciate your points, I am not convinced to change my approach to large amounts of data on the heap.
  16. Navid Madani

    TClientDataSet's odd behavior with hyphens in string fields

    Thank Dmitry, but I did not grasp the implication of your terse comment. The size of string fields needs to be set?
  17. Value types are copied unless passed by reference. That can impact performance. Classes and interfaces would be more efficient. Interfaces can emulate data immutability and prevent bugs. Interfaces obviate the need for try-finally blocks, keep code cleaner and easier to maintain. Interfaces can prevent memory leaks. It is not always a simple case of memory allocation/de-allocation with records on the heap. There can be issues with access violations, and hard to detect bugs if record pointers are accessed but point to invalid data. Again, I said that is what I do when using Delphi as opposed to C.
  18. Depending on what you are trying to do, keeping records on the heap could become an anti-pattern and cause problems. For one, your records could be duplicated on assignments, on the stack, and if your application relies on their consistency, bugs can creep in. Unlike languages like Rust and Swift, all variables in Delphi are mutable. If I needed a large dataset on. the heap, I would either wrap the records in a class or define a class, and in order to maintain their integrity, I would use interface references to access them and avoid memory leaks. Just my two cents.
  19. Navid Madani

    How to test FDConnection with SQLite

    Check the Params TStrings property to check for the database name and other properties. procedure TForm1.Button1Click(Sender: TObject); begin if FDConnection1.Params.Values['Database'] <> '' then ShowMessage('Database name is ' + FDConnection1.Params.Values['Database']); end;
  20. Navid Madani

    TClientDataSet's odd behavior with hyphens in string fields

    Reported as bug: RSP-44009.
  21. When the project file has conditional compiler directives, the source indexer omits files that should be included. For example, in the uses section of the .dpr file quoted below: {$IFDEF MSWindows} uWinSpawn in '..\Units\Win\uWinSpawn.pas', uReadPipeThread in '..\Units\Win\uReadPipeThread.pas', {$ENDIF } {$IFDEF MACOS} uMacOSSpawn in '..\Units\macOS\uMacOSSpawn.pas' {$ENDIF } uProcessSpawn in '..\Units\uProcessSpawn.pas'; When MSWindows is defined and not MACOS, in my case, ..\Units\uMacOSSpawn.pas is indexed, but not ..\Units\uProcessSpawn.pas. Thanks to Uwe for his outstanding work maintaining and updating MMX Tools. Navid
  22. Navid Madani

    MMX 15.1.8 build 2580: Possible Source Indexer Bug?

    I'll take that back: not a bug - each time I add a unit to the project, the IDE messes up the conditional defines, sometimes inserting two uses clauses into the DPR. While editing, I also erroneously deleted the comma after the unit in the excluded MACOS clause. Restoring the missing comma allowed MMX to index everything.
  23. Is it just me, or is the entire refactoring functionality in 12/Athens broken? Sync Prototypes does not work, refactor rename just replaces the selected identifier instance, and ignores every other identifier occurrence including those in the visible file, ...
  24. Navid Madani

    Delphi 12 Athens Refactoring Broken

    Deprectated? https://docwiki.embarcadero.com/RADStudio/Athens/en/Refactor_Menu https://docwiki.embarcadero.com/RADStudio/Athens/en/Rename_symbol_name_(Delphi) ...
×