Bug 536437 - work around a bug in the Mozilla plugin host where NPN_GetURLNotify can return an error and also call NPP_URLNotify, r=cjones

--HG--
extra : transplant_source : %07%7B%DBO%AF%069%16%F5%FF%1A%C5%F5Wi%E1%9D%E1%E6%83
This commit is contained in:
Benjamin Smedberg 2010-01-05 12:12:30 -05:00
Родитель f08afe579d
Коммит 04d26699a0
2 изменённых файлов: 29 добавлений и 3 удалений

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

@ -270,6 +270,10 @@ PluginInstanceParent::AnswerPStreamNotifyConstructor(PStreamNotifyParent* actor,
const bool& file,
NPError* result)
{
bool streamDestroyed = false;
static_cast<StreamNotifyParent*>(actor)->
SetDestructionFlag(&streamDestroyed);
if (!post) {
*result = mNPNIface->geturlnotify(mNPP,
NullableStringGet(url),
@ -285,8 +289,11 @@ PluginInstanceParent::AnswerPStreamNotifyConstructor(PStreamNotifyParent* actor,
file, actor);
}
if (*result != NPERR_NO_ERROR)
PStreamNotifyParent::Call__delete__(actor, NPERR_GENERIC_ERROR);
if (!streamDestroyed) {
static_cast<StreamNotifyParent*>(actor)->ClearDestructionFlag();
if (*result != NPERR_NO_ERROR)
PStreamNotifyParent::Call__delete__(actor, NPERR_GENERIC_ERROR);
}
return true;
}

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

@ -48,7 +48,26 @@ class StreamNotifyParent : public PStreamNotifyParent
{
friend class PluginInstanceParent;
StreamNotifyParent() { }
StreamNotifyParent()
: mDestructionFlag(NULL)
{ }
~StreamNotifyParent() {
if (mDestructionFlag)
*mDestructionFlag = true;
}
public:
// If we are destroyed within the call to NPN_GetURLNotify, notify the caller
// so that we aren't destroyed again. see bug 536437.
void SetDestructionFlag(bool* flag) {
mDestructionFlag = flag;
}
void ClearDestructionFlag() {
mDestructionFlag = NULL;
}
private:
bool* mDestructionFlag;
};
} // namespace plugins