Jump to content

Leaderboard


Popular Content

Showing content with the highest reputation on 10/31/23 in Posts

  1. Yellow, https://quality.embarcadero.com/browse/RSP-42524 Delphi comes with very old PCRE (8.45) and it'll wont get any updates according to pcre.org. Latest 10.4.2 : https://github.com/PCRE2Project/pcre2/releases -Tee-
  2. You didn't mention the Delphi version, but since Delphi 11 you can use the appropriate Sort overload taking a comparer, start index and count. procedure Sort; overload; procedure Sort(const AComparer: IComparer<T>); overload; procedure Sort(const AComparer: IComparer<T>; Index, Count: Integer); overload;
  3. It should be enough to use IdOpenSSLSetLibPath.
  4. Remy Lebeau

    How to free TListView Objects (String)

    As you already know, you need to use the TListView.OnDeletion event to dispose of the TListItem.Data memory that you are allocating. If you read the documentation for StrAlloc(), the correct way to free that memory is with StrDispose(), not FreeMem(): procedure TMainFrm.LV_DataDeletion(Sender: TObject; Item: TListItem); begin if Item.Data <> nil then begin StrDispose(PChar(Item.Data)); Item.Data := nil; end; end; Alternatively, a slightly easier way is to use a normal String and let the compiler manage it. A String is implemented as a pointer, and you can store that pointer in the TListItem.Data. You would just have to ensure its reference count is incremented while stored in TListItem.Data, and decremented when you are done using it: var i : Integer; ListItem : TListItem; PObject : Pointer; begin for i := 0 to 3 do begin ListItem := AList.Items.Add; ... PObject := nil; String(PObject) := '...'; ListItem.Data := PObject; end; procedure TMainFrm.LV_DataDeletion(Sender: TObject; Item: TListItem); var PObject: Pointer: begin if Item.Data <> nil then begin PObject := Item.Data; Item.Data := nil; String(PObject) := ''; end; end; var sPath : string; begin if (LV_Data.Items.Count > 0) AND (LV_Data.ItemIndex <> -1) then begin sPath := String(LV_Data.Items[LV_Data.ItemIndex].Data); end; That being said, a much safer and cleaner solution is to not use the TListItem.Data property at all. Instead, derive a new class from TListItem and add a String member to it, then use the TListView.OnCreateItemClass event to let TListView create instances of your derived class: type TMyListItem = class(TListItem) public Path: string; end; procedure TMainFrm.LV_DataCreateItemClass(Sender: TCustomListView; var ItemClass: TListItemClass); begin ItemClass := TMyListItem; end; var i : Integer; ListItem : TListItem; begin for i := 0 to 3 do begin ListItem := AList.Items.Add; ... TMyListItem(ListItem).Path := '...'; end; var sPath : string; begin if (LV_Data.Items.Count > 0) AND (LV_Data.ItemIndex <> -1) then begin sPath := TMyListItem(LV_Data.Items[LV_Data.ItemIndex]).Path; end; No mess, no fuss. The memory is managed for you, and will be cleaned up automatically, no OnDeletion handler needed.
  5. I have no idea why and how you are building a DLL, but from the size I can tell that you are pulling in a large chank of the Delphi RTL. Not except the source code.
  6. DiGi

    Delphi 11.3 : FORSAKEN

    Wait what? Nobody is talking about broken refactoring?
  7. Remy Lebeau

    curl-example for POST works, Delphi code throws an 404

    On a side note, you are leaking the SSLIOHandler object. You are not assigning it an Owner, so you need to Free() it. Otherwise, I suggest assigning the TIdHTTP at its Owner, eg: var HTTP := TIdHTTP.Create(nil); try var SSL := TIdSSLIOHandlerSocketOpenSSL.Create(HTTP); SSL.SSLOptions.SSLVersions := [sslvTLSv1_2]; HTTP.IOHandler := SSL; HTTP.Request.CustomHeaders.Values['Authorization'] := 'Bearer ' + bearer; var Params := TIdMultiPartFormDataStream.Create; try filename := StringReplace(Training.filename, '.ictt', '.fit', [rfIgnoreCase]); params.AddFile('file', filename); ResponseStr := HTTP.Post('https://pushinglimits.club/api/oauth/upload_single_fit_file', Params); finally Params.Free; end; finally HTTP.Free; end;
  8. Remy Lebeau

    curl-example for POST works, Delphi code throws an 404

    Did you notice the URL is different in the response HTML? The leading /api was removed. That implies to me (without proof to the contrary - does TNetHTTPClient offer any kind of debug output?) that the server probably didn't like something about the initial request and issued an HTTP redirect to a new URL that happens to not exist. Sounds like a problem with the way the server is processing TNetHTTPClient's reequest, considering the same request in TIdHTTP works.
  9. IMHO using inline variables and with together looks somewhat strange.
  10. philipp.hofmann

    curl-example for POST works, Delphi code throws an 404

    Info: I was successful with the following code (using Indy now): with TIdHTTP.Create(nil) do try var FIdSSLIOHandlerSocketOpenSSL:TIdSSLIOHandlerSocketOpenSSL:=TIdSSLIOHandlerSocketOpenSSL.Create(nil); var Params: TIdMultiPartFormDataStream; filename:=StringReplace(Training.filename, '.ictt', '.fit', [rfIgnoreCase]); FIdSSLIOHandlerSocketOpenSSL.SSLOptions.Method := sslvTLSv1_2; FIdSSLIOHandlerSocketOpenSSL.SSLOptions.SSLVersions := [sslvTLSv1_2]; IOHandler := FIdSSLIOHandlerSocketOpenSSL; Request.ContentType := 'multipart/form-data'; Request.CustomHeaders.add('Authorization: Bearer ' + bearer); Params := TIdMultiPartFormDataStream.Create; try params.AddFile('file', filename, GetMIMETypeFromFile(filename)); ResponseStr := Post('https://pushinglimits.club/api/oauth/upload_single_fit_file', Params); finally Params.Free; end; finally Free; end;
  11. David Heffernan

    Profiler for Delphi

    That's not what AQtime does. Vtune is essentially analogous to AQtime but far more capable. You aren't going to find this magic solution that you want, whereby you wave a magic wand and your program is suddenly much faster. Optimisation though is going to take effort from you to understand your program. No shortcuts.
×