win32 nsFilePicker does not clear out mFiles on showing picker

RESOLVED FIXED in mozilla9

Status

()

Core
Widget: Win32
RESOLVED FIXED
6 years ago
6 years ago

People

(Reporter: Mook (work), Assigned: bbondy)

Tracking

Trunk
mozilla9
x86
Windows 7
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

(URL)

Attachments

(1 attachment)

(Reporter)

Description

6 years ago
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)

Updated

6 years ago
Assignee: nobody → netzen
(Assignee)

Comment 1

6 years ago
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
(Assignee)

Comment 2

6 years ago
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
Attachment #544610 - Flags: review?(jmathies)

Updated

6 years ago
Attachment #544610 - Flags: review?(jmathies) → review+
(Assignee)

Updated

6 years ago
Attachment #544610 - Flags: checkin?
(Assignee)

Updated

6 years ago
Attachment #544610 - Flags: checkin?
http://hg.mozilla.org/mozilla-central/rev/bd9dd7e4c7ff
Status: NEW → RESOLVED
Last Resolved: 6 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla9
You need to log in before you can comment on or make changes to this bug.