mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-05 22:05:40 +00:00
Bug 883554 - Don't clear too close to a SetData in case another program accesses on clipboard changes. r=jimm
This commit is contained in:
parent
15f539db5c
commit
d9a8a2ce6f
@ -927,7 +927,12 @@ nsClipboard::GetNativeClipboardData ( nsITransferable * aTransferable, int32_t a
|
||||
NS_IMETHODIMP
|
||||
nsClipboard::EmptyClipboard(int32_t aWhichClipboard)
|
||||
{
|
||||
if (aWhichClipboard == kGlobalClipboard) {
|
||||
// Some programs such as ZoneAlarm monitor clipboard usage and then open the
|
||||
// clipboard to scan it. If we i) empty and then ii) set data, then the
|
||||
// 'set data' can sometimes fail with access denied becacuse another program
|
||||
// has the clipboard open. So to avoid this race condition for OpenClipboard
|
||||
// we do not empty the clipboard when we're setting it.
|
||||
if (aWhichClipboard == kGlobalClipboard && !mEmptyingForSetData) {
|
||||
OleSetClipboard(NULL);
|
||||
}
|
||||
return nsBaseClipboard::EmptyClipboard(aWhichClipboard);
|
||||
|
@ -15,7 +15,7 @@ nsBaseClipboard::nsBaseClipboard()
|
||||
mClipboardOwner = nullptr;
|
||||
mTransferable = nullptr;
|
||||
mIgnoreEmptyNotification = false;
|
||||
|
||||
mEmptyingForSetData = false;
|
||||
}
|
||||
|
||||
nsBaseClipboard::~nsBaseClipboard()
|
||||
@ -42,7 +42,9 @@ NS_IMETHODIMP nsBaseClipboard::SetData(nsITransferable * aTransferable, nsIClipb
|
||||
if ( !selectClipPresent && aWhichClipboard != kGlobalClipboard )
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
mEmptyingForSetData = true;
|
||||
EmptyClipboard(aWhichClipboard);
|
||||
mEmptyingForSetData = false;
|
||||
|
||||
mClipboardOwner = anOwner;
|
||||
if ( anOwner )
|
||||
|
@ -38,6 +38,7 @@ protected:
|
||||
NS_IMETHOD SetNativeClipboardData ( int32_t aWhichClipboard ) = 0;
|
||||
NS_IMETHOD GetNativeClipboardData ( nsITransferable * aTransferable, int32_t aWhichClipboard ) = 0;
|
||||
|
||||
bool mEmptyingForSetData;
|
||||
bool mIgnoreEmptyNotification;
|
||||
nsIClipboardOwner * mClipboardOwner;
|
||||
nsITransferable * mTransferable;
|
||||
|
Loading…
x
Reference in New Issue
Block a user