Commit d4d9ce42 authored by Sergey Radionov's avatar Sergey Radionov Committed by Jean-Baptiste Kempf

Prevent a scheduled async event from crashing if callback triggered after plugin destruction

Signed-off-by: Jean-Baptiste Kempf's avatarJean-Baptiste Kempf <jb@videolan.org>
parent 26c29cce
...@@ -363,6 +363,7 @@ VlcPluginBase::VlcPluginBase( NPP instance, NPuint16_t mode ) : ...@@ -363,6 +363,7 @@ VlcPluginBase::VlcPluginBase( NPP instance, NPuint16_t mode ) :
psz_baseURL(NULL) psz_baseURL(NULL)
{ {
memset(&npwindow, 0, sizeof(NPWindow)); memset(&npwindow, 0, sizeof(NPWindow));
_instances.insert(this);
} }
static bool boolValue(const char *value) { static bool boolValue(const char *value) {
...@@ -371,9 +372,14 @@ static bool boolValue(const char *value) { ...@@ -371,9 +372,14 @@ static bool boolValue(const char *value) {
!strcasecmp(value, "yes") ); !strcasecmp(value, "yes") );
} }
std::set<VlcPluginBase*> VlcPluginBase::_instances;
void VlcPluginBase::eventAsync(void *param) void VlcPluginBase::eventAsync(void *param)
{ {
VlcPluginBase *plugin = (VlcPluginBase*)param; VlcPluginBase *plugin = (VlcPluginBase*)param;
if(_instances.find(plugin) == _instances.end())
return;
plugin->events.deliver(plugin->getBrowser()); plugin->events.deliver(plugin->getBrowser());
plugin->update_controls(); plugin->update_controls();
} }
...@@ -580,6 +586,8 @@ VlcPluginBase::~VlcPluginBase() ...@@ -580,6 +586,8 @@ VlcPluginBase::~VlcPluginBase()
libvlc_media_list_release( libvlc_media_list ); libvlc_media_list_release( libvlc_media_list );
if( libvlc_instance ) if( libvlc_instance )
libvlc_release( libvlc_instance ); libvlc_release( libvlc_instance );
_instances.erase(this);
} }
void VlcPluginBase::setWindow(const NPWindow &window) void VlcPluginBase::setWindow(const NPWindow &window)
......
...@@ -77,6 +77,7 @@ ...@@ -77,6 +77,7 @@
#include <npfunctions.h> #include <npfunctions.h>
#include <vector> #include <vector>
#include <set>
#include <assert.h> #include <assert.h>
#include "control/nporuntime.h" #include "control/nporuntime.h"
...@@ -321,6 +322,9 @@ protected: ...@@ -321,6 +322,9 @@ protected:
NPWindow npwindow; NPWindow npwindow;
static void eventAsync(void *); static void eventAsync(void *);
private:
static std::set<VlcPluginBase*> _instances;
}; };
#endif #endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment