X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=projects%2Fmozilla%2Fcontrol%2Fnporuntime.h;fp=projects%2Fmozilla%2Fcontrol%2Fnporuntime.h;h=fe9bfc62936a305188162070584e99fab3112f88;hb=57a63ce739a89546ba2e72b09561d480b42c241d;hp=6aba74e7c88656fe23a63fdedc1113c1c651a116;hpb=9bec486d7355d63ffbdba50570b73383cc364175;p=vlc diff --git a/projects/mozilla/control/nporuntime.h b/projects/mozilla/control/nporuntime.h index 6aba74e7c8..fe9bfc6293 100644 --- a/projects/mozilla/control/nporuntime.h +++ b/projects/mozilla/control/nporuntime.h @@ -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 void InstantObj( NPObject *&obj ); /* ** utility functions @@ -174,6 +177,13 @@ private: NPIdentifier *methodIdentifiers; }; +template +inline void RuntimeNPObject::InstantObj( NPObject *&obj ) +{ + if( !obj ) + obj = NPN_CreateObject(_instance, RuntimeNPClass::getClass()); +} + template static NPObject *RuntimeNPClassAllocate(NPP instance, NPClass *aClass) {