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:
Brian R. Bondy 2013-07-09 14:39:46 -04:00
parent 15f539db5c
commit d9a8a2ce6f
3 changed files with 10 additions and 2 deletions

View File

@ -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);

View File

@ -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 )

View File

@ -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;