-
-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use IFileDialog where available. #91
Conversation
Thinking of merging this regardless, wdyt @lonnywong? |
Sorry for the delay. It doesn't work on that machine. It may fall back to |
That's disappointing. If you can help debug, it'd be great. I'll test more just to see if this big change isn't a regression. And I'll probably merge it too. |
file_windows.go
Outdated
func coInitialize() (context.CancelFunc, error) { | ||
runtime.LockOSThread() | ||
err := win.CoInitializeEx(0, win.COINIT_APARTMENTTHREADED|win.COINIT_DISABLE_OLE1DDE) | ||
if err == nil || err == win.S_FALSE { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the app calls CoInitializeEx
with win.COINIT_APARTMENTTHREADED|win.COINIT_DISABLE_OLE1DDE
before calling zenity
, the err
will be win.S_FALSE
. zenity
should not call win.CoUninitialize()
.
So, err == win.S_FALSE
should be moved to below: err == win.RPC_E_CHANGED_MODE || err == win.S_FALSE
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we've covered this before:
To close the COM library gracefully on a thread, each successful call to CoInitialize or CoInitializeEx, including any call that returns S_FALSE, must be balanced by a corresponding call to CoUninitialize.
https://learn.microsoft.com/en-us/windows/win32/api/combaseapi/nf-combaseapi-coinitializeex
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But if you don't want COM to be closed, you can CoInitializeEx
yourself, and never CoUninitialize
.
This is a reference count, if you don't CoUninitialize
it never goes back to zero.
If we're going to leave COM initialized, windows can do it for us. When it returns Otherwise, it's an error. |
@ncruces Thanks. #89 has been fixed by 99f1a25: Lines 453 to 472 in 99f1a25
As long as the reference count does not decrease to |
That was the expectation, great to see it confirmed! It just felt better to leave it to windows to manage the thread local stuff. |
Alternative fix for #89.