diff --git a/core/area.h b/core/area.h index fdd64b3bb..18a11874e 100644 --- a/core/area.h +++ b/core/area.h @@ -272,6 +272,29 @@ struct HighlightRect : public NormalizedRect QColor color; }; + +/** @internal */ +template +class okularDeleter +{ +public: + static void doDelete( T& t ) + { + (void)t; + } +}; + +/** @internal */ +template +class okularDeleter +{ +public: + static void doDelete( T* t ) + { + delete t; + } +}; + /** * @short A regular area of NormalizedShape which normalizes a Shape * @@ -286,6 +309,7 @@ struct HighlightRect : public NormalizedRect template class RegularArea : public QList { public: + ~RegularArea(); bool contains( double x, double y ) const; bool contains( const NormalizedShape& shape ) const; bool intersects (const RegularArea * area) const; @@ -296,6 +320,14 @@ template class RegularArea : public QList< QList* geometry( int xScale, int yScale, int dx=0,int dy=0 ) const; }; +template +RegularArea::~RegularArea() +{ + int size = this->count(); + for ( int i = 0; i < size; ++i ) + okularDeleter::doDelete( (*this)[i] ); +} + template void RegularArea::simplify() { @@ -308,7 +340,9 @@ void RegularArea::simplify() if ( (*this)[x]->intersects( (*this)[i+1] ) ) { *((*this)[x]) |= *((*this)[i+1]); + NormalizedShape tobedeleted = (*this)[i+1]; this->removeAt( i + 1 ); + okularDeleter::doDelete( tobedeleted ); --end; --i; } diff --git a/core/page.cpp b/core/page.cpp index e7cebf7ac..515734bb0 100644 --- a/core/page.cpp +++ b/core/page.cpp @@ -582,12 +582,8 @@ void Page::deleteHighlights( int s_id ) void Page::deleteTextSelections() { - if (m_textSelections) - { - qDeleteAll(*m_textSelections); - delete m_textSelections; - m_textSelections = 0; - } + delete m_textSelections; + m_textSelections = 0; } void Page::deleteSourceReferences()