Clean up Windows nsFilePicker #1911

Closed
opened 1 year ago by Moonchild · 0 comments
Owner

There is a whole bunch of stuff in nsFilePicker that is either crappy, redundant, or never worked right. This cleanup will be based on Bug 1677168 and should result in both faster operation, better error state handling, and fewer potential issues.

Most notably:

  • Replace mLastUsedUnicodeDirectory and its manual memory management with a UniquePtr named sLastUsedUnicodeDirectory
  • Remove AutoRestoreWorkingPath, as it never was actually necessary and was left in, "just in case."
  • Remove the timeout stuff, as that never actually worked, at least with the current implementation of the file picker; perhaps it worked with the legacy file picker APIs, but it doesn't work with the Vista+, COM-based stuff.
  • Also get rid of IFileDialogEvents, as all of that stuff was needed for timeouts. It also adds unnecessary additional complexity.
  • Replace do_CreateInstance("@mozilla.org/file/local;1") with NS_NewLocalFile.
  • Add HRESULT error handling to all of the method invocations on COM interfaces.
  • Replace CLSCTX_INPROC with CLSCTX_INPROC_SERVER in CoCreateInstance calls.
  • Remove CoInitialize and CoUninitialize calls. Those are not necessary in single-process applications.
There is a whole bunch of stuff in nsFilePicker that is either crappy, redundant, or never worked right. This cleanup will be based on [Bug 1677168](https://bugzilla.mozilla.org/show_bug.cgi?id=1677168) and should result in both faster operation, better error state handling, and fewer potential issues. Most notably: - Replace `mLastUsedUnicodeDirectory` and its manual memory management with a `UniquePtr` named `sLastUsedUnicodeDirectory` - Remove `AutoRestoreWorkingPath`, as it never was actually necessary and was left in, "just in case." - Remove the timeout stuff, as that never actually worked, at least with the current implementation of the file picker; perhaps it worked with the legacy file picker APIs, but it doesn't work with the Vista+, COM-based stuff. - Also get rid of `IFileDialogEvents`, as all of that stuff was needed for timeouts. It also adds unnecessary additional complexity. - Replace `do_CreateInstance("@mozilla.org/file/local;1")` with `NS_NewLocalFile`. - Add `HRESULT` error handling to all of the method invocations on COM interfaces. - Replace `CLSCTX_INPROC` with `CLSCTX_INPROC_SERVER` in `CoCreateInstance` calls. - Remove `CoInitialize` and `CoUninitialize` calls. Those are not necessary in single-process applications.
Moonchild added this to the 31.1.0 milestone 1 year ago
Moonchild added the
Code Cleanup
Enhancement
OS: Windows
labels 1 year ago
Moonchild self-assigned this 1 year ago
Moonchild closed this issue 1 year ago
Sign in to join this conversation.
No Milestone
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: MoonchildProductions/UXP#1911
Loading…
There is no content yet.