]> git.vomp.tv Git - vompclient.git/commitdiff
Change ChannelList back to std::vector, use custom deleter in shared_ptr
authorChris Tallon <chris@vomp.tv>
Thu, 18 Nov 2021 16:03:31 +0000 (16:03 +0000)
committerChris Tallon <chris@vomp.tv>
Thu, 18 Nov 2021 16:03:31 +0000 (16:03 +0000)
vdr.cc
vdr.h

diff --git a/vdr.cc b/vdr.cc
index 6d8a953818df960edb626fb972d2281f5c0615aa..9705686cf9ec49fcdd551f5c5284fb61732cab39 100644 (file)
--- a/vdr.cc
+++ b/vdr.cc
@@ -861,8 +861,9 @@ std::shared_ptr<ChannelList> VDR::getChannelsList(ULONG type)
   VDR_ResponsePacket* vresp = RequestResponse(&vrp);
   if (vresp->noResponse()) { delete vresp; return NULL; }
   
-  //ChannelList* chanList = new ChannelList();
-  std::shared_ptr<ChannelList> chanList = std::make_shared<ChannelList>();
+  // shared_ptr for a ChannelList (std::vector<Channel*>) with custom deleter to delete all the Channel* objects
+  std::shared_ptr<ChannelList> chanList(new ChannelList(),
+    [] (ChannelList* cl) { for (Channel* p : *cl) delete p; });
 
   bool h264support=Video::getInstance()->supportsh264();
   bool mpeg2support=Video::getInstance()->supportsmpeg2();
diff --git a/vdr.h b/vdr.h
index 8f705c0408aabf4725a9d26032e26ea095a4a5dc..adb6178fe73c9558f034a0a919522ebe7a63865b 100644 (file)
--- a/vdr.h
+++ b/vdr.h
 #include "i18n.h"
 #include "control.h"
 #include "tcp.h"
-#include "channel.h"
 
 class RecInfo;
 class Event;
-//class Channel;
+class Channel;
 class VDR_RequestPacket;
 class VDR_ResponsePacket;
 #ifdef VOMP_MEDIAPLAYER
@@ -59,19 +58,9 @@ class SeriesInfo;
 class TVMediaInfo;
 
 typedef std::vector<Event*> EventList;
-//typedef std::vector<Channel*> ChannelList;
+typedef std::vector<Channel*> ChannelList;
 typedef std::vector<RecTimer*> RecTimerList;
 
-// Subclass vector to add custom delete behaviour for the contents
-class ChannelList : public std::vector<Channel*>
-{
-  public:
-    ~ChannelList()
-    {
-      for (Channel* p : *this) delete p;
-    }
-};
-
 struct RecTimerSorter     // : public binary_function<double, double, bool>
 {
   bool operator() (const RecTimer* a, const RecTimer* b)