Last Comment Bug 665987 - win32 nsFilePicker does not clear out mFiles on showing picker
: win32 nsFilePicker does not clear out mFiles on showing picker
Status: RESOLVED FIXED
:
Product: Core
Classification: Components
Component: Widget: Win32 (show other bugs)
: Trunk
: x86 Windows 7
: -- normal (vote)
: mozilla9
Assigned To: Brian R. Bondy [:bbondy]
:
: Jim Mathies [:jimm]
Mentors:
http://mxr.mozilla.org/mozilla-centra...
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2011-06-21 12:17 PDT by Mook (as)
Modified: 2011-08-21 11:44 PDT (History)
5 users (show)
See Also:
Crash Signature:
(edit)
QA Whiteboard:
Iteration: ---
Points: ---
Has Regression Range: ---
Has STR: ---


Attachments
Patch for win32 nsFilePicker does not clear out mFiles on showing picker (1.10 KB, patch)
2011-07-07 13:54 PDT, Brian R. Bondy [:bbondy]
jmathies: review+
Details | Diff | Splinter Review

Description Mook (as) 2011-06-21 12:17:21 PDT
In the GTK2 and Cocoa implementations, showing the file picker clears out nsFilePicker.mFiles.  This does not happen for Win32, though it probably should, given that there's no other way for an API consumer to clear it.

STR:
1. Create a nsIFilePicker on Windows and .init() as appropriate for modeOpen
2. .show() and pick a file.
3. .show() and pick a different file
4. read fp.files

Expected results:
fp.files should only have the last file picked from step 3.

Actual results:
fp.files contains both files (steps 2 and 3).
Comment 1 Brian R. Bondy [:bbondy] 2011-07-07 13:50:37 PDT
Here are exact steps to reproduce the problem:

1. Download the Extension Developer extension (https://addons.mozilla.org/en-us/firefox/addon/extension-developer/)
2. Open the Interactive JS console via the small button under the maximize button
3. Type in the following code, and select a file on each open:

var picker = Components.classes["@mozilla.org/filepicker;1"].createInstance();
picker = picker.QueryInterface(Components.interfaces.nsIFilePicker);
picker.init(window, "Select 1 file exactly", Components.interfaces.nsIFilePicker.modeOpenMultiple);
picker.show();
picker.show();

var enumerator = picker.files;
while (enumerator.hasMoreElements()) {
  var file = enumerator.getNext().QueryInterface(Components.interfaces.nsILocalFile);
  print(file.path);
}

Actual results: 
Step 3 prints all files selected

Expected results:
Step 3 should print only the files selected in the second file picker dialog
Comment 2 Brian R. Bondy [:bbondy] 2011-07-07 13:54:08 PDT
Created attachment 544610 [details] [diff] [review]
Patch for win32 nsFilePicker does not clear out mFiles on showing picker

I simply call `Clear()` on the nsCOMArray before re-filling the array
Comment 3 :Ms2ger (⌚ UTC+1/+2) 2011-08-21 11:44:08 PDT
http://hg.mozilla.org/mozilla-central/rev/bd9dd7e4c7ff

Note You need to log in before you can comment on or make changes to this bug.