From: Juergen Spitzmueller Date: Thu, 27 Aug 2020 09:52:52 +0000 (+0200) Subject: Report back if citation target could not be opened X-Git-Tag: lyx-2.4.0dev-acb2ca7b~283 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=ff14d0bd007065f058951d902255496f38a6d056;p=lyx.git Report back if citation target could not be opened --- diff --git a/lib/scripts/lyxpaperview.py b/lib/scripts/lyxpaperview.py index 3a611a67b7..f62c5ea9a3 100755 --- a/lib/scripts/lyxpaperview.py +++ b/lib/scripts/lyxpaperview.py @@ -122,7 +122,7 @@ def main(argv): result = find(args, path = os.environ["HOME"]) if result == "": message("no document found!") - return 0 + exit(2) else: message("found document %s" % result) @@ -140,7 +140,7 @@ def main(argv): subprocess.call([viewer, result]) - return 0 + exit(0) if __name__ == "__main__": main(sys.argv) diff --git a/src/frontends/qt/qt_helpers.cpp b/src/frontends/qt/qt_helpers.cpp index f064d50d14..20f58034c7 100644 --- a/src/frontends/qt/qt_helpers.cpp +++ b/src/frontends/qt/qt_helpers.cpp @@ -298,7 +298,8 @@ void showDirectory(FileName const & directory) LYXERR0("Unable to open QUrl even though dir exists!"); } -void showTarget(string const & target, string const & pdfv, string const & psv){ +void showTarget(string const & target, string const & pdfv, string const & psv) +{ LYXERR(Debug::INSETS, "Showtarget:" << target << "\n"); if (prefixIs(target, "EXTERNAL ")) { if (!lyxrc.citation_search) @@ -311,12 +312,23 @@ void showTarget(string const & target, string const & pdfv, string const & psv){ opts += " -w " + psv; if (!opts.empty()) opts += " "; - FuncRequest cmd = FuncRequest(LFUN_VC_COMMAND,"U . \"" + - lyxrc.citation_search_view + " " + opts + tar + "\""); - lyx::dispatch(cmd); + Systemcall one; + string const command = lyxrc.citation_search_view + " " + opts + tar; + int const result = one.startscript(Systemcall::Wait, command); + if (result == 1) + // Script failed + frontend::Alert::error(_("Could not open file"), + _("The lyxpaperview script failed.")); + else if (result == 2) + frontend::Alert::error(_("Could not open file"), + bformat(_("No file was found using the pattern `%1$s'."), + from_utf8(tar))); return; } - QDesktopServices::openUrl(QUrl(toqstr(target), QUrl::TolerantMode)); + if (!QDesktopServices::openUrl(QUrl(toqstr(target), QUrl::TolerantMode))) + frontend::Alert::error(_("Could not open file"), + bformat(_("The target `%1$s' could not be resolved."), + from_utf8(target))); } } // namespace frontend