Closed Bug 665987 Opened 13 years ago Closed 13 years ago

win32 nsFilePicker does not clear out mFiles on showing picker

Categories

(Core :: Widget: Win32, defect)

x86
Windows 7
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla9

People

(Reporter: mark.yen, Assigned: bbondy)

References

()

Details

Attachments

(1 file)

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).
Assignee: nobody → netzen
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
I simply call `Clear()` on the nsCOMArray before re-filling the array
Attachment #544610 - Flags: review?(jmathies)
Attachment #544610 - Flags: review?(jmathies) → review+
Attachment #544610 - Flags: checkin?
Attachment #544610 - Flags: checkin?
http://hg.mozilla.org/mozilla-central/rev/bd9dd7e4c7ff
Status: NEW → RESOLVED
Closed: 13 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla9
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: