Skip to content

Commit

Permalink
Fix handling of failure modes that occur before a parser is created
Browse files Browse the repository at this point in the history
(cherry picked from commit 3ac783a)
  • Loading branch information
timangus committed Aug 7, 2023
1 parent ed18f62 commit 770b8de
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
12 changes: 11 additions & 1 deletion source/app/ui/document.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,12 @@ bool Document::openUrl(const QUrl& url, const QString& type, QString pluginName,
auto* plugin = _application->pluginForName(pluginName);

if(plugin == nullptr)
{
setFailureReason(tr("The plugin %1 could not be found.").arg(pluginName));
emit failureReasonChanged();
emit loadComplete(url, false);
return false;
}

if(type != Application::NativeFileType)
{
Expand Down Expand Up @@ -612,7 +617,12 @@ bool Document::openUrl(const QUrl& url, const QString& type, QString pluginName,

if(parser == nullptr)
{
qDebug() << "Plugin does not provide parser";
setFailureReason(tr("The plugin %1 does not provide a parser for %2. "
"This is probably a bug, please report it to the developers.")
.arg(pluginName, type));

emit failureReasonChanged();
emit loadComplete(url, false);
return false;
}
}
Expand Down
3 changes: 1 addition & 2 deletions source/app/ui/qml/main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -2830,8 +2830,7 @@ ApplicationWindow
{
let tab = currentTab;
tab.application = application;
if(!tab.openUrl(url, type, pluginName, parameters))
onLoadFailure(findTabIndex(tab), url);
tab.openUrl(url, type, pluginName, parameters);
}

function closeTab(index, onCloseFunction)
Expand Down

0 comments on commit 770b8de

Please sign in to comment.