Fix crash if processing a link closes the document

BUGS: 400104
remotes/origin/Applications/18.08
Albert Astals Cid 7 years ago
parent 22e7cb86a5
commit 27197b5f76
  1. 15
      core/document.cpp
  2. 6
      core/document.h

@ -2634,6 +2634,8 @@ void Document::closeDocument()
if ( !d->m_generator )
return;
emit aboutToClose();
delete d->m_pageController;
d->m_pageController = nullptr;
@ -4079,6 +4081,10 @@ void Document::processAction( const Action * action )
if ( !action )
return;
// Don't execute next actions if the action itself caused the closing of the document
bool executeNextActions = true;
auto connectionId = connect( this, &Document::aboutToClose, [&executeNextActions] { executeNextActions = false; } );
switch( action->actionType() )
{
case Action::Goto: {
@ -4277,9 +4283,14 @@ void Document::processAction( const Action * action )
}
for ( const Action *a : action->nextActions() )
disconnect( connectionId );
if ( executeNextActions )
{
processAction( a );
for ( const Action *a : action->nextActions() )
{
processAction( a );
}
}
}

@ -1022,6 +1022,12 @@ class OKULARCORE_EXPORT Document : public QObject
void reloadDocument() const;
Q_SIGNALS:
/**
* This signal is emitted whenever the document is about to close.
* @since 1.5.3
*/
void aboutToClose();
/**
* This signal is emitted whenever an action requests a
* document close operation.

Loading…
Cancel
Save