Skip to content

Commit 0f5ce86

Browse files
ferdymercurydpiparo
authored andcommitted
[core] print URL to terminal if web browser could not be opened
Fixes #22496 (cherry picked from commit 295249a)
1 parent f47deb4 commit 0f5ce86

1 file changed

Lines changed: 16 additions & 13 deletions

File tree

core/base/src/TApplication.cxx

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -624,7 +624,8 @@ TApplication::EExitOnException TApplication::ExitOnException(TApplication::EExit
624624
/// The function generates and executes a command that loads the Doxygen URL in
625625
/// a browser. It works for Mac, Windows and Linux. In the case of Linux, the
626626
/// function also checks if the DISPLAY is set. If it isn't, a warning message
627-
/// and the URL will be displayed on the terminal.
627+
/// and the URL will be displayed on the terminal. In all OS, if the system command
628+
/// fails, the URL will be also displayed on the terminal.
628629
///
629630
/// \param[in] url web page to be displayed in a browser
630631

@@ -636,26 +637,28 @@ void TApplication::OpenInBrowser(const TString &url)
636637
TString cMac("open ");
637638
// We generate the full command and execute it.
638639
cMac.Append(url);
639-
gSystem->Exec(cMac);
640+
auto res = gSystem->Exec(cMac);
640641
#elif defined(R__WIN32)
641642
// Command for opening a browser on Windows.
642643
TString cWindows("start \"\" ");
643644
cWindows.Append(url);
644-
gSystem->Exec(cWindows);
645+
auto res = gSystem->Exec(cWindows);
645646
#else
646-
// Command for opening a browser in Linux.
647+
// For Linux we check first if the DISPLAY is set.
648+
if (!gSystem->Getenv("DISPLAY")) {
649+
// The user will have a warning and the URL in the terminal.
650+
Warning("OpenInBrowser", "The $DISPLAY is not set! Please manually open (e.g. Ctrl-click) %s\n", url.Data());
651+
return;
652+
}
653+
// Command for opening a browser in Linux. Since the DISPLAY is set, it will open the browser.
647654
TString cLinux("xdg-open ");
648-
// For Linux we check if the DISPLAY is set.
649-
if (gSystem->Getenv("DISPLAY")) {
650-
// If the DISPLAY is set it will open the browser.
651-
cLinux.Append(url);
652-
gSystem->Exec(cLinux);
653-
} else {
654-
// Else the user will have a warning and the URL in the terminal.
655-
Warning("OpenInBrowser", "The $DISPLAY is not set! Please open (e.g. Ctrl-click) %s\n", url.Data());
655+
cLinux.Append(url);
656+
auto res = gSystem->Exec(cLinux);
657+
#endif
658+
if (res != EXIT_SUCCESS) {
659+
Warning("OpenInBrowser", "Could not automatically open web browser (e.g. due to missing X11)! Please manually open (e.g. Ctrl-click) %s\n", url.Data());
656660
return;
657661
}
658-
#endif
659662
Info("OpenInBrowser", "A new tab should have opened in your browser.");
660663
}
661664

0 commit comments

Comments
 (0)