diff --git a/src/internfile/mh_exec.h b/src/internfile/mh_exec.h index fdc595c6..e7275225 100644 --- a/src/internfile/mh_exec.h +++ b/src/internfile/mh_exec.h @@ -65,10 +65,9 @@ class MimeHandlerExec : public RecollFilter { virtual bool next_document(); virtual bool skip_to_document(const std::string& ipath); - virtual void clear() { + virtual void clear_impl() override { m_fn.erase(); m_ipath.erase(); - RecollFilter::clear(); } protected: diff --git a/src/internfile/mh_html.h b/src/internfile/mh_html.h index a4f21776..06453140 100644 --- a/src/internfile/mh_html.h +++ b/src/internfile/mh_html.h @@ -37,14 +37,12 @@ class MimeHandlerHtml : public RecollFilter { return false; } virtual bool next_document(); - const std::string& get_html() - { + const std::string& get_html() { return m_html; } - virtual void clear() { + virtual void clear_impl() override { m_filename.erase(); m_html.erase(); - RecollFilter::clear(); } protected: virtual bool set_document_file_impl(const std::string& mt, diff --git a/src/internfile/mh_mail.cpp b/src/internfile/mh_mail.cpp index 8550d8b0..d766d0c4 100644 --- a/src/internfile/mh_mail.cpp +++ b/src/internfile/mh_mail.cpp @@ -66,7 +66,7 @@ MimeHandlerMail::~MimeHandlerMail() { clear(); } -void MimeHandlerMail::clear() +void MimeHandlerMail::clear_impl() { delete m_bincdoc; m_bincdoc = 0; if (m_fd >= 0) { @@ -82,7 +82,6 @@ void MimeHandlerMail::clear() delete *it; } m_attachments.clear(); - RecollFilter::clear(); } bool MimeHandlerMail::set_document_file_impl(const string& mt, const string &fn) diff --git a/src/internfile/mh_mail.h b/src/internfile/mh_mail.h index 51eca62d..eb2660cc 100644 --- a/src/internfile/mh_mail.h +++ b/src/internfile/mh_mail.h @@ -46,7 +46,7 @@ public: } virtual bool next_document(); virtual bool skip_to_document(const std::string& ipath); - virtual void clear(); + virtual void clear_impl() override; protected: virtual bool set_document_file_impl(const std::string& mt, diff --git a/src/internfile/mh_mbox.cpp b/src/internfile/mh_mbox.cpp index 68c4d172..b03343d7 100644 --- a/src/internfile/mh_mbox.cpp +++ b/src/internfile/mh_mbox.cpp @@ -232,7 +232,7 @@ MimeHandlerMbox::~MimeHandlerMbox() clear(); } -void MimeHandlerMbox::clear() +void MimeHandlerMbox::clear_impl() { m_fn.erase(); if (m_vfp) { @@ -242,7 +242,6 @@ void MimeHandlerMbox::clear() m_msgnum = m_lineno = 0; m_ipath.erase(); m_offsets.clear(); - RecollFilter::clear(); } bool MimeHandlerMbox::set_document_file_impl(const string& mt, const string &fn) diff --git a/src/internfile/mh_mbox.h b/src/internfile/mh_mbox.h index e2b0de9a..8f890f0b 100644 --- a/src/internfile/mh_mbox.h +++ b/src/internfile/mh_mbox.h @@ -39,7 +39,7 @@ public: m_ipath = ipath; return true; } - virtual void clear(); + virtual void clear_impl() override; typedef long long mbhoff_type; protected: diff --git a/src/internfile/mh_text.h b/src/internfile/mh_text.h index f2166a3c..9cebaa59 100644 --- a/src/internfile/mh_text.h +++ b/src/internfile/mh_text.h @@ -43,12 +43,11 @@ class MimeHandlerText : public RecollFilter { } virtual bool next_document(); virtual bool skip_to_document(const std::string& s); - virtual void clear() { + virtual void clear_impl() override { m_paging = false; m_text.erase(); m_fn.erase(); m_offs = 0; - RecollFilter::clear(); } protected: diff --git a/src/internfile/mimehandler.h b/src/internfile/mimehandler.h index ccba1e52..bae08266 100644 --- a/src/internfile/mimehandler.h +++ b/src/internfile/mimehandler.h @@ -115,15 +115,17 @@ public: return m_id; } - // "Call super" anti-pattern again. Must be called from derived - // classes which reimplement clear() - virtual void clear() { + // Classes which need to do local work in clear() need + // to implement clear_impl() + virtual void clear() final { + clear_impl(); Dijon::Filter::clear(); m_forPreview = m_havedoc = false; m_dfltInputCharset.clear(); m_reason.clear(); } - + virtual void clear_impl() {} + // This only makes sense if the contents are currently txt/plain // It converts from keyorigcharset to UTF-8 and sets keycharset. bool txtdcode(const std::string& who);