From 08693413e8725495cf5d3a874cab0ab638bab324 Mon Sep 17 00:00:00 2001 From: David Rose Date: Sun, 4 Sep 2011 00:11:18 +0000 Subject: [PATCH] need a destructor to fix a major file handle leak! --- panda/src/putil/datagramInputFile.I | 10 ++++++++++ panda/src/putil/datagramInputFile.h | 1 + panda/src/putil/datagramOutputFile.I | 10 ++++++++++ panda/src/putil/datagramOutputFile.h | 1 + 4 files changed, 22 insertions(+) diff --git a/panda/src/putil/datagramInputFile.I b/panda/src/putil/datagramInputFile.I index e6633e7506..06ade2a1bf 100644 --- a/panda/src/putil/datagramInputFile.I +++ b/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 diff --git a/panda/src/putil/datagramInputFile.h b/panda/src/putil/datagramInputFile.h index 6550005288..b5e2b0d856 100644 --- a/panda/src/putil/datagramInputFile.h +++ b/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); diff --git a/panda/src/putil/datagramOutputFile.I b/panda/src/putil/datagramOutputFile.I index 37dc3b684a..2eefc85635 100644 --- a/panda/src/putil/datagramOutputFile.I +++ b/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 diff --git a/panda/src/putil/datagramOutputFile.h b/panda/src/putil/datagramOutputFile.h index d9004417f6..f4df769f17 100644 --- a/panda/src/putil/datagramOutputFile.h +++ b/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);