From a4e4db31bcf4bc1c3e7c195189ad36a7e69fd6e8 Mon Sep 17 00:00:00 2001 From: Emmanuel Papin Date: Sat, 7 Mar 2015 14:42:01 +0100 Subject: [PATCH] Delete event data in event class, not in plugin function --- src/zm_event.cpp | 11 ++++++++++- src/zm_event.h | 3 ++- src/zm_monitor.cpp | 5 +++++ 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/zm_event.cpp b/src/zm_event.cpp index fb774d6e7..459fb7f1c 100644 --- a/src/zm_event.cpp +++ b/src/zm_event.cpp @@ -227,8 +227,17 @@ void Event::AddCause( const std::string new_cause ) } } +void Event::Close() +{ + if ( ( tot_score == 0 ) && ( alarm_frames == 0 ) ) + { + Info( "Event is empty: Delete data" ); + DeleteData(); + } +} + // This is the transcription of JavaScript function DeleteEvent() -void Event::DeleteEvent() +void Event::DeleteData() { static char sql[ZM_SQL_MED_BUFSIZ]; diff --git a/src/zm_event.h b/src/zm_event.h index 2d9e107f3..ec31cae72 100644 --- a/src/zm_event.h +++ b/src/zm_event.h @@ -133,10 +133,11 @@ public: void AddFrames( int n_frames, Image **images, struct timeval **timestamps ); void AddFrame( Image *image, struct timeval timestamp, int score=0, Image *alarm_frame=NULL ); void AddCause( const std::string new_cause ); - void DeleteEvent(); + void Close(); private: void AddFramesInternal( int n_frames, int start_frame, Image **images, struct timeval **timestamps ); + void DeleteData(); public: static const char *getSubPath( struct tm *time ) diff --git a/src/zm_monitor.cpp b/src/zm_monitor.cpp index b685ddf90..2646c917a 100644 --- a/src/zm_monitor.cpp +++ b/src/zm_monitor.cpp @@ -3117,10 +3117,15 @@ bool Monitor::closeEvent() { gettimeofday( &(event->EndTime()), NULL ); } + + // Inform all plugins that we are closing the event if ( config.load_plugins && ( purpose == ANALYSIS ) ) { ThePluginManager.getImageAnalyser().onCloseEvent( zones, event ); } + + event->Close(); + delete event; event = 0; return( true );