[gparted] Restore specific error message on failure to launch yelp



commit e3ae8a6f26323ffdba6646dacb1a8f0a1c7623df
Author: Mike Fleetwood <mike fleetwood googlemail com>
Date:   Wed Feb 27 18:53:08 2019 +0000

    Restore specific error message on failure to launch yelp
    
    Originally, if the yelp command was not installed, attempting to display
    help produced an error dialog with this message:
        Failed to execute child process "yelp" (No such file or directory)
    
    However since this commit during the Gtk 3 port [1] the error message
    became this less useful one:
        Operation not supported
    
    Two attempts are made to display the GParted Manual, first using
    gtk_show_uri() and second by executing the yelp command directly.  Prior
    to the aforementioned commit [1] both methods returned the failure
    reason using the same 'error' variable.  Hence reported the message
    "Failed to execute child process "yelp" ..." from the second attempt.
    However that commit had to re-code the second method as part of the Gtk
    3 port and use a different error returning mechanism, thus the use of
    different variable 'e'.  But the dialog was left reporting the message
    from the original 'error' variable, thus reporting "Operation not
    supported" message from the first attempt using gtk_show_uri().
    
    Fix by again displaying the message from the second failure into the
    error dialog.  Also make it very clear there are two error returning
    variables by naming them 'error1' and 'error2_msg'.
    
    [1] 2953778a4c0e61d8fe49c7a6d707add8a9eb0634
        port-to-gtk3: Use Gdk::AppLaunchContext to launch yelp (#7)

 src/Win_GParted.cc | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)
---
diff --git a/src/Win_GParted.cc b/src/Win_GParted.cc
index 7ebbeec0..bbd0f056 100644
--- a/src/Win_GParted.cc
+++ b/src/Win_GParted.cc
@@ -1774,7 +1774,7 @@ void Win_GParted::show_help_dialog( const Glib::ustring & filename /* E.g., gpar
                                   , const Glib::ustring & link_id  /* For context sensitive help */
                                   )
 {
-       GError *error = NULL ;
+       GError *error1 = NULL;
        GdkScreen *gscreen = NULL ;
 
        Glib::ustring uri = "help:" + filename;
@@ -1782,8 +1782,8 @@ void Win_GParted::show_help_dialog( const Glib::ustring & filename /* E.g., gpar
                uri = uri + "/" + link_id;
 
        gscreen = get_window()->get_screen()->gobj();
-       gtk_show_uri( gscreen, uri .c_str(), gtk_get_current_event_time(), &error ) ;
-       if ( error != NULL )
+       gtk_show_uri(gscreen, uri.c_str(), gtk_get_current_event_time(), &error1);
+       if (error1 != NULL)
        {
                //Try opening yelp application directly
 
@@ -1796,13 +1796,14 @@ void Win_GParted::show_help_dialog( const Glib::ustring & filename /* E.g., gpar
                context->set_timestamp(gtk_get_current_event_time());
 
                bool launched;
+               Glib::ustring error2_msg;
                try
                {
                        launched = yelp->launch_uris(std::vector<std::string>(1, uri), context);
                }
                catch (Glib::Error& e)
                {
-                       std::cerr << e.what() << std::endl;
+                       error2_msg = e.what();
                        launched = false;
                }
 
@@ -1814,11 +1815,11 @@ void Win_GParted::show_help_dialog( const Glib::ustring & filename /* E.g., gpar
                                                  Gtk::MESSAGE_ERROR,
                                                  Gtk::BUTTONS_OK,
                                                  true);
-                       dialog.set_secondary_text(error->message);
+                       dialog.set_secondary_text(error2_msg);
                        dialog.run();
                }
 
-               g_clear_error(&error);
+               g_clear_error(&error1);
        }
 }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]