Need help with "Progress indication" in WCX plugins

Discuss and announce Total Commander plugins, addons and other useful tools here, both their usage and their development.

Moderators: Stefan2, white, sheep, Hacker

Post Reply
User avatar
rg_software
Junior Member
Junior Member
Posts: 7
Joined: 2009-08-06, 12:59 UTC

Need help with "Progress indication" in WCX plugins

Post by *rg_software » 2018-11-30, 11:21 UTC

I am working on a pseudo-packer plugin for converting audiofiles (similar to Audioconverter that we had to leave behind in 32-bit era).
One problem I faced is progress bar. I think I understand how to implement it, but there is one weird thing that is either my or TC bug.

When I run my plugin first time, the indicator works correctly. However, when I try to compress more files, it starts counting files as if the same session is continued. See, here it thinks that the first file in the second session is actually file #20:

Image: https://i.ibb.co/BfK952W/Clipboard01.png

I noticed the same behavior in Graphics Converter plugin, so I am puzzled. Any ideas?

User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 36544
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Re: Need help with "Progress indication" in WCX plugins

Post by *ghisler(Author) » 2018-12-03, 19:53 UTC

I assume that you use the callback function tProcessDataProc to show progress. Please note that you have to pass the number of bytes processed since the last call to tProcessDataProc, NOT the overall number of bytes processed!
Author of Total Commander
http://www.ghisler.com

User avatar
MVV
Power Member
Power Member
Posts: 8142
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Re: Need help with "Progress indication" in WCX plugins

Post by *MVV » 2018-12-04, 06:21 UTC

Perhaps it would be better for a pseudo-packer plugin to use negative values that set progress bar position directly.

User avatar
rg_software
Junior Member
Junior Member
Posts: 7
Joined: 2009-08-06, 12:59 UTC

Re: Need help with "Progress indication" in WCX plugins

Post by *rg_software » 2018-12-04, 15:58 UTC

Well, thank you for answers. I tend to believe that my code follows the recommendations.
I am setting the progress indicator to the number of bytes since the last call, and I also tried to set the initial indicator to zero using negative values.

When I pack some files, everything works correctly, and the issue appears only when I am trying to pack some more files. This makes me think that something is not reset between the sessions, and I don't know what I can do about it.

User avatar
milo1012
Power Member
Power Member
Posts: 1084
Joined: 2012-02-02, 19:23 UTC

Re: Need help with "Progress indication" in WCX plugins

Post by *milo1012 » 2018-12-04, 21:33 UTC

Just some quick guess:
  • do you check for a valid function pointer in SetProcessDataProc (INVALID_HANDLE_VALUE is defined as -1, or 0xFFFFFFFF (32-bit)- reason: TC calls SetProcessDataProc for PackFiles, without previous call to OpenArchive -> no valid hArcData available)
  • did you make sure to use SetProcessDataProcW instead of SetProcessDataProc when creating a Unicode capable plugin?
From my experience, the only reason why TC might increment that counter is that you use different strings each time you call the progress function, as TC tries to keep track of the files you selected for compression (it fills a map of file paths, so that the counter doesn't increase when you "process" a file a 2nd time during the pack process). When writing the zpaq plugin I never had any problems using this function's logic. So I can only guess that you somehow either do too many calls to the progress function or you use varying strings for individual files, as the progress indicator itself seems to work, but the counter is wrong.
TC plugins: PCREsearch and RegXtract

User avatar
Flint
Power Member
Power Member
Posts: 3160
Joined: 2003-10-27, 09:25 UTC
Location: Moscow, Russia
Contact:

Re: Need help with "Progress indication" in WCX plugins

Post by *Flint » 2018-12-04, 22:59 UTC

2rg_software
I tried to reply to the E-mail you've sent me, but the mail was bounced back with the "Unknown user" status. Also you did't enable any option of contacting you via the forum, so I have to write here. Please, send me a valid E-mail so that I could reply to you.
Flint's Homepage: Full TC Russification Package, VirtualDisk, NTFS Links, NoClose Replacer, and other stuff!
 
Using TC 9.21a / Win7 x64 SP1, Win10 x64

User avatar
rg_software
Junior Member
Junior Member
Posts: 7
Joined: 2009-08-06, 12:59 UTC

Re: Need help with "Progress indication" in WCX plugins

Post by *rg_software » 2018-12-05, 13:12 UTC

Thanks again for these suggestions. I will try to investigate.

My basic presumption was that once packing is done, it is done, so the next packing session (select more files, then pack) has no knowledge whatsoever about the previous session. However, it is seemingly not true.

Some more experiments:
(select 3 files, pack) -> works as expected
(select 5 files, pack) -> starts with progress bar at 4/5 -- so it thinks that we are continuing the previous session, and 3 files are packed already.
(select 10 files, pack) -> starts at 9/10, then after 10 goes out of bounds.

So apparently something is not reset in my DLL between the sessions. What can it be?
Suppose in theory I want to start with progress indicator at 4/5 -- how do I achieve that (besieds passing four files size upon the first call to tProcessDataProc)?

Post Reply