Commit 1080a193 authored by Pino Toscano's avatar Pino Toscano

- make sure to properly unregister all the observers before the Document gets destroyed

- keep ownership of the "export as" menu, and check before manipulating its child widgets: avoid crashes in case the part widget is destroyed before the pa
rt is
both the problems discovered and debugged with the precious help of Armin Berres, thanks!
CCMAIL: trigger@space-based.de

svn path=/trunk/KDE/kdegraphics/okular/; revision=863716
parent 4eae1424
......@@ -268,13 +268,13 @@ m_cliPresentation(false), m_generatorGuiClient(0), m_keeper( 0 )
m_sidebar->setCurrentIndex( tbIndex );
// [left toolbox: Reviews] | []
Reviews * reviewsWidget = new Reviews( 0, m_document );
m_sidebar->addItem( reviewsWidget, KIcon("draw-freehand"), i18n("Reviews") );
m_reviewsWidget = new Reviews( 0, m_document );
m_sidebar->addItem( m_reviewsWidget, KIcon("draw-freehand"), i18n("Reviews") );
m_sidebar->setItemEnabled( 2, false );
// [left toolbox: Bookmarks] | []
BookmarkList * bookmarkList = new BookmarkList( m_document, 0 );
m_sidebar->addItem( bookmarkList, KIcon("bookmarks"), i18n("Bookmarks") );
m_bookmarkList = new BookmarkList( m_document, 0 );
m_sidebar->addItem( m_bookmarkList, KIcon("bookmarks"), i18n("Bookmarks") );
m_sidebar->setItemEnabled( 3, false );
// widgets: [../miniBarContainer] | []
......@@ -335,9 +335,9 @@ m_cliPresentation(false), m_generatorGuiClient(0), m_keeper( 0 )
bottomBarLayout->addWidget( m_pageSizeLabel );
rightLayout->addWidget( bottomBar );
connect( reviewsWidget, SIGNAL( setAnnotationWindow( Okular::Annotation* ) ),
connect( m_reviewsWidget, SIGNAL( setAnnotationWindow( Okular::Annotation* ) ),
m_pageView, SLOT( setAnnotationWindow( Okular::Annotation* ) ) );
connect( reviewsWidget, SIGNAL( removeAnnotationWindow( Okular::Annotation* ) ),
connect( m_reviewsWidget, SIGNAL( removeAnnotationWindow( Okular::Annotation* ) ),
m_pageView, SLOT( removeAnnotationWindow( Okular::Annotation* ) ) );
// add document observers
......@@ -350,9 +350,9 @@ m_cliPresentation(false), m_generatorGuiClient(0), m_keeper( 0 )
#ifdef OKULAR_ENABLE_MINIBAR
m_document->addObserver( m_progressWidget );
#endif
m_document->addObserver( reviewsWidget );
m_document->addObserver( m_reviewsWidget );
m_document->addObserver( m_pageSizeLabel );
m_document->addObserver( bookmarkList );
m_document->addObserver( m_bookmarkList );
connect( m_document->bookmarkManager(), SIGNAL( saved() ),
this, SLOT( slotRebuildBookmarkMenu() ) );
......@@ -502,11 +502,11 @@ m_cliPresentation(false), m_generatorGuiClient(0), m_keeper( 0 )
m_exportAs = ac->addAction("file_export_as");
m_exportAs->setText(i18n("E&xport As"));
m_exportAs->setIcon( KIcon( "document-export" ) );
QMenu *menu = new QMenu(widget());
connect(menu, SIGNAL(triggered(QAction *)), this, SLOT(slotExportAs(QAction *)));
m_exportAs->setMenu( menu );
m_exportAsText = actionForExportFormat( Okular::ExportFormat::standardFormat( Okular::ExportFormat::PlainText ), menu );
menu->addAction( m_exportAsText );
m_exportAsMenu = new QMenu();
connect(m_exportAsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotExportAs(QAction *)));
m_exportAs->setMenu( m_exportAsMenu );
m_exportAsText = actionForExportFormat( Okular::ExportFormat::standardFormat( Okular::ExportFormat::PlainText ), m_exportAsMenu );
m_exportAsMenu->addAction( m_exportAsText );
m_exportAs->setEnabled( false );
m_exportAsText->setEnabled( false );
......@@ -570,6 +570,8 @@ m_cliPresentation(false), m_generatorGuiClient(0), m_keeper( 0 )
Part::~Part()
{
m_document->removeObserver( this );
if ( m_document->isOpened() )
Part::closeUrl();
......@@ -581,6 +583,8 @@ Part::~Part()
delete m_progressWidget;
#endif
delete m_pageSizeLabel;
delete m_reviewsWidget;
delete m_bookmarkList;
delete m_document;
......@@ -588,6 +592,8 @@ Part::~Part()
qDeleteAll( m_bookmarkActions );
delete m_exportAsMenu;
#ifdef OKULAR_KEEP_FILE_OPEN
delete m_keeper;
#endif
......@@ -992,11 +998,14 @@ bool Part::closeUrl()
m_generatorGuiClient = 0;
m_document->closeDocument();
updateViewActions();
m_searchWidget->clearText();
delete m_tempfile;
m_tempfile = 0;
m_topMessage->setVisible( false );
m_formsMessage->setVisible( false );
if ( widget() )
{
m_searchWidget->clearText();
m_topMessage->setVisible( false );
m_formsMessage->setVisible( false );
}
#ifdef OKULAR_KEEP_FILE_OPEN
m_keeper->close();
#endif
......
......@@ -30,6 +30,7 @@
class QAction;
class QWidget;
class QPrinter;
class QMenu;
class KUrl;
class KConfigGroup;
......@@ -52,6 +53,8 @@ class Sidebar;
class TOC;
class MiniBar;
class FileKeeper;
class Reviews;
class BookmarkList;
namespace Okular
{
......@@ -193,6 +196,8 @@ class Part : public KParts::ReadOnlyPart, public Okular::DocumentObserver, publi
QPointer<PresentationWidget> m_presentationWidget;
QPointer<ProgressWidget> m_progressWidget;
QPointer<PageSizeLabel> m_pageSizeLabel;
QPointer<Reviews> m_reviewsWidget;
QPointer<BookmarkList> m_bookmarkList;
// document watcher (and reloader) variables
KDirWatch *m_watcher;
......@@ -234,6 +239,7 @@ class Part : public KParts::ReadOnlyPart, public Okular::DocumentObserver, publi
KToggleFullScreenAction* m_showFullScreenAction;
QAction *m_aboutBackend;
QAction *m_reload;
QMenu *m_exportAsMenu;
bool m_actionsSearched;
BrowserExtension *m_bExtension;
......
......@@ -127,6 +127,7 @@ BookmarkList::BookmarkList( Okular::Document *document, QWidget *parent )
BookmarkList::~BookmarkList()
{
m_document->removeObserver( this );
}
uint BookmarkList::observerId() const
......
......@@ -148,6 +148,11 @@ Reviews::Reviews( QWidget * parent, Okular::Document * document )
}
Reviews::~Reviews()
{
m_document->removeObserver( this );
}
//BEGIN DocumentObserver Notifies
void Reviews::notifyViewportChanged( bool )
{
......
......@@ -37,6 +37,7 @@ class Reviews : public QWidget, public Okular::DocumentObserver
Q_OBJECT
public:
Reviews( QWidget * parent, Okular::Document * document );
~Reviews();
// [INHERITED] from DocumentObserver
uint observerId() const { return REVIEWS_ID; }
......
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