Closed
Bug 782451
Opened 13 years ago
Closed 12 years ago
Work - OleSetClipboard always fails with winrt backend
Categories
(Core :: Widget: Win32, defect)
Tracking
()
RESOLVED
FIXED
People
(Reporter: jimm, Assigned: TimAbraldes)
References
Details
(Whiteboard: metro-preview completed-elm)
Attachments
(1 file, 1 obsolete file)
1.24 KB,
patch
|
TimAbraldes
:
review+
|
Details | Diff | Splinter Review |
http://mxr.mozilla.org/mozilla-central/source/widget/windows/nsClipboard.cpp#236
The call fails with a "CoInit was never called" error, however com has been initialized. I confirmed this by adding a RoInit on the metro main thread which return S_FALSE, indicating COM was already set up. (Interesting to note that the main thread was initialized with RO_INIT_SINGLETHREADED.)
So I'm not sure what's wrong here. Winrt has a wrapper around these calls which we can use -
http://msdn.microsoft.com/en-us/library/windows/apps/br205867.aspx
But I'd rather get our existing code working rather than reformulating it to work with the winrt classes.
Comment 2•13 years ago
|
||
Hey Tim, this should be failing because we're no longer calling OleInitialize in WinRT code. This call only works when Ole is initialized. It's not related to CoInitialize/RoInitialize.
Updated•13 years ago
|
Whiteboard: metro-preview
Comment 3•13 years ago
|
||
OleInitialize calls CoInitialize internally but also does some other stuff that is needed for the clipboard.
Assignee | ||
Comment 4•13 years ago
|
||
Thanks Brian!
I had noticed that `OleInitialize` is probably the initialization function that we wanted. I'm testing locally whether calling `OleInitialize` before attempting the `OleSetClipboard` works, and if it does I'll post a patch shortly.
Comment 5•13 years ago
|
||
Sounds good, I'd do the call somewhere higher up, maybe in MetroWidget::MetroWidget's !gInstanceCount condition.
Then in the destructor under !gInstanceCount call both OleFlushClipboard and OleUninitialize
Comment 6•13 years ago
|
||
Check out how nsWindow.cpp does it with the error check in case the initialize fails (using sIsOleInitialized)
Assignee | ||
Comment 7•13 years ago
|
||
This patch creates an `OleInitializeWrapper` to mimic `RoInitializeWrapper`. It creates an `OleInitializeWrapper` member of `MetroWidget` that initializes OLE in its constructor and, when the final `MetroWidget` is destroyed, handles OLE uninitialization.
Attachment #658545 -
Flags: review?(jmathies)
Comment 8•13 years ago
|
||
Comment on attachment 658545 [details] [diff] [review]
Patch
Review of attachment 658545 [details] [diff] [review]:
-----------------------------------------------------------------
Feel free to land on elm with those changes, thanks!
::: widget/windows/winrt/MetroWidget.cpp
@@ +70,5 @@
> gInstanceCount--;
>
> // Global shutdown
> if (!gInstanceCount) {
> + mOleInitializeWrapper.flush();
Just put the flush call in the destructor instead
::: widget/windows/winrt/MetroWidget.h
@@ +142,5 @@
> + HRESULT const hr;
> +
> + operator HRESULT() const {
> + return hr;
> + }
I don't think this is needed.
@@ +156,5 @@
> + {
> + }
> +
> + ~OleInitializeWrapper() {
> + ::OleUninitialize();
Also wrap this inside an if (SUCCEEDED(hr)) {
Attachment #658545 -
Flags: review?(jmathies) → review+
Assignee | ||
Comment 9•13 years ago
|
||
Implemented review comments. I'll test locally and push to elm.
Attachment #658545 -
Attachment is obsolete: true
Attachment #658999 -
Flags: review+
Assignee | ||
Comment 10•13 years ago
|
||
Status: NEW → ASSIGNED
Whiteboard: metro-preview → metro-preview completed-elm
Updated•12 years ago
|
Summary: OleSetClipboard always fails with winrt backend → Work - OleSetClipboard always fails with winrt backend
![]() |
Reporter | |
Updated•12 years ago
|
Status: ASSIGNED → RESOLVED
Closed: 12 years ago
Resolution: --- → FIXED
Updated•11 years ago
|
OS: Windows 8 Metro → Windows 8.1
You need to log in
before you can comment on or make changes to this bug.
Description
•