]> git.lyx.org Git - lyx.git/commitdiff
Report back if citation target could not be opened
authorJuergen Spitzmueller <spitz@lyx.org>
Thu, 27 Aug 2020 09:52:52 +0000 (11:52 +0200)
committerJuergen Spitzmueller <spitz@lyx.org>
Thu, 27 Aug 2020 09:52:52 +0000 (11:52 +0200)
lib/scripts/lyxpaperview.py
src/frontends/qt/qt_helpers.cpp

index 3a611a67b77325091287ce5a718336537a68143f..f62c5ea9a3e18b3f89e9d42726a52aab2d4fd810 100755 (executable)
@@ -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)
index f064d50d14f32e3bf6683740b1f8a0b63b1d5243..20f58034c73aed0f76d9109cc5f6312b43c1905c 100644 (file)
@@ -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