From: José Fonseca Date: Sun, 27 Nov 2011 12:18:24 +0000 (+0000) Subject: Don't call overridden virtual methods from the base destructor. X-Git-Url: https://git.cworth.org/git?a=commitdiff_plain;h=565b80cc4a88ab420cf5e2138300856888ad9968;p=apitrace Don't call overridden virtual methods from the base destructor. It causes the program to terminate with "pure virtual method called" error, as the derived class members are no longer accessible. --- diff --git a/common/trace_file.cpp b/common/trace_file.cpp index 2210602..3657fd2 100644 --- a/common/trace_file.cpp +++ b/common/trace_file.cpp @@ -28,6 +28,7 @@ #include + using namespace trace; @@ -43,7 +44,8 @@ File::File(const std::string &filename, File::~File() { - close(); + // We can't invoke any overriden virtual method here anymore + assert(!m_isOpened); } diff --git a/common/trace_file_snappy.cpp b/common/trace_file_snappy.cpp index 4d4ecea..5901bfb 100644 --- a/common/trace_file_snappy.cpp +++ b/common/trace_file_snappy.cpp @@ -141,6 +141,7 @@ SnappyFile::SnappyFile(const std::string &filename, SnappyFile::~SnappyFile() { + close(); delete [] m_compressedCache; delete [] m_cache; } diff --git a/common/trace_file_zlib.cpp b/common/trace_file_zlib.cpp index 92cead9..b299b5a 100644 --- a/common/trace_file_zlib.cpp +++ b/common/trace_file_zlib.cpp @@ -73,6 +73,7 @@ ZLibFile::ZLibFile(const std::string &filename, ZLibFile::~ZLibFile() { + close(); } bool ZLibFile::rawOpen(const std::string &filename, File::Mode mode)