Jump to content

RaelB

Members
  • Content Count

    72
  • Joined

  • Last visited

Everything posted by RaelB

  1. Hi, When trying to modify or overwrite an existing file, I get this error: Similarly the file cannot be deleted with SysUtils.DeleteFile. It seems that the file is actually in use within the same application (since if I close the app and restart it the file can be deleted...) Is there any way i.e. via code or perhaps an external tool, I can find out which piece of code is locking/holding the file? Similar to how when there is a memory leak, FastMM can give a report of which code block created the object. Thanks
  2. Thanks all for the suggestions. The DDetours library was really helpful in this situation (in combination with logging), and helped me locate the problem fairly easily. Yeah not that tricky. I just used a TStringList to keep track of opened files (i.e. Handles) and only logged calls to CloseHandle that had an entry in the stringlist (and then removed them..)
  3. RaelB

    Delphi Jobs

    Hi, Are there any well known sites to post Delphi job opportunities? Thanks
  4. I have the following code. It creates 3 tasks and then calls `TTask.WaitForAll(tasks)` : procedure TVideoFrame.AddVideo(....); var ... begin MainTrace.SendStack('AddVideo'); btnPaste.Enabled := False; btnUpdate.Enabled := False; Application.ProcessMessages; ... TTask.Run(procedure() var tasks: array of ITask; ... S: String; Res: Integer; begin Setlength(tasks ,3); MemStream := nil; tasks[0] := TTask.Create (procedure () begin ... end); tasks[0].Start; tasks[1] := TTask.Create (procedure () begin MainTrace.Send('Run Task 1'); S := GetHtml(Url); end); tasks[1].Start; tasks[2] := TTask.Create (procedure () begin ... end); tasks[2].Start; MainTrace.Send('WaitForAll'); TTask.WaitForAll(tasks); EnterCriticalSection(_CritSec); // Don't think it's necessary but just to be safe... try try .... // Process results.. except On E: Exception do MainTrace.Send(E.ClassName, E.Message); end; finally LeaveCriticalSection(_CritSec); end; TThread.Synchronize(nil, procedure() begin btnUpdate.Enabled := True; btnPaste.Enabled := True; .... end); end); end; A normal trace would look like this: It seems a little strange that the trace of `WaitForAll` happens before `Run Task 1`, but maybe that's because it takes a few moments before Task 1 starts to run. Anyway that is not the main issue. The problem is I get a trace like this: Task 1 is running twice, and you can see from the trace in a different thread. I also have a breakpoint in the `GetHtml` method, and I see that in fact it is being called twice. How does this happen? In the main user interface I only click the button once. (as you can see from the code, I disable the button so I can't click it twice anyway..) Thanks Rael
  5. RaelB

    TTask running twice?

    @Der schöne Günther: If I set a timeout the problem does not occur. Thanks a lot for your help. Kudos for noticing the thread ID issue. It is something that can be reproduced quite easily as in my test application.
  6. RaelB

    TTask running twice?

    @Der schöne Günther: Yes, it is a thread ID. What you say is an interesting observation. I have created a small demo (attached). I am not able to reproduce the problem of Task 1 running twice, however on some occassion, the WaitForAll and Run Task 1 calls have the same Thread ID. Here is an example trace. The issue occurred for the first run, but not the others. 0x3374 19:33:20:910 AddVideo 0x6518 19:33:21:125 WaitForAll 0x6518 19:33:21:179 Run Task 1 0x6518 19:33:22:590 --- 0x3374 19:33:24:230 AddVideo 0x47C4 19:33:24:240 WaitForAll 0x1984 19:33:24:240 Run Task 1 0x47C4 19:33:24:875 --- 0x3374 19:33:26:397 AddVideo 0x6130 19:33:26:459 WaitForAll 0x6518 19:33:26:459 Run Task 1 0x6130 19:33:27:247 --- Perhaps if you look at the code you will see something wrong. I am using the open source TraceTool for the logging. (https://github.com/capslock66/Tracetool) TTaskRun Test.zip (btw, I'm using Rio 10.3.2) Thanks
  7. RaelB

    Application does not close

    I have a VCL app, running on Windows 10, Delphi 10.3.2. Sometimes when I press the X button on the main form (to exit the app), the application does not close. The Main window disappears, however the IDE continues in "Running mode" / Debug Mode, i.e. the Program Reset button continues to be Red. When I press the Red button, the program then terminates completely and normally. Not too much going on in the application. What could be causing the program execution to hang in this way? How can I go about trying to figure out the cause? (I have no OnClose or OnCloseQuery handlers) Thanks Rael
  8. RaelB

    Application does not close

    Thanks alot for the suggestions, especially Der schöne Günther - It is indeed related to a TTask not completing. Since the nature of the problem relates more to TTask I am going to follow up the issue over here: https://en.delphipraxis.net/topic/4174-ttask-running-twice/
  9. I had installed a number of components into Delphi 10.2 (Tokyo). One such being Graphics32 which has 2 packages: GR32_R, GR32_D (in Folder Source\Packages\RX2). I subsequently installed the packages from Folder RX3 into Delphi 10.3 Rio. I did a similar thing for a few other components. Then when I tried to open 10.2 again, I got a "runtime error 236", and after pressing "OK", (well it's not really OK, but they don't give me any other choice, do they?) the IDE quits/crashes. Anyway, so I uninstalled some of the other components from 10.2 that I had also installed into 10.3 or simply deleted the bpl files from the output directory, and eventually the IDE now loads without a problem. So now I am trying to install Graphics32 into 10.2 again. Beforehand I have deleted all related bpl/dcp files from the computer (using "everything" (voidtools.com) to locate them). The GR32_R package compiles without problem. Then I try to install GR32_D, and I get this error: As far as I know Delphi 10.2 is vcl250/rtl250, and 10.3 is rtl260, so what does it mean that the call stack is showing both rtl250 and rtl260?
  10. RaelB

    Bungled up component install

    @Uwe and @emailx45, thanks for the tips. I did manage to come right eventually. There were some errant bpl's in C:\Users\Public\Documents\Embarcadero\Studio\20.0\Bpl. Once they were deleted, things started making more sense. Not sure why they were affecting Tokyo installation though. I uninstalled and re-installed a number of components, and also looked through the registry and found a couple of strange entries where some components where referencing a mix of Tokyo and Rio bpl's. (I did a search for rtl260) Not sure how that happened. Maybe due to a custom util that I use 🙂
  11. RaelB

    Can VCL, TMS, DeveloperExpress styles be combined?

    There is an enhanced version of Toolbar 2000 called SpTBXLib. see https://github.com/SilverpointDev/sptbxlib It is actually quite a good option, since it supports VCL Styles, and is High DPI aware. It has been used in PyScripter (https://github.com/pyscripter/pyscripter ) And the author has worked on adding these features (i.e. to be High DPI aware), so I recommend that you check it out. Dev Express has it's own skin system that does not work with the VCL styles. So if your app is using a whole range of components, it is probably a good idea not to use their Toolbar/Ribbon system. Only use individual controls you may need, and you can manually select specific styles that would match VCL Styles, if neccessary. I would suggest for you to first upgrade your project to recent version of Delphi, using SpTBXLib and support high DPI, since that is a fair amount of work in itself. Once your app is up and running, then you could decide on replacing various components if necessary.
  12. Hi, I see if a class has the [TestFixture] attribute, then it will be included in the Test Suite. So it seems that the initialization TDUnitX.RegisterTestFixture(TMyTests); is not neccessary. Maybe it just a relic from the past, or does it still serve a purpose?
  13. I'm using the latest version of superobject from here https://github.com/hgourvest/superobject. It fails to parse attached json file (return nil object). I have no problem using x-superobject, and notepad++ has no problem parsing it. Sample code: var O: ISuperObject; S: string; StrList: TStringList; begin StrList := TStringList.Create; try StrList.LoadFromFile(....'sample.json'); S := StrList.Text; O := SO(S); if O = nil then Memo1.Lines.Text := 'O = nil' else Memo1.Text := O.AsJSon(True); finally StrList.Free; end; Can anyone tell me why it fails? Is there a more recent version of superobject to use? hgourvest repo is no longer maintained. (My project is using superobject, so I don't want to swap to another library..) Thanks sample.json
  14. In Data structures & Algorithm courses, there is usually a discussion on Binary Search Trees and it is seems to be an important data structure. Although in Delphi land I don't see much mention of BST. So I'm curious do people use BST and if so in what cases? or does TStringList mostly replace the need for it. If you do use it, what implementation do you use. Most of the libraries I found don't seem to have a BST, although I did find one in https://github.com/Zeus64/alcinoe
  15. Hello, I'm using 10.3.2. I created a VCL Project, then added a Test Project and Test Case (DUnit). When I run the test project, it runs and exits, without doing anything. What is wrong? I have not made any changes to Conditional Defines, so it should be GUI runner. Thanks Rael
  16. RaelB

    DUnit GUI does not seem to work

    It is unchecked. I did find the problem. There was no call to RegisterTest in initialization section of test unit.
  17. In the SimplePipeline project (from HL-III presentation), if I add a call to sleep in AddOne stage, the program (i.e. UI) blocks for 5 seconds. procedure AddOne(const input, output: IOmniBlockingCollection); var v: TOmniValue; begin for v in input do begin output.Add(v.AsInteger + 1); Sleep(1000); end; end; I would expect this to not block the UI, since it is running in a Thread/Task?
  18. Hello, I am looking at the code from WebSpider demo from HL-III presentation. (The project is just called pipeline) It has code like this: procedure TfrmWebSpider.UniqueFilter(const input, output: IOmniBlockingCollection); var uniqueUrls: TStringList; url : string; begin uniqueUrls := TStringList.Create; try uniqueUrls.Sorted := true; for url in input do begin if uniqueUrls.IndexOf(url) < 0 then begin uniqueUrls.Add(url); output.TryAdd(url); end else if FURLCount.Decrement = 0 then FSpider.Input.CompleteAdding; end; finally FreeAndNil(uniqueUrls); end; end; When I run the demo, I see that the uniqueUrls TStringList is working on all inputs received. This is what we want, but how does this work?, since it is a local variable one would expect/imagine that it goes out of scope each time UniqueFilter is "called". Thanks Rael
  19. Thanks, that is quite amazing. You're saying the loop is actually pausing/resuming depending on queue activity.
×