Pārlūkot izejas kodu

need a destructor to fix a major file handle leak!

David Rose 14 gadi atpakaļ
vecāks
revīzija
08693413e8

+ 10 - 0
panda/src/putil/datagramInputFile.I

@@ -26,6 +26,16 @@ DatagramInputFile() {
   _owns_in = false;
 }
 
+////////////////////////////////////////////////////////////////////
+//     Function: DatagramInputFile::Destructor
+//       Access: Published
+//  Description:
+////////////////////////////////////////////////////////////////////
+INLINE DatagramInputFile::
+~DatagramInputFile() {
+  close();
+}
+
 ////////////////////////////////////////////////////////////////////
 //     Function: DatagramInputFile::open
 //       Access: Published

+ 1 - 0
panda/src/putil/datagramInputFile.h

@@ -31,6 +31,7 @@
 class EXPCL_PANDA_PUTIL DatagramInputFile : public DatagramGenerator {
 PUBLISHED:
   INLINE DatagramInputFile();
+  INLINE ~DatagramInputFile();
 
   bool open(const FileReference *file);
   INLINE bool open(const Filename &filename);

+ 10 - 0
panda/src/putil/datagramOutputFile.I

@@ -26,6 +26,16 @@ DatagramOutputFile() {
   _owns_out = false;
 }
 
+////////////////////////////////////////////////////////////////////
+//     Function: DatagramOutputFile::Destructor
+//       Access: Public
+//  Description:
+////////////////////////////////////////////////////////////////////
+INLINE DatagramOutputFile::
+~DatagramOutputFile() {
+  close();
+}
+
 ////////////////////////////////////////////////////////////////////
 //     Function: DatagramOutputFile::open
 //       Access: Published

+ 1 - 0
panda/src/putil/datagramOutputFile.h

@@ -30,6 +30,7 @@
 class EXPCL_PANDA_PUTIL DatagramOutputFile : public DatagramSink {
 public:
   INLINE DatagramOutputFile();
+  INLINE ~DatagramOutputFile();
 
   bool open(const FileReference *file);
   INLINE bool open(const Filename &filename);