Code Lemurs Wiki

7-Zip Bug Fixes and Added Features

Team Roster:

Nicholas Klofta
Alex Pang
Chris Pangalos
Kevin Spanier

Photoviewer Bug

Estimated Impact Set:
Update.cpp
Tempfiles.h
Tempfiles.cpp
Filedir.h
Filedir.cpp
Panel.h
Panelitemopen.cpp

Actual Impact Set:
PanelItemOpen.cpp

File Changed:
PanelItemOpen.cpp

Lines of Code Changed:
7

Estimated/Actual Time:
4 Hour, 20 Hours

Tests:
Reproduce: Compress an image file with photoviewer as the default handler, Open 7-Zip file manager, double click your compressed image and attempt to open it. The expected output is for your image to open in photoviewer, but instead you receive an error message stating that photoviewer cannot open this image because either the picture is deleted or in an unavailable location.
Validate the fix: Compress an image file that uses photoviewer as the default handler, Open 7-Zip file manager, double click your compressed image and attempt to open it. This time you should receive the expected output as the image opens in photoviewer.

Comments:
I had a fair amount of difficulty with this bug it’s been one of the biggest complaints of 7-zip users for years and appears multiple times in the bug database under different names. Igor Pavlov originally said he would fix it but later gave up. The problem is caused by windows switching to a different process called dllhost to handle photoviewer. I had originally hoped to use an if statement to set the second process when the first was detected but was unable to do this since 7-zip records processes based on specific handles when they are created. After experimenting with delays to wait for the process to switch to the second I found that this bug could be fixed by adding a delay before the openiteminarchive function returns which in turn is when the file is deleted. I had the delay wait for a maximum of 3 seconds for the handle value to change.

“…” Button to “Browser…” Button

Estimated Impact Set:
BrowseDialog.h
BrowseDialog.cpp
CopyDialog.h
CopyDialog.cpp

Actual Impact Set:
CopyDialog.rc
SplitDialog.rc
CompressDialog.rc
ExtractDialog.rc

Source Files Changed:
CopyDialog.rc
SplitDialog.rc
CompressDialog.rc
ExtractDialog.rc

Lines of Code Changed and Written:
12
Estimated/Actual Time:
2 Hours 4 Hours

Tests:
Reproduce: Open 7-Zip File manager, right click a file, click “Copy to or Move to” The expected ouput is for 7-zip to have an option to browse folder to the right of the address bar, 7-zip should have this but the button will be labeled at … which may be confusing to some users rather than the more standard Browse… This same type of button can be found by right click a file in 7-zip file manager and clicking split archive, or by right clicking an archive, hovering over 7-zip and clicking extract files or compress and email.
Validate: The fix can be validated by opening 7-zip file manager, right clicking a file and clicking “Copy to or Move to”. The button should now appear as Browse… This can also be checked by opening dialogs to split, compress, or extract and archive which should all now show Browse… buttons.

Comments:
I initially had difficulty finding this bug as running a search for “…” produced a very large number of results and I couldn’t find the text for buttons anywhere in the .cpp or .h files. I eventually checked the CopyDialog.rc file due to its name which was appropriate to the box I wished to change. Visual Studio 10 could not handle this file type so I instead had to use notepad. I quickly noticed the … text I had been looking for and after some trial and error of moving and resizing boxes I was able to change the button text do the same for the 3 other dialog boxes.

"Cancel” to “Close” Text on Button

Estimated Impact Set:
BenchmarkDialog.rc

Actual Impact Set:
BenchmarkDialog.rc

Source Files Changed:
BenchmarkDialog.rc

Lines of Code Changed:
3
Estimated/Actual Time:
30 Min 30 Min

Tests:
Reproduce: Open 7-zip file manager, on the menu bar go to tools, then benchmark. The expected output is for a button in the right corner to close the box. The box has this button but it is instead labeled as “cancel” which implies the test would be canceled but doesn’t let the user know the box will be closed.
Validate: Open 7-zip file manager, on the menu bar go to tools, then benchmark. The bottom right corner of the box now shows a button labeled “close” which appropriately closes the box.

