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
return range;
}
struct ExecuteNextActionsHelper : public QObject {
Q_OBJECT
public:
bool b = true;
};
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;
QObject disconnectHelper; // guarantees the connect below will be disconnected on finishing the function
connect(this, &Document::aboutToClose, &disconnectHelper, [&executeNextActions] { executeNextActions = false; }); // clazy:exclude=lambda-in-connect
ExecuteNextActionsHelper executeNextActions;
connect(this, &Document::aboutToClose, &executeNextActions, [&executeNextActions] { executeNextActions.b = false; });
switch (action->actionType()) {
case Action::Goto: {
......@@ -3868,8 +3873,9 @@ void Document::processAction(const Action *action)
// it does not show anything
// first open filename if link is pointing outside this document
if (go->isExternal() && !d->openRelativeFile(go->fileName())) {
qCWarning(OkularCoreDebug).nospace() << "Action: Error opening '" << go->fileName() << "'.";
const QString filename = go->fileName();
if (go->isExternal() && !d->openRelativeFile(filename)) {
qCWarning(OkularCoreDebug).nospace() << "Action: Error opening '" << filename << "'.";
break;
} else {
const DocumentViewport nextViewport = d->nextDocumentViewport();
......@@ -4030,7 +4036,7 @@ void Document::processAction(const Action *action)
} break;
}
if (executeNextActions) {
if (executeNextActions.b) {
const QVector<Action *> nextActions = action->nextActions();
for (const Action *a : nextActions) {
processAction(a);
......@@ -5557,4 +5563,6 @@ void NewSignatureData::setBoundingRectangle(const NormalizedRect &rect)
#undef foreachObserver
#undef foreachObserverD
#include "document.moc"
/* kate: replace-tabs on; indent-width 4; */
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