Commit 03e0154f authored by Pino Toscano's avatar Pino Toscano

use a stack of dom elements by value, so no memory is leaked

svn path=/trunk/KDE/kdegraphics/okular/; revision=753169
parent 6164d717
......@@ -344,20 +344,19 @@ const Okular::DocumentSynopsis *DviGenerator::generateDocumentSynopsis()
return m_docSynopsis;
m_docSynopsis = new Okular::DocumentSynopsis();
QStack<QDomElement*> stack;
QVector<PreBookmark> prebookmarks = m_dviRenderer->getPrebookmarks();
if ( prebookmarks.isEmpty() )
return m_docSynopsis;
QStack<QDomElement> stack;
QVector<PreBookmark>::ConstIterator it = prebookmarks.begin();
QVector<PreBookmark>::ConstIterator itEnd = prebookmarks.end();
for( ; it != itEnd; ++it )
{
QDomElement *domel = new QDomElement;
*domel= m_docSynopsis->createElement( (*it).title );
QDomElement domel = m_docSynopsis->createElement( (*it).title );
Anchor a = m_dviRenderer->findAnchor((*it).anchorName);
if ( a.isValid() )
......@@ -367,19 +366,17 @@ const Okular::DocumentSynopsis *DviGenerator::generateDocumentSynopsis()
const Okular::Page *p = document()->page( a.page - 1 );
/* Don't care about rotations... */
fillViewportFromAnchor( vp, a, (int)p->width(), (int)p->height(), 0 );
domel->setAttribute( "Viewport", vp.toString() );
domel.setAttribute( "Viewport", vp.toString() );
}
if ( stack.isEmpty() )
m_docSynopsis->appendChild( *domel );
m_docSynopsis->appendChild( domel );
else
{
stack.top()->appendChild( *domel );
stack.top().appendChild( domel );
stack.pop();
}
for ( int i = 0; i < (*it).noOfChildren; ++i )
stack.push( domel );
if (!(*it).noOfChildren)
delete domel;
}
return m_docSynopsis;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment