[vlc-commits] Prevent a scheduled async event from crashing if callback triggered after plugin destruction
Sergey Radionov
git at videolan.org
Wed Dec 28 19:15:57 CET 2011
npapi-vlc | branch: master | Sergey Radionov <RSATom at gmail.com> | Wed Dec 28 21:04:07 2011 +0700| [d4d9ce427c2372817b3b744094b835f9a06e181f] | committer: Jean-Baptiste Kempf
Prevent a scheduled async event from crashing if callback triggered after plugin destruction
Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>
> http://git.videolan.org/gitweb.cgi/npapi-vlc.git/?a=commit;h=d4d9ce427c2372817b3b744094b835f9a06e181f
---
npapi/vlcplugin_base.cpp | 8 ++++++++
npapi/vlcplugin_base.h | 4 ++++
2 files changed, 12 insertions(+), 0 deletions(-)
diff --git a/npapi/vlcplugin_base.cpp b/npapi/vlcplugin_base.cpp
index b96e756..953765b 100644
--- a/npapi/vlcplugin_base.cpp
+++ b/npapi/vlcplugin_base.cpp
@@ -363,6 +363,7 @@ VlcPluginBase::VlcPluginBase( NPP instance, NPuint16_t mode ) :
psz_baseURL(NULL)
{
memset(&npwindow, 0, sizeof(NPWindow));
+ _instances.insert(this);
}
static bool boolValue(const char *value) {
@@ -371,9 +372,14 @@ static bool boolValue(const char *value) {
!strcasecmp(value, "yes") );
}
+std::set<VlcPluginBase*> VlcPluginBase::_instances;
+
void VlcPluginBase::eventAsync(void *param)
{
VlcPluginBase *plugin = (VlcPluginBase*)param;
+ if(_instances.find(plugin) == _instances.end())
+ return;
+
plugin->events.deliver(plugin->getBrowser());
plugin->update_controls();
}
@@ -580,6 +586,8 @@ VlcPluginBase::~VlcPluginBase()
libvlc_media_list_release( libvlc_media_list );
if( libvlc_instance )
libvlc_release( libvlc_instance );
+
+ _instances.erase(this);
}
void VlcPluginBase::setWindow(const NPWindow &window)
diff --git a/npapi/vlcplugin_base.h b/npapi/vlcplugin_base.h
index 5775506..2832001 100644
--- a/npapi/vlcplugin_base.h
+++ b/npapi/vlcplugin_base.h
@@ -77,6 +77,7 @@
#include <npfunctions.h>
#include <vector>
+#include <set>
#include <assert.h>
#include "control/nporuntime.h"
@@ -321,6 +322,9 @@ protected:
NPWindow npwindow;
static void eventAsync(void *);
+
+private:
+ static std::set<VlcPluginBase*> _instances;
};
#endif
More information about the vlc-commits
mailing list