Jump to content

TurboMagic

Members
  • Content Count

    235
  • Joined

  • Last visited

  • Days Won

    9

Everything posted by TurboMagic

  1. I added unit tests for usage with objects now, testing the OwnsObjects semantics. After fixing a bug in destructor, where I tried to free one object too much (which even got the IDE into trouble) it seems to work as it should. But: I have a memory leak problem with two of the unit tests which I don't know how to fix. These are unit tests testing exceptions and the program flow doesn't seem to get to the point in the test method after the exception has been raised. So the code I put there for cleaning up seems not to be run. The circular buffer doesn't free the objects in such an exception case either. I thought that the user wouldn't expect me to do this. Or would a user expect me freeing objects the user tried to add but couldn't because the buffer is full and my implementation has no "overwrite the oldest items in such a case" semantics? (if I would be thinking about adding this I'd make it configurable)
  2. TurboMagic

    ICS crash

    Hello, in my project I ue ICS V8.62 in Delphi 10.3.3 to detect some devices on the network per UDP. Sometimes my routine works as expected and sometimes it crashes. When it crashes it happens on a call to Socket.MessagePump and inside that one on the call to Application.ProcessMessages. My code is inside an Button click handler and it immediately crashes when pressing F7 in the debugger on Application.ProcessMessages. Since it's a VCL app unit forms is used. Application is assigned. My socket is a plain TWSocket, Proto is 'UDP' and local IP is set to one of the interfaces the computer has to search on that one and LocalPort is 0. I call Socket.Connect and then immediately Socket.MessagePump where it crashes in. Anybody any clue?
  3. TurboMagic

    ICS crash

    Ok, now I better understand. Have to find the time to properly refactor this code. Thanks so far.
  4. TurboMagic

    ICS crash

    Is there really such an OnSessionConnected event on a connection less UDP socket? Remember: I'm using UDP here.
  5. TurboMagic

    ICS crash

    I know that it would be better to not use it. It often works, but just not always. In my case the routine running this shall already return the list of the search so after the code fragment shown in my post above, which is in a loop going through all interfaces determined as plausible ones, I have a waiting loop so received answers which are noted in some list have time to arrive. It's just to find out if a device answers to this request so it is present and to get it's IP.
  6. TurboMagic

    ICS crash

    In order to obtain the list of interfaces I loop through I use IcsGetInterfaceList. This returns 3 interfaces to me: 127.0.0.1 (loopback), which I skip, 10.149.x.y (x and y have valid numbers) which is the IP of that VM I'm running in and the last one is 0.0.0.0. This is my code: Socket := TWSocket.Create(nil); Socket.Proto := 'UDP'; Socket.Addr := '255.255.255.255'; Socket.Port := '1234'; Socket.LineMode := false; Socket.OnDataAvailable := OnUDPDataAvailable; Addr.S_addr := IfList[i]^.iiAddress.AddressIn.sin_addr.S_addr; Socket.LocalAddr := string(WSocket_inet_ntoa(Addr)); Socket.LocalPort := '0'; Socket.Connect; Socket.MessagePump; Socket.SendLine('Hallo?'); OnUDPDataAvailable is declared as method like this: procedure TMyClass.OnUDPDataAvailable(Sender: TObject; ErrCode: Word);
  7. TurboMagic

    ICS crash

    I do set the interface because it is a broadcast to 255.255.255.255 and I want it to go out to all interfaces. But: would that be really connected to the MessagePump crash in Application.ProcessMessages?
  8. TurboMagic

    GUI automation tool for Firemonkey apps ?

    One issue with this is, that there didn't ask enough people about this yet. That's at least what SmartBear the company behind TestComplete told me. Why don't all users liking to have such a thing ask all these vendors about it to show there's demand? I'd start with TestComplete and with Ranorex, which even belongs to Idera but can only do VCL so far, as far as I know.
  9. TurboMagic

    DEC (Delphi Encryption Compendium) has a new home

    Oh and to help your decision what to do: participate in this nice project! Look at missing algorithms and how to implement them so they fit to the architecture or create some more unit tests and turn them in... There's a lot you can do to help! 😉
  10. TurboMagic

    DEC (Delphi Encryption Compendium) has a new home

    Confident now? Remember: this is an open source project so could have implemented the proposed addition of readme.md yourself and either turned it in as issue or created a pull request. Another possible answer would have been: look at the source Luke! 😉
  11. TurboMagic

    FTP and non SSL

    Hello, ICS is now moving to those SSL named classes, which is fine. The question now is: in order to have a FTP client not using SSL is it enough to set the SSLType of the client component to "none"? Best regards TurboMagic
  12. You know that arrays can be concatenated with + since XE7? And delete etc. is available for them as well!
  13. TurboMagic

    Delphi 10.4.1 and the IDE FIx Pack

    One thing which has helped at least some persons is to have a look at where units are put in uses. It often helped to put them into interface section rather than implementation section. And somewhere else I read reports which compared 10.3.3 and 10.4.x both without fix pack and 10.4.x was measurably faster. It might not be as fast yet as everybody wishes, but at least noticeably faster. Oh and somebody lately suspected it might have to do with unit scope like sometimes using SysUtils and sometimes System.SysUtils. But that's a guess only.
  14. Small status update: it looks I have fixed all non object related issues. At least the unit tests for those do run and the same unit tests as implemented for unmanaged types have ben implemented for strings as well and they do run. What's left now is the OwnsObjects semantics and tests for interfaces and regular classes. That's the state of the development branch.
  15. I fixed the Add(Items:TRingbufferArray) now, it might need further test coverage for managed types, but that at least fixed some of the failed string test cases now. Peek no longer crashes and while working on that I had see that Peek had already a value in Result at the beginning of the method. Trying to set that to Default(T) there crashed immediately. So fixing add was the right thing. One thing which still puzzles me and maybe is not even possible: I can have such a generic ringbuffer class which works for non managed types and for reference counted types at the same time. But I don't seem to be able to make it work with objects and OwnsObject semantics, as I cannot call free. I can only call free if I introduce a class constraint. Is this assumption correct and my initial attempt with a class for objects inheriting from the first one is the right one? I already tried to find out how TObjectList<T> from Generics.Collections does it, but I failed to find the free of the items in it...
  16. Hello, given I wanted to distribute a shared object file with map Android app which I need to load dynamically in order to use it. Where would/should I place this on the device? Is .\assets\internal the right path to use when adding this file to deployment manager? If not which is the correct path? When loading it I'd use LoadLibrary like for a DLL, right? And if so, would I use this call for that, give the file name would be test.so? LoadLibrary(TPath.Combine(TPath.Combine('assets', 'internal'), 'test.so'))
  17. TurboMagic

    Loading shared objects on Android

    Yes, I resolved it by upgrading the student to 10.3.3 and then using the permission request solution provided there. It works now and if you check the github repo you'll see it's in there as well 😉 So if you need to create a video on Android you can use that solution right away 😉 The only thing missing there is an iOS implementation as I don't have any iPhone and Mac.
  18. Access violation, but I don't know why. Ok, I started to write some further unit tests now as a start to fix the issues this implementation has in order to learn some things. I copied the integer unit tests which run fine and reworked those into string ones. so <T> is string now. One of the tests calls this method: function TRingbuffer<T>.Peek(Index: UInt32): T; var reminder : UInt32; begin if (Index < Count) then begin // Puffer läuft derzeit nicht über seine obere Grenze hinaus if ((FStart+Index) < Size) then result := FItems[FStart+Index] else begin // um wieviel geht es über die obere Grenze hinaus? reminder := (FStart+Index)-Size; result := FItems[reminder]; end; end else raise EArgumentOutOfRangeException.Create('Invalid Index: '+Index.ToString+ ' Max. Index: '+Count.ToString); end; FItems at that point contains 5 items, FStart is 1 and Index is 1 as well. It crashes with EInvalidPointer at this line: result := FItems[FStart+Index] When debugging the asm I see some call to freemem. I would have expected that Peek would simply return a string with the contents of FItems[FStart+Index] and that it would increase the reference counter of the string stored in FItems[FStart+Index]. This Peek method is called in a loop over the complete ringbuffer to check if its contents is the expected one. For Index = 0 it doesn't crash. What is wrong on my assumption? And the other question would be: should peek increase reference counter of reference counted types (string, interface...) or return a copy which is not reference counted and thus completely detached from the buffer inside the ring buffer class? And if "detached" should be preferred, how to do the copying properly?
  19. TurboMagic

    Loading shared objects on Android

    By the way: the whole thing is now available here: https://github.com/rmesch/Bitmaps2Video Android 64 bit support for the sample provided should be available soon, I need to commit it and create a pull request. Which I'll do in a minute.
  20. TurboMagic

    Byte and Integer

    I guess it's rather a missing overflow check in the server software for the vote counter 😉 But I guess this Jira software is not written in Delphi (oh, if it were overflow checking would be available and this issue would have been caught during testing...) Of course I voted for this as well.
  21. If your Delphi version is new enough to support generics: Create a TDictionary where the key is the number (ID) of the question and the data is the number of points of the answer selected. Store the ID of the question in the tag of the tab the question is on (assuming one tab holds one question, if not put each question in some container which has a tag, it doesn't matter if that container is visible or not). Store the number of points associated with an anwer to the question in the tag of the checkbox or radio button for the answer. If somebody selects an answer look in the list if there is already some entry with hat question ID. If yes, remove it and add it again with the new data or overwrite the data. When the questionaire is finished iterate through the dictionary and count the points. uses Generics.Collections; type // first one is the key = question ID, last one the data asociated with the key in your case the points. TAnswerDict = Dictionary<integer, integer>; var Answers:TAnswerDict; Pair: TPair; Points: Integer; begin Answers := TAnswerDict.Create; try Answers.Add(1,3); Answers.Add(2,1); Points := 0; for Pair in Answers do inc(Points, Pair.Value); finally Answers.Free; end; end. The code has not been tested but it should be a starting point for you, if still relevant.
  22. Ok, besides accepting Uwe's pull request I did some changes to the Peek method in order to make it more compatible with managed types. Feel free to look at it and critisise where necessary, I admit that I didn't test it yet (need to create unit tests) but it's getting late enough already. I can only learn from it. And if somebody wants to contribute: feel free. As far as I understood Stefan, one could get rid of the 2nd class implemented for managed types altogether by using IsManaged and calling the appropriate code to release the items where necessary.
  23. Yes, unit tests for managed types would still have to be created. And yes one would have to do some for strings and interfaces as well as tey're of course managed as well. I contributed this to the public because it will not help the community if one always consumes only without giving. That also means, if there's interest in this library others should contribute fixes etc. as well. My main open source commitment currently is DEC (Delphi Encryption Compendium) and that's enough work.
  24. Thanks! That could be fixed at the place where items get taken out of the list. I guess one would have to make a distinction of cases via IsManagedType(T) so one can keep using Move for non manages types and assignment operator for managed ones. Would that be correct?
×