[nemiver/better-variable-format: 7/8] Avoid emitting useless -enable-pretty-printing



commit 6345c248bbdd87e26ae2dae00bead12a80d6ef5b
Author: Dodji Seketeli <dodji seketeli org>
Date:   Wed Mar 2 15:28:29 2011 +0100

    Avoid emitting useless -enable-pretty-printing
    
    	* src/dbgengine/nmv-gdb-engine.cc
    	(GDBEngine::Priv::pretty_printing_enabled_once): New member.
    	(GDBEngine::Priv::on_conf_key_changed_signal): Don't emit
    	-enable-pretty-printing if it has already been emitted once.
    	(GDBEngine::load_program): Likewise.

 src/dbgengine/nmv-gdb-engine.cc |   24 +++++++++++++++++++-----
 1 files changed, 19 insertions(+), 5 deletions(-)
---
diff --git a/src/dbgengine/nmv-gdb-engine.cc b/src/dbgengine/nmv-gdb-engine.cc
index 45bd43b..e817d3d 100644
--- a/src/dbgengine/nmv-gdb-engine.cc
+++ b/src/dbgengine/nmv-gdb-engine.cc
@@ -140,6 +140,11 @@ public:
     UString follow_fork_mode;
     GDBMIParser gdbmi_parser;
     bool enable_pretty_printing;
+    // Once pretty printing has been globally enabled once, there is
+    // no command to globally disable it.  So once it has been enabled
+    // globally, we shouldn't try to globally enable it again.  So
+    // let's keep track of if we enabled it once.
+    bool pretty_printing_enabled_once;
     sigc::signal<void> gdb_died_signal;
     sigc::signal<void, const UString& > master_pty_signal;
     sigc::signal<void, const UString& > gdb_stdout_signal;
@@ -463,7 +468,8 @@ public:
         cur_thread_num (1),
         follow_fork_mode ("parent"),
         gdbmi_parser (GDBMIParser::BROKEN_MODE),
-        enable_pretty_printing (true)
+        enable_pretty_printing (true),
+        pretty_printing_enabled_once (false)
     {
 
         enable_pretty_printing =
@@ -1029,9 +1035,16 @@ public:
             follow_fork_mode = boost::get<UString> (a_value).raw ();
             set_debugger_parameter ("follow-fork-mode", follow_fork_mode);
         } else if (a_key == CONF_KEY_PRETTY_PRINTING) {
-            enable_pretty_printing = boost::get<bool> (a_value);
-            if (enable_pretty_printing) {
-                queue_command (Command ("-enable-pretty-printing"));
+            bool e = boost::get<bool> (a_value);
+            // Don't react if the new value == the old value.
+            if (e != enable_pretty_printing) {
+                enable_pretty_printing = e;
+                if (!pretty_printing_enabled_once
+                    && enable_pretty_printing) {
+                    queue_command (Command ("-enable-pretty-printing"));
+                    if (!pretty_printing_enabled_once)
+                        pretty_printing_enabled_once = true;
+                }
             }
         }
 
@@ -2804,7 +2817,8 @@ GDBEngine::load_program (const UString &a_prog,
         } else {
             LOG_DD ("not setting LD_BIND_NOW environment variable ");
         }
-        if (m_priv->enable_pretty_printing)
+        if (m_priv->enable_pretty_printing
+            && !m_priv->pretty_printing_enabled_once)
             queue_command (Command ("-enable-pretty-printing"));
     } else {
         Command command ("load-program",



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