Commit eee71036 authored by Albert Astals Cid's avatar Albert Astals Cid
Browse files

Fix crash in bug 400104 again

And also make clazy happier so we don't need an exclude
parent c0de8366
Pipeline #76793 passed with stage
in 10 minutes and 57 seconds
...@@ -3843,15 +3843,20 @@ QString Document::bookmarkedPageRange() const ...@@ -3843,15 +3843,20 @@ QString Document::bookmarkedPageRange() const
return range; return range;
} }
struct ExecuteNextActionsHelper : public QObject {
Q_OBJECT
public:
bool b = true;
};
void Document::processAction(const Action *action) void Document::processAction(const Action *action)
{ {
if (!action) if (!action)
return; return;
// Don't execute next actions if the action itself caused the closing of the document // Don't execute next actions if the action itself caused the closing of the document
bool executeNextActions = true; ExecuteNextActionsHelper executeNextActions;
QObject disconnectHelper; // guarantees the connect below will be disconnected on finishing the function connect(this, &Document::aboutToClose, &executeNextActions, [&executeNextActions] { executeNextActions.b = false; });
connect(this, &Document::aboutToClose, &disconnectHelper, [&executeNextActions] { executeNextActions = false; }); // clazy:exclude=lambda-in-connect
switch (action->actionType()) { switch (action->actionType()) {
case Action::Goto: { case Action::Goto: {
...@@ -3868,8 +3873,9 @@ void Document::processAction(const Action *action) ...@@ -3868,8 +3873,9 @@ void Document::processAction(const Action *action)
// it does not show anything // it does not show anything
// first open filename if link is pointing outside this document // first open filename if link is pointing outside this document
if (go->isExternal() && !d->openRelativeFile(go->fileName())) { const QString filename = go->fileName();
qCWarning(OkularCoreDebug).nospace() << "Action: Error opening '" << go->fileName() << "'."; if (go->isExternal() && !d->openRelativeFile(filename)) {
qCWarning(OkularCoreDebug).nospace() << "Action: Error opening '" << filename << "'.";
break; break;
} else { } else {
const DocumentViewport nextViewport = d->nextDocumentViewport(); const DocumentViewport nextViewport = d->nextDocumentViewport();
...@@ -4030,7 +4036,7 @@ void Document::processAction(const Action *action) ...@@ -4030,7 +4036,7 @@ void Document::processAction(const Action *action)
} break; } break;
} }
if (executeNextActions) { if (executeNextActions.b) {
const QVector<Action *> nextActions = action->nextActions(); const QVector<Action *> nextActions = action->nextActions();
for (const Action *a : nextActions) { for (const Action *a : nextActions) {
processAction(a); processAction(a);
...@@ -5557,4 +5563,6 @@ void NewSignatureData::setBoundingRectangle(const NormalizedRect &rect) ...@@ -5557,4 +5563,6 @@ void NewSignatureData::setBoundingRectangle(const NormalizedRect &rect)
#undef foreachObserver #undef foreachObserver
#undef foreachObserverD #undef foreachObserverD
#include "document.moc"
/* kate: replace-tabs on; indent-width 4; */ /* kate: replace-tabs on; indent-width 4; */
Supports Markdown
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