]> git.sesse.net Git - vlc/blobdiff - projects/mozilla/control/nporuntime.h
Default to rebase on submodule updates to prevent losing local changes.
[vlc] / projects / mozilla / control / nporuntime.h
index 1fc8d1cd343e71436d3429134ab5e4873ebe2080..fe9bfc62936a305188162070584e99fab3112f88 100644 (file)
@@ -42,6 +42,9 @@ static bool RuntimeNPClassInvokeDefault(NPObject *npobj,
 class RuntimeNPObject : public NPObject
 {
 public:
+    // Lazy child object cration helper. Doing this avoids
+    // ownership problems with firefox.
+    template<class T> void InstantObj( NPObject *&obj );
 
     /*
     ** utility functions
@@ -131,7 +134,7 @@ protected:
 
     bool isPluginRunning()
     {
-        return _instance->pdata;
+        return (_instance->pdata != NULL);
     }
     template<class T> T *getPrivate()
     {
@@ -174,6 +177,13 @@ private:
     NPIdentifier *methodIdentifiers;
 };
 
+template<class T>
+inline void RuntimeNPObject::InstantObj( NPObject *&obj )
+{
+    if( !obj )
+        obj = NPN_CreateObject(_instance, RuntimeNPClass<T>::getClass());
+}
+
 template<class T>
 static NPObject *RuntimeNPClassAllocate(NPP instance, NPClass *aClass)
 {