Comments:
After already fixing another bug involving button modifications it was easy to figure out that I needed to find the appropriate .rc file for the benchmark box and modify its text. Since the text for “Cancel” and “Close” is about the same size I didn’t run into issue of needing to resize the button which made the fix much easier overall.

Escape Button to Exit feature request

Estimated Impact Set:
PanelKey.cpp
Panel.h

Actual Impact Set:
PanelKey.cpp

File Changed:
PanelKey.cpp

Lines of Code Changed:
4

Estimated Time: 6 hours
Actual Time: 30 minutes

Tests:
Reproduce – N/A
Validate the fix – It was desired to be able to press the escape key to end the program instead of having to click through the menu list.
Comments:
This feature request did not take as long as I had originally planned. After doing some research on the internet, I figured that the program used “VK_”s or “Virtual Keys”. I knew that some of them were already implemented in the program through my own experimentation so I performed a GREP search looking for “VK”. When I got the results, I browsed through them (luckily there was only a few) and identified PanelKey.cpp as the file I needed to alter. Then all I had to do was add an extra switch case.

 “Integrate to Shell context menu” bug

Estimated Impact Set:
OptionsDialog.cpp
MenuPage.h
EditPage.h
SettingPage.h

Actual Impact Set:
MenuPage.cpp

File Changed:
MenuPage.cpp

Lines of Code Changed:
1

Estimated Time: 24 hours
Actual Time: 96+ hours

Tests:
Reproduce – Go to tools. Click options. Go to 7-zip tab. Check box for “Integrate 7-Zip to shell context menu”. Press either “apply” or “ok” to get error “An event was unable to invoke any of the sub-scribers”
Validate the fix – the option is there for a reason but it never worked. That left one of two options left; you could either implement the option or remove the option. I chose the second only because I ran out of time.
Comments:
This bug was a pain. I spent all semester working on it. First thing I did was research on the internet to figure out what exactly a “shell context menu” was. After I figured out what a context menu is, I started searching for where it was implemented in the code. I did a few grep searches but didn’t turn up any useful results. I had to manually search through files and started at the OptionsDialog.cpp because it seemed like the closest start. Followed some clues and finally found out that the code was really in MenuPage.cpp. In MenuPage.cpp, I found out how to disable the button and figured, if worse came to worse, it still “counts” as being fixed because I simply removed the option to select the box. Tried to implement the code further by going down to OnApply() and reading that code. Tried to follow the code after that but just ended up going in circles through the files. I never saw any code that could’ve even remotely affected the actual implementation of the shell context menu but I know it’s somewhere in there. Another bug I noticed was that, after clicking “Apply” and getting the error, the check box never reset. I tried to reset that as well but that didn’t quite work out either.

File Relocation During a Renaming Action

Estimated Impact Set:
FSFolder.cpp

Actual Impact Set:
FSFolder.cpp
AgentOut.cpp

Source Files Changed:
FSFolder.cpp
AgentOut.cpp

Lines of Code Changed:
6

Estimated/Actual Time:
2 hours / 5 hours

Tests:
Reproduce: Try renaming a folder or file, using folder redirection (eg. Going into more subfolders with “\” or going up with “..”), and you’ll find that by “renaming”, you can also move.
Validate: Trying it now, and you get an argument error.

Comments:
This was implemented because 7-zip also has a “Move” feature, meaning the renaming feature should only do just that—rename things. One of the more difficult parts of this issue is finding the locations in the code that the conditions need to be placed; there isn’t a single method called “Rename” ran throughout the entire code, but rather one for outside of archives, and one for inside. Additionally, I needed to lookup and understand (without documentation) 7-zip’s UStrings and FStrings, in order to check them.