[nemiver/follow-fork-mode: 34/35] Better handling of empty notebooks



commit 9a780cbb17ecbee47911a9cc6a4a9925799c482d
Author: Dodji Seketeli <dodji gnome org>
Date:   Wed May 5 16:49:05 2010 +0200

    Better handling of empty notebooks
    
    	* src/persp/dbgperspective/nmv-dbg-perspective.cc
    	(DBGPerspective::get_current_source_editor): Do not emit error
    	logs on empty notebook.
    	(DBGPerspective::get_num_notebook_pages): Do not throw on empty
    	notebook.

 src/persp/dbgperspective/nmv-dbg-perspective.cc |   16 +++++++---------
 1 files changed, 7 insertions(+), 9 deletions(-)
---
diff --git a/src/persp/dbgperspective/nmv-dbg-perspective.cc b/src/persp/dbgperspective/nmv-dbg-perspective.cc
index 48950a0..5bf177e 100644
--- a/src/persp/dbgperspective/nmv-dbg-perspective.cc
+++ b/src/persp/dbgperspective/nmv-dbg-perspective.cc
@@ -4238,14 +4238,8 @@ DBGPerspective::get_current_source_editor (bool a_load_if_nil)
 {
     THROW_IF_FAIL (m_priv);
 
-    if (!m_priv->sourceviews_notebook) {
-        LOG_ERROR ("NULL m_priv->sourceviews_notebook");
-        return 0;
-    }
-
-    if (a_load_if_nil
-        && m_priv->sourceviews_notebook
-        && !m_priv->sourceviews_notebook->get_n_pages ()) {
+    int num_pages = get_num_notebook_pages ();
+    if (a_load_if_nil && num_pages == 0) {
         // The source notebook is empty. If the current frame
         // has file info, load the file, bring it to the front,
         // apply decorations to it and return its editor.
@@ -4264,6 +4258,8 @@ DBGPerspective::get_current_source_editor (bool a_load_if_nil)
                            /*scroll_to_where_marker=*/true);
         bring_source_as_current (editor);
         return editor;
+    } else if (num_pages == 0) {
+        return 0;
     }
 
     LOG_DD ("current pagenum: "
@@ -4954,8 +4950,10 @@ DBGPerspective::read_default_config ()
 int
 DBGPerspective::get_num_notebook_pages ()
 {
-    THROW_IF_FAIL (m_priv && m_priv->sourceviews_notebook);
+    THROW_IF_FAIL (m_priv);
 
+    if (!m_priv->sourceviews_notebook)
+        return 0;
     return m_priv->sourceviews_notebook->get_n_pages ();
 }
 



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