mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-12 04:45:45 +00:00
Bug 159646 -- taking care of stale pointer in the plugin sample code, not part of the build
This commit is contained in:
parent
95ef8b41ef
commit
ce05ae57b4
@ -107,6 +107,11 @@ NS_IMETHODIMP nsScriptablePeer::QueryInterface(const nsIID& aIID, void** aInstan
|
||||
return NS_NOINTERFACE;
|
||||
}
|
||||
|
||||
void nsScriptablePeer::SetInstance(nsPluginInstance* plugin)
|
||||
{
|
||||
mPlugin = plugin;
|
||||
}
|
||||
|
||||
//
|
||||
// the following methods will be callable from JavaScript
|
||||
//
|
||||
|
@ -98,6 +98,8 @@ public:
|
||||
// native methods callable from JavaScript
|
||||
NS_DECL_NSISCRIPTABLEPLUGIN
|
||||
|
||||
void SetInstance(nsPluginInstance* plugin);
|
||||
|
||||
protected:
|
||||
nsPluginInstance* mPlugin;
|
||||
};
|
||||
|
@ -91,6 +91,11 @@ nsPluginInstance::nsPluginInstance(NPP aInstance) : nsPluginInstanceBase(),
|
||||
|
||||
nsPluginInstance::~nsPluginInstance()
|
||||
{
|
||||
// mScriptablePeer may be also held by the browser
|
||||
// so releasing it here does not guarantee that it is over
|
||||
// we should take precaution in case it will be called later
|
||||
// and zero its mPlugin member
|
||||
mScriptablePeer->SetInstance(NULL);
|
||||
NS_IF_RELEASE(mScriptablePeer);
|
||||
}
|
||||
|
||||
@ -356,7 +361,7 @@ NPError nsPluginInstance::GetValue(NPPVariable aVariable, void *aValue)
|
||||
// ==============================
|
||||
//
|
||||
// this method will return the scriptable object (and create it if necessary)
|
||||
nsIScriptablePlugin* nsPluginInstance::getScriptablePeer()
|
||||
nsScriptablePeer* nsPluginInstance::getScriptablePeer()
|
||||
{
|
||||
if (!mScriptablePeer) {
|
||||
mScriptablePeer = new nsScriptablePeer(this);
|
||||
@ -369,6 +374,4 @@ nsIScriptablePlugin* nsPluginInstance::getScriptablePeer()
|
||||
// add reference for the caller requesting the object
|
||||
NS_ADDREF(mScriptablePeer);
|
||||
return mScriptablePeer;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
@ -56,7 +56,7 @@ public:
|
||||
|
||||
void showVersion();
|
||||
void clear();
|
||||
nsIScriptablePlugin* getScriptablePeer();
|
||||
nsScriptablePeer* getScriptablePeer();
|
||||
|
||||
char mString[128];
|
||||
|
||||
@ -67,7 +67,7 @@ private:
|
||||
void EndDraw(NPWindow* window);
|
||||
void DrawString(const unsigned char* text, short width, short height, short centerX, Rect drawRect);
|
||||
|
||||
nsIScriptablePlugin * mScriptablePeer;
|
||||
nsScriptablePeer * mScriptablePeer;
|
||||
|
||||
NPWindow * mWindow;
|
||||
NPP mInstance;
|
||||
|
@ -99,6 +99,11 @@ nsPluginInstance::nsPluginInstance(NPP aInstance) : nsPluginInstanceBase(),
|
||||
|
||||
nsPluginInstance::~nsPluginInstance()
|
||||
{
|
||||
// mScriptablePeer may be also held by the browser
|
||||
// so releasing it here does not guarantee that it is over
|
||||
// we should take precaution in case it will be called later
|
||||
// and zero its mPlugin member
|
||||
mScriptablePeer->SetInstance(NULL);
|
||||
NS_IF_RELEASE(mScriptablePeer);
|
||||
}
|
||||
|
||||
@ -246,7 +251,7 @@ NPError nsPluginInstance::GetValue(NPPVariable aVariable, void *aValue)
|
||||
// ==============================
|
||||
//
|
||||
// this method will return the scriptable object (and create it if necessary)
|
||||
nsIScriptablePlugin* nsPluginInstance::getScriptablePeer()
|
||||
nsScriptablePeer* nsPluginInstance::getScriptablePeer()
|
||||
{
|
||||
if (!mScriptablePeer) {
|
||||
mScriptablePeer = new nsScriptablePeer(this);
|
||||
@ -259,6 +264,4 @@ nsIScriptablePlugin* nsPluginInstance::getScriptablePeer()
|
||||
// add reference for the caller requesting the object
|
||||
NS_ADDREF(mScriptablePeer);
|
||||
return mScriptablePeer;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
@ -58,7 +58,7 @@ public:
|
||||
void clear();
|
||||
void draw();
|
||||
|
||||
nsIScriptablePlugin* getScriptablePeer();
|
||||
nsScriptablePeer* getScriptablePeer();
|
||||
|
||||
private:
|
||||
NPP mInstance;
|
||||
@ -73,7 +73,7 @@ private:
|
||||
XFontStruct *mFontInfo;
|
||||
GC mGC;
|
||||
|
||||
nsIScriptablePlugin * mScriptablePeer;
|
||||
nsScriptablePeer* mScriptablePeer;
|
||||
|
||||
public:
|
||||
char mString[128];
|
||||
|
@ -107,6 +107,11 @@ NS_IMETHODIMP nsScriptablePeer::QueryInterface(const nsIID& aIID, void** aInstan
|
||||
return NS_NOINTERFACE;
|
||||
}
|
||||
|
||||
void nsScriptablePeer::SetInstance(nsPluginInstance* plugin)
|
||||
{
|
||||
mPlugin = plugin;
|
||||
}
|
||||
|
||||
//
|
||||
// the following methods will be callable from JavaScript
|
||||
//
|
||||
|
@ -98,6 +98,8 @@ public:
|
||||
// native methods callable from JavaScript
|
||||
NS_DECL_NSISCRIPTABLEPLUGIN
|
||||
|
||||
void SetInstance(nsPluginInstance* plugin);
|
||||
|
||||
protected:
|
||||
nsPluginInstance* mPlugin;
|
||||
};
|
||||
|
@ -88,6 +88,11 @@ nsPluginInstance::nsPluginInstance(NPP aInstance) : nsPluginInstanceBase(),
|
||||
|
||||
nsPluginInstance::~nsPluginInstance()
|
||||
{
|
||||
// mScriptablePeer may be also held by the browser
|
||||
// so releasing it here does not guarantee that it is over
|
||||
// we should take precaution in case it will be called later
|
||||
// and zero its mPlugin member
|
||||
mScriptablePeer->SetInstance(NULL);
|
||||
NS_IF_RELEASE(mScriptablePeer);
|
||||
}
|
||||
|
||||
@ -184,7 +189,7 @@ NPError nsPluginInstance::GetValue(NPPVariable aVariable, void *aValue)
|
||||
// ==============================
|
||||
//
|
||||
// this method will return the scriptable object (and create it if necessary)
|
||||
nsIScriptablePlugin* nsPluginInstance::getScriptablePeer()
|
||||
nsScriptablePeer* nsPluginInstance::getScriptablePeer()
|
||||
{
|
||||
if (!mScriptablePeer) {
|
||||
mScriptablePeer = new nsScriptablePeer(this);
|
||||
@ -197,8 +202,6 @@ nsIScriptablePlugin* nsPluginInstance::getScriptablePeer()
|
||||
// add reference for the caller requesting the object
|
||||
NS_ADDREF(mScriptablePeer);
|
||||
return mScriptablePeer;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static LRESULT CALLBACK PluginWinProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||
|
@ -59,13 +59,13 @@ public:
|
||||
void showVersion();
|
||||
void clear();
|
||||
|
||||
nsIScriptablePlugin* getScriptablePeer();
|
||||
nsScriptablePeer* getScriptablePeer();
|
||||
|
||||
private:
|
||||
NPP mInstance;
|
||||
NPBool mInitialized;
|
||||
HWND mhWnd;
|
||||
nsIScriptablePlugin * mScriptablePeer;
|
||||
nsScriptablePeer * mScriptablePeer;
|
||||
|
||||
public:
|
||||
char mString[128];
|
||||
|
@ -107,6 +107,11 @@ NS_IMETHODIMP nsScriptablePeer::QueryInterface(const nsIID& aIID, void** aInstan
|
||||
return NS_NOINTERFACE;
|
||||
}
|
||||
|
||||
void nsScriptablePeer::SetInstance(nsPluginInstance* plugin)
|
||||
{
|
||||
mPlugin = plugin;
|
||||
}
|
||||
|
||||
//
|
||||
// the following method will be callable from JavaScript
|
||||
//
|
||||
|
@ -98,6 +98,8 @@ public:
|
||||
// native methods callable from JavaScript
|
||||
NS_DECL_NSISIMPLEPLUGIN
|
||||
|
||||
void SetInstance(nsPluginInstance* plugin);
|
||||
|
||||
protected:
|
||||
nsPluginInstance* mPlugin;
|
||||
};
|
||||
|
@ -118,6 +118,11 @@ nsPluginInstance::nsPluginInstance(NPP aInstance) : nsPluginInstanceBase(),
|
||||
|
||||
nsPluginInstance::~nsPluginInstance()
|
||||
{
|
||||
// mScriptablePeer may be also held by the browser
|
||||
// so releasing it here does not guarantee that it is over
|
||||
// we should take precaution in case it will be called later
|
||||
// and zero its mPlugin member
|
||||
mScriptablePeer->SetInstance(NULL);
|
||||
NS_IF_RELEASE(mScriptablePeer);
|
||||
}
|
||||
|
||||
@ -222,7 +227,7 @@ NPError nsPluginInstance::GetValue(NPPVariable aVariable, void *aValue)
|
||||
// ==============================
|
||||
//
|
||||
// this method will return the scriptable object (and create it if necessary)
|
||||
nsISimplePlugin* nsPluginInstance::getScriptablePeer()
|
||||
nsScriptablePeer* nsPluginInstance::getScriptablePeer()
|
||||
{
|
||||
if (!mScriptablePeer) {
|
||||
mScriptablePeer = new nsScriptablePeer(this);
|
||||
@ -235,6 +240,4 @@ nsISimplePlugin* nsPluginInstance::getScriptablePeer()
|
||||
// add reference for the caller requesting the object
|
||||
NS_ADDREF(mScriptablePeer);
|
||||
return mScriptablePeer;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
@ -59,12 +59,12 @@ public:
|
||||
// locals
|
||||
void getVersion(char* *aVersion);
|
||||
|
||||
nsISimplePlugin* getScriptablePeer();
|
||||
nsScriptablePeer* getScriptablePeer();
|
||||
|
||||
private:
|
||||
NPP mInstance;
|
||||
NPBool mInitialized;
|
||||
nsISimplePlugin * mScriptablePeer;
|
||||
nsScriptablePeer * mScriptablePeer;
|
||||
|
||||
public:
|
||||
char mString[128];
|
||||
|
Loading…
Reference in New Issue
Block a user