Summary: | Leaking memory when watching a file | ||
---|---|---|---|
Product: | [Unmaintained] kpdf | Reporter: | Kevin Goeser <kevin> |
Component: | general | Assignee: | Albert Astals Cid <aacid> |
Status: | RESOLVED FIXED | ||
Severity: | normal | CC: | lucaswb.lee |
Priority: | NOR | ||
Version: | 0.4 | ||
Target Milestone: | --- | ||
Platform: | Gentoo Packages | ||
OS: | Linux | ||
Latest Commit: | Version Fixed In: | ||
Sentry Crash Report: |
Description
Kevin Goeser
2005-03-09 19:05:31 UTC
CVS commit by aacid: Comitting a fix for the memory leak that happens when reloading a file because it was beign watched. To fix it what we do is close the document, show a message telling that the document is beign reloaded and then open the document again when it's ready, that presents a big problem to a backport, because without the text it is really not understood that something is happening. Enrico any idea to do this in a better way so we can backport it? BUGS: 101192 M +17 -4 part.cpp 1.30 M +2 -1 part.h 1.11 M +7 -0 ui/pageview.cpp 1.49 M +2 -0 ui/pageview.h 1.17 --- kdegraphics/kpdf/part.cpp #1.29:1.30 @@ -357,4 +357,6 @@ bool Part::openURL(const KURL &url) if ( !b ) KMessageBox::error( widget(), i18n("Could not open %1").arg( url.prettyURL() ) ); + else + m_viewportDirty.pageNumber = -1; return b; } @@ -403,9 +405,20 @@ void Part::slotFileDirty( const QString& void Part::slotDoFileDirty() { - uint p = m_document->currentPage() + 1; - if (openFile()) + if (m_viewportDirty.pageNumber == -1) { - if (p > m_document->pages()) p = m_document->pages(); - goToPage(p); + m_viewportDirty = m_document->viewport(); + m_pageView->showText(i18n("Reloading the document..."), 0); + } + + if (KParts::ReadOnlyPart::openURL(m_file)) + { + if (m_viewportDirty.pageNumber > m_document->pages()) m_viewportDirty.pageNumber = m_document->pages(); + m_document->setViewport(m_viewportDirty); + m_viewportDirty.pageNumber = -1; + } + else + { + m_watcher->addFile(m_file); + m_dirtyHandler->start( 750, true ); } } --- kdegraphics/kpdf/part.h #1.10:1.11 @@ -20,4 +20,5 @@ #include <kparts/part.h> #include <qguardedptr.h> +#include "core/document.h" #include "core/observer.h" #include "dcop.h" @@ -36,5 +37,4 @@ class KAboutData; class KPrinter; -class KPDFDocument; class ThumbnailList; class ThumbnailController; @@ -134,4 +134,5 @@ private: KDirWatch *m_watcher; QTimer *m_dirtyHandler; + DocumentViewport m_viewportDirty; // actions --- kdegraphics/kpdf/ui/pageview.cpp #1.48:1.49 @@ -404,4 +404,11 @@ bool PageView::canUnloadPixmap( int page //END DocumentObserver inherited methods + +void PageView::showText( const QString &text, int ms ) +{ + d->messageWindow->display(text, PageViewMessage::Info, ms ); +} + + //BEGIN widget events void PageView::viewportPaintEvent( QPaintEvent * pe ) --- kdegraphics/kpdf/ui/pageview.h #1.16:1.17 @@ -64,4 +64,6 @@ class PageView : public QScrollView, pub bool canUnloadPixmap( int pageNum ); + void showText( const QString &text, int ms ); + signals: void urlDropped( const KURL& ); Verified :) Thx for the fast fix!!! To the backport: You could introduce a statusbar, showing all information displayed in the message box of the newer versions (if this is not too much for a backport). The problem is not the message box but the text itself, in "old" branches like KDE 3.4.x new texts are not allowed :-( and without "Reloading the document..." it is pretty difficult to see the document is actually beign reloaded. *** Bug 101265 has been marked as a duplicate of this bug. *** How about a backport that shows the filename of the file being reloaded instead of i18n("Reloading the document..."). Might be still unclear but maybe better than the memory leak. And it does not need translation. Just an idea... Keep up that great work... I've backported the fix with the translation asked at translators list and got an OK |