Fix clear() call super antipattern in handlers
This commit is contained in:
parent
23141307f7
commit
218b3fbfe2
@ -65,10 +65,9 @@ class MimeHandlerExec : public RecollFilter {
|
|||||||
virtual bool next_document();
|
virtual bool next_document();
|
||||||
virtual bool skip_to_document(const std::string& ipath);
|
virtual bool skip_to_document(const std::string& ipath);
|
||||||
|
|
||||||
virtual void clear() {
|
virtual void clear_impl() override {
|
||||||
m_fn.erase();
|
m_fn.erase();
|
||||||
m_ipath.erase();
|
m_ipath.erase();
|
||||||
RecollFilter::clear();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|||||||
@ -37,14 +37,12 @@ class MimeHandlerHtml : public RecollFilter {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
virtual bool next_document();
|
virtual bool next_document();
|
||||||
const std::string& get_html()
|
const std::string& get_html() {
|
||||||
{
|
|
||||||
return m_html;
|
return m_html;
|
||||||
}
|
}
|
||||||
virtual void clear() {
|
virtual void clear_impl() override {
|
||||||
m_filename.erase();
|
m_filename.erase();
|
||||||
m_html.erase();
|
m_html.erase();
|
||||||
RecollFilter::clear();
|
|
||||||
}
|
}
|
||||||
protected:
|
protected:
|
||||||
virtual bool set_document_file_impl(const std::string& mt,
|
virtual bool set_document_file_impl(const std::string& mt,
|
||||||
|
|||||||
@ -66,7 +66,7 @@ MimeHandlerMail::~MimeHandlerMail()
|
|||||||
{
|
{
|
||||||
clear();
|
clear();
|
||||||
}
|
}
|
||||||
void MimeHandlerMail::clear()
|
void MimeHandlerMail::clear_impl()
|
||||||
{
|
{
|
||||||
delete m_bincdoc; m_bincdoc = 0;
|
delete m_bincdoc; m_bincdoc = 0;
|
||||||
if (m_fd >= 0) {
|
if (m_fd >= 0) {
|
||||||
@ -82,7 +82,6 @@ void MimeHandlerMail::clear()
|
|||||||
delete *it;
|
delete *it;
|
||||||
}
|
}
|
||||||
m_attachments.clear();
|
m_attachments.clear();
|
||||||
RecollFilter::clear();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MimeHandlerMail::set_document_file_impl(const string& mt, const string &fn)
|
bool MimeHandlerMail::set_document_file_impl(const string& mt, const string &fn)
|
||||||
|
|||||||
@ -46,7 +46,7 @@ public:
|
|||||||
}
|
}
|
||||||
virtual bool next_document();
|
virtual bool next_document();
|
||||||
virtual bool skip_to_document(const std::string& ipath);
|
virtual bool skip_to_document(const std::string& ipath);
|
||||||
virtual void clear();
|
virtual void clear_impl() override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual bool set_document_file_impl(const std::string& mt,
|
virtual bool set_document_file_impl(const std::string& mt,
|
||||||
|
|||||||
@ -232,7 +232,7 @@ MimeHandlerMbox::~MimeHandlerMbox()
|
|||||||
clear();
|
clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MimeHandlerMbox::clear()
|
void MimeHandlerMbox::clear_impl()
|
||||||
{
|
{
|
||||||
m_fn.erase();
|
m_fn.erase();
|
||||||
if (m_vfp) {
|
if (m_vfp) {
|
||||||
@ -242,7 +242,6 @@ void MimeHandlerMbox::clear()
|
|||||||
m_msgnum = m_lineno = 0;
|
m_msgnum = m_lineno = 0;
|
||||||
m_ipath.erase();
|
m_ipath.erase();
|
||||||
m_offsets.clear();
|
m_offsets.clear();
|
||||||
RecollFilter::clear();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MimeHandlerMbox::set_document_file_impl(const string& mt, const string &fn)
|
bool MimeHandlerMbox::set_document_file_impl(const string& mt, const string &fn)
|
||||||
|
|||||||
@ -39,7 +39,7 @@ public:
|
|||||||
m_ipath = ipath;
|
m_ipath = ipath;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
virtual void clear();
|
virtual void clear_impl() override;
|
||||||
typedef long long mbhoff_type;
|
typedef long long mbhoff_type;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|||||||
@ -43,12 +43,11 @@ class MimeHandlerText : public RecollFilter {
|
|||||||
}
|
}
|
||||||
virtual bool next_document();
|
virtual bool next_document();
|
||||||
virtual bool skip_to_document(const std::string& s);
|
virtual bool skip_to_document(const std::string& s);
|
||||||
virtual void clear() {
|
virtual void clear_impl() override {
|
||||||
m_paging = false;
|
m_paging = false;
|
||||||
m_text.erase();
|
m_text.erase();
|
||||||
m_fn.erase();
|
m_fn.erase();
|
||||||
m_offs = 0;
|
m_offs = 0;
|
||||||
RecollFilter::clear();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|||||||
@ -115,14 +115,16 @@ public:
|
|||||||
return m_id;
|
return m_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
// "Call super" anti-pattern again. Must be called from derived
|
// Classes which need to do local work in clear() need
|
||||||
// classes which reimplement clear()
|
// to implement clear_impl()
|
||||||
virtual void clear() {
|
virtual void clear() final {
|
||||||
|
clear_impl();
|
||||||
Dijon::Filter::clear();
|
Dijon::Filter::clear();
|
||||||
m_forPreview = m_havedoc = false;
|
m_forPreview = m_havedoc = false;
|
||||||
m_dfltInputCharset.clear();
|
m_dfltInputCharset.clear();
|
||||||
m_reason.clear();
|
m_reason.clear();
|
||||||
}
|
}
|
||||||
|
virtual void clear_impl() {}
|
||||||
|
|
||||||
// This only makes sense if the contents are currently txt/plain
|
// This only makes sense if the contents are currently txt/plain
|
||||||
// It converts from keyorigcharset to UTF-8 and sets keycharset.
|
// It converts from keyorigcharset to UTF-8 and sets keycharset.
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user