Bug 1636740 - Block CMemStream::Read only if the drop target initiated an async operation. r=aklotz

If the drop target did not initiate an async operation, `DoDragDrop` will
block on the main thread until the data transfer completes. Although the
`ObtainCachedIconFile` callback itself will run off the main thread,
`ObtainCachedIconFile` will end up with calling `NotifyIconObservers` that
heavily relies on the main thread. So `ObtainCachedIconFile` will have no
chance to run the callback.

To complete the data transfer, however, the `ObtainCachedIconFile` callback
must signal the event object to unblock `CMemStream::Read`. Deadlock.

Differential Revision: https://phabricator.services.mozilla.com/D75531
This commit is contained in:
Masatoshi Kimura 2020-05-20 14:07:19 +00:00
Родитель b93b459b46
Коммит bccfb6df94
1 изменённых файлов: 5 добавлений и 0 удалений

Просмотреть файл

@ -1360,6 +1360,11 @@ nsDataObj ::GetFileContentsInternetShortcut(FORMATETC& aFE, STGMEDIUM& aSTG) {
::GlobalUnlock(globalMem.get());
if (aFE.tymed & TYMED_ISTREAM) {
if (!mIsInOperation) {
// The drop target didn't initiate an async operation.
// We can't block CMemStream::Read.
event = nullptr;
}
RefPtr<IStream> stream =
new CMemStream(globalMem.disown(), totalLen, event.forget());
stream.forget(&aSTG.pstm);