[PATCH] Drop redundant parameter from some variable utils
- From: Dodji Seketeli <dodji seketeli org>
- To: Nemiver Development <nemiver-list gnome org>
- Subject: [PATCH] Drop redundant parameter from some variable utils
- Date: Sun, 19 Feb 2012 11:35:34 +0100
While working on something else, it occurred to me that a couple of
methods of nmv-variable-utils.{h,cc} where being passed both a tree
view and the tree model it uses. This is redundant as the tree model
can be retrieved from the tree model.
This patch thus removes that redundancy.
Tested and applied to master.
commit 44711beee8d75498a92beba66df40e49fd0a3960
Author: Dodji Seketeli <dodji seketeli org>
Date: Sat Feb 4 15:47:55 2012 +0100
Drop redundant parameter from some variable utils
* src/persp/dbgperspective/nmv-variables-utils.h
(append_a_variable, set_a_variable): Drop redundant a_tree_store
and the const from a_tree_view.
(update_a_variable_node, update_unfolded_variable)
(update_a_variable, visualize_a_variable): Adjust.
* src/persp/dbgperspective/nmv-variables-utils.cc
(append_a_variable, set_a_variable): Drop redundant
a_tree_store parameter. Get it from from the a_tree_view
parameter instead. Drop the const from a_tree_view as a
consequence. Adjust the rest of the function accordingly.
(update_a_variable_real, update_a_variable)
(update_a_variable_node, update_unfolded_variable)
(visualize_a_variable): Adjust.
* src/persp/dbgperspective/nmv-global-vars-inspector-dialog.cc
(append_a_global_variable): Adjust.
* src/persp/dbgperspective/nmv-local-vars-inspector.cc
(append_a_local_variable, append_a_function_argument)
(on_variable_unfolded_signal): Likewise.
* src/persp/dbgperspective/nmv-var-inspector.cc
(graphically_set_variable, on_variable_unfolded_signal): Likewise.
diff --git a/src/persp/dbgperspective/nmv-global-vars-inspector-dialog.cc b/src/persp/dbgperspective/nmv-global-vars-inspector-dialog.cc
index 03a944c..e321521 100644
--- a/src/persp/dbgperspective/nmv-global-vars-inspector-dialog.cc
+++ b/src/persp/dbgperspective/nmv-global-vars-inspector-dialog.cc
@@ -199,7 +199,6 @@ public:
typedef Glib::RefPtr<Gtk::TreeStore> TreeStoreRefPtr;
vutil::append_a_variable (a_var,
static_cast<Gtk::TreeView&> (*tree_view),
- TreeStoreRefPtr::cast_static (tree_store),
iter /* no parent */,
iter /* result iter */,
false /* do not truncate type */);
diff --git a/src/persp/dbgperspective/nmv-local-vars-inspector.cc b/src/persp/dbgperspective/nmv-local-vars-inspector.cc
index bc124ba..85bb00d 100644
--- a/src/persp/dbgperspective/nmv-local-vars-inspector.cc
+++ b/src/persp/dbgperspective/nmv-local-vars-inspector.cc
@@ -379,7 +379,6 @@ public:
if (get_local_variables_row_iterator (parent_row_it)) {
vutil::append_a_variable (a_var,
*tree_view,
- tree_store,
parent_row_it,
false /* do not truncate types */);
tree_view->expand_row (tree_store->get_path (parent_row_it), false);
@@ -399,7 +398,6 @@ public:
LOG_DD ("appending argument: " << a_var->name ());
vutil::append_a_variable (a_var,
*tree_view,
- tree_store,
parent_row_it,
false /* do not truncate type */);
tree_view->expand_row (tree_store->get_path (parent_row_it), false);
@@ -936,7 +934,6 @@ public:
Gtk::TreeModel::iterator var_it = tree_store->get_iter (a_var_node);
vutil::update_unfolded_variable (a_var,
*tree_view,
- tree_store,
var_it,
false /* do not truncate type */);
tree_view->expand_row (a_var_node, false);
diff --git a/src/persp/dbgperspective/nmv-var-inspector.cc b/src/persp/dbgperspective/nmv-var-inspector.cc
index d5f109f..60a3c3e 100644
--- a/src/persp/dbgperspective/nmv-var-inspector.cc
+++ b/src/persp/dbgperspective/nmv-var-inspector.cc
@@ -172,7 +172,6 @@ class VarInspector::Priv : public sigc::trackable {
Gtk::TreeModel::iterator var_row;
vutil::append_a_variable (a_variable,
*tree_view,
- tree_store,
parent_iter,
var_row,
true /* Do truncate type */);
@@ -510,7 +509,6 @@ class VarInspector::Priv : public sigc::trackable {
Gtk::TreeModel::iterator var_it = tree_store->get_iter (a_var_node);
vutil::update_unfolded_variable (a_var, *tree_view,
- tree_store,
var_it,
true /* Do truncate type */);
tree_view->expand_row (a_var_node, false);
diff --git a/src/persp/dbgperspective/nmv-variables-utils.cc b/src/persp/dbgperspective/nmv-variables-utils.cc
index cb05a9a..7c5762e 100644
--- a/src/persp/dbgperspective/nmv-variables-utils.cc
+++ b/src/persp/dbgperspective/nmv-variables-utils.cc
@@ -33,7 +33,7 @@ NEMIVER_BEGIN_NAMESPACE (nemiver)
NEMIVER_BEGIN_NAMESPACE (variables_utils2)
static void update_a_variable_real (const IDebugger::VariableSafePtr a_var,
- const Gtk::TreeView &a_tree_view,
+ Gtk::TreeView &a_tree_view,
Gtk::TreeModel::iterator &a_row_it,
bool a_truncate_type,
bool a_handle_highlight,
@@ -131,7 +131,7 @@ set_a_variable_node_type (Gtk::TreeModel::iterator &a_var_it,
// different from the previous one.
void
update_a_variable_node (const IDebugger::VariableSafePtr a_var,
- const Gtk::TreeView &a_tree_view,
+ Gtk::TreeView &a_tree_view,
Gtk::TreeModel::iterator &a_iter,
bool a_truncate_type,
bool a_handle_highlight,
@@ -195,7 +195,6 @@ update_a_variable_node (const IDebugger::VariableSafePtr a_var,
/// nodes representing the new children of a variable.
/// \a_var the variable that got unfolded
/// \a_tree_view the tree view in which a_var is represented
-/// \a_tree_store the tree store in which a_var is represented
/// \a_var_it the graphical node of the variable that got unfolded.
/// So what happened is that a_var got unfolded.
/// a_var is bound to the graphical node pointed to by a_var_it.
@@ -203,8 +202,7 @@ update_a_variable_node (const IDebugger::VariableSafePtr a_var,
/// nodes representing the new children of a_variable.
void
update_unfolded_variable (const IDebugger::VariableSafePtr a_var,
- const Gtk::TreeView &a_tree_view,
- const Glib::RefPtr<Gtk::TreeStore> &a_tree_store,
+ Gtk::TreeView &a_tree_view,
Gtk::TreeModel::iterator a_var_it,
bool a_truncate_type)
{
@@ -218,7 +216,6 @@ update_unfolded_variable (const IDebugger::VariableSafePtr a_var,
++member_it) {
append_a_variable (*member_it,
a_tree_view,
- a_tree_store,
a_var_it,
result_var_row_it,
a_truncate_type);
@@ -413,7 +410,7 @@ variables_match (const IDebugger::VariableSafePtr &a_var,
// representations of the members a_var.
bool
update_a_variable (const IDebugger::VariableSafePtr a_var,
- const Gtk::TreeView &a_tree_view,
+ Gtk::TreeView &a_tree_view,
Gtk::TreeModel::iterator &a_parent_row_it,
bool a_truncate_type,
bool a_handle_highlight,
@@ -455,7 +452,7 @@ update_a_variable (const IDebugger::VariableSafePtr a_var,
// the graphical representation of the members of a_var.
static void
update_a_variable_real (const IDebugger::VariableSafePtr a_var,
- const Gtk::TreeView &a_tree_view,
+ Gtk::TreeView &a_tree_view,
Gtk::TreeModel::iterator &a_row_it,
bool a_truncate_type,
bool a_handle_highlight,
@@ -488,23 +485,21 @@ update_a_variable_real (const IDebugger::VariableSafePtr a_var,
///
/// \param a_var the variable to add
/// \param a_tree_view the variable tree view widget to consider
-/// \param a_tree_store the tree store of the variable tree view widget
/// \param a_parent_row_it an iterator to the graphical parent node the
/// the variable is to be added to. If the iterator is false, then the
/// variable is added as the root node of the tree view widget.
/// \return true if a_var was added, false otherwise.
bool
append_a_variable (const IDebugger::VariableSafePtr a_var,
- const Gtk::TreeView &a_tree_view,
- const Glib::RefPtr<Gtk::TreeStore> &a_tree_store,
+ Gtk::TreeView &a_tree_view,
Gtk::TreeModel::iterator &a_parent_row_it,
bool a_truncate_type)
{
LOG_FUNCTION_SCOPE_NORMAL_DD;
Gtk::TreeModel::iterator row_it;
- return append_a_variable (a_var, a_tree_view, a_tree_store,
- a_parent_row_it, row_it, a_truncate_type);
+ return append_a_variable (a_var, a_tree_view, a_parent_row_it,
+ row_it, a_truncate_type);
}
/// Append a variable to a variable tree view widget.
@@ -512,7 +507,6 @@ append_a_variable (const IDebugger::VariableSafePtr a_var,
/// \param a_var the variable to add. It can be zero. In that case,
/// a dummy (empty) node is added as a graphical child of a_parent_row_it.
/// \param a_tree_view the variable tree view widget to consider
-/// \param a_tree_store the tree store of the variable tree view widget
/// \param a_parent_row_it an iterator to the graphical parent node the
/// the variable is to be added to. If the iterator is false, then the
/// variable is added as the root node of the tree view widget.
@@ -522,18 +516,20 @@ append_a_variable (const IDebugger::VariableSafePtr a_var,
/// \return true if a_var was added, false otherwise.
bool
append_a_variable (const IDebugger::VariableSafePtr a_var,
- const Gtk::TreeView &a_tree_view,
- const Glib::RefPtr<Gtk::TreeStore> &a_tree_store,
+ Gtk::TreeView &a_tree_view,
Gtk::TreeModel::iterator &a_parent_row_it,
Gtk::TreeModel::iterator &a_result,
bool a_truncate_type)
{
LOG_FUNCTION_SCOPE_NORMAL_DD;
- THROW_IF_FAIL (a_tree_store);
+
+ Glib::RefPtr<Gtk::TreeStore> tree_store =
+ Glib::RefPtr<Gtk::TreeStore>::cast_dynamic (a_tree_view.get_model ());
+ THROW_IF_FAIL (tree_store);
Gtk::TreeModel::iterator row_it;
if (!a_parent_row_it) {
- row_it = a_tree_store->append ();
+ row_it = tree_store->append ();
} else {
if (a_parent_row_it->children ()
&& a_var
@@ -545,18 +541,17 @@ append_a_variable (const IDebugger::VariableSafePtr a_var,
Gtk::TreeModel::Children::const_iterator it;
for (it = a_parent_row_it->children ().begin ();
it != a_parent_row_it->children ().end ();) {
- it = a_tree_store->erase (it);
+ it = tree_store->erase (it);
}
(*a_parent_row_it)[get_variable_columns ().needs_unfolding]
= false;
}
- row_it = a_tree_store->append (a_parent_row_it->children ());
+ row_it = tree_store->append (a_parent_row_it->children ());
}
if (!a_var) {
return false;
}
- if (!set_a_variable (a_var, a_tree_view, a_tree_store,
- row_it, a_truncate_type))
+ if (!set_a_variable (a_var, a_tree_view, row_it, a_truncate_type))
return false;
a_result = row_it;
return true;
@@ -570,8 +565,6 @@ append_a_variable (const IDebugger::VariableSafePtr a_var,
/// \param a_tree_view the treeview containing the graphical
/// representation to set.
///
-/// \param a_tree_store the treestore of the treeview.
-///
/// \param a_row_it an iterator to the row of the graphical
/// representation of the variable.
///
@@ -581,13 +574,15 @@ append_a_variable (const IDebugger::VariableSafePtr a_var,
/// \return TRUE upon successful completion
bool
set_a_variable (const IDebugger::VariableSafePtr a_var,
- const Gtk::TreeView &a_tree_view,
- const Glib::RefPtr<Gtk::TreeStore> &a_tree_store,
+ Gtk::TreeView &a_tree_view,
Gtk::TreeModel::iterator a_row_it,
bool a_truncate_type)
{
LOG_FUNCTION_SCOPE_NORMAL_DD;
- THROW_IF_FAIL (a_tree_store);
+
+ Glib::RefPtr<const Gtk::TreeStore> tree_store =
+ Glib::RefPtr<const Gtk::TreeStore>::cast_dynamic (a_tree_view.get_model ());
+ THROW_IF_FAIL (tree_store);
if (!a_var) {
return false;
@@ -603,15 +598,12 @@ set_a_variable (const IDebugger::VariableSafePtr a_var,
(*a_row_it)[get_variable_columns ().needs_unfolding] = true;
IDebugger::VariableSafePtr empty_var;
append_a_variable (empty_var, a_tree_view,
- a_tree_store, a_row_it,
- a_truncate_type);
+ a_row_it, a_truncate_type);
} else {
for (it = a_var->members ().begin ();
it != a_var->members ().end ();
++it) {
- append_a_variable (*it, a_tree_view,
- a_tree_store, a_row_it,
- a_truncate_type);
+ append_a_variable (*it, a_tree_view, a_row_it, a_truncate_type);
}
}
return true;
@@ -666,14 +658,13 @@ unlink_member_variable_rows (const Gtk::TreeModel::iterator &a_row_it,
bool
visualize_a_variable (const IDebugger::VariableSafePtr a_var,
const Gtk::TreeModel::iterator &a_row_it,
- const Gtk::TreeView &a_tree_view,
+ Gtk::TreeView &a_tree_view,
const Glib::RefPtr<Gtk::TreeStore> &a_store)
{
if (!unlink_member_variable_rows (a_row_it, a_store))
return false;
- return set_a_variable (a_var, a_tree_view,
- a_store, a_row_it,
+ return set_a_variable (a_var, a_tree_view, a_row_it,
/*a_truncate_type=*/true);
}
diff --git a/src/persp/dbgperspective/nmv-variables-utils.h b/src/persp/dbgperspective/nmv-variables-utils.h
index d650ec2..29861a6 100644
--- a/src/persp/dbgperspective/nmv-variables-utils.h
+++ b/src/persp/dbgperspective/nmv-variables-utils.h
@@ -82,15 +82,14 @@ void set_a_variable_node_type (Gtk::TreeModel::iterator &a_var_it,
bool a_truncate);
void update_a_variable_node (const IDebugger::VariableSafePtr a_var,
- const Gtk::TreeView &a_tree_view,
+ Gtk::TreeView &a_tree_view,
Gtk::TreeModel::iterator &a_iter,
bool a_truncate_type,
bool a_handle_highlight,
bool a_is_new_frame);
void update_unfolded_variable (const IDebugger::VariableSafePtr a_var,
- const Gtk::TreeView &a_tree_view,
- const Glib::RefPtr<Gtk::TreeStore> &a_tree_store,
+ Gtk::TreeView &a_tree_view,
Gtk::TreeModel::iterator a_var_it,
bool a_truncate_type);
@@ -106,7 +105,7 @@ bool find_a_variable_descendent (const IDebugger::VariableSafePtr a_var,
Gtk::TreeModel::iterator &a_out_row_it);
bool update_a_variable (const IDebugger::VariableSafePtr a_var,
- const Gtk::TreeView &a_tree_view,
+ Gtk::TreeView &a_tree_view,
Gtk::TreeModel::iterator &a_parent_row_it,
bool a_truncate_type,
bool a_handle_highlight,
@@ -114,21 +113,18 @@ bool update_a_variable (const IDebugger::VariableSafePtr a_var,
bool a_update_members = false);
bool append_a_variable (const IDebugger::VariableSafePtr a_var,
- const Gtk::TreeView &a_tree_view,
- const Glib::RefPtr<Gtk::TreeStore> &a_tree_store,
+ Gtk::TreeView &a_tree_view,
Gtk::TreeModel::iterator &a_parent_row_it,
bool a_truncate_type);
bool append_a_variable (const IDebugger::VariableSafePtr a_var,
- const Gtk::TreeView &a_tree_view,
- const Glib::RefPtr<Gtk::TreeStore> &a_tree_store,
+ Gtk::TreeView &a_tree_view,
Gtk::TreeModel::iterator &a_parent_row_it,
Gtk::TreeModel::iterator &a_result,
bool a_truncate_type);
bool set_a_variable (const IDebugger::VariableSafePtr a_var,
- const Gtk::TreeView &a_tree_view,
- const Glib::RefPtr<Gtk::TreeStore> &a_tree_store,
+ Gtk::TreeView &a_tree_view,
Gtk::TreeModel::iterator a_row_it,
bool a_truncate_type);
@@ -137,7 +133,7 @@ bool unlink_member_variable_rows (const Gtk::TreeModel::iterator &a_row_it,
bool visualize_a_variable (const IDebugger::VariableSafePtr a_var,
const Gtk::TreeModel::iterator &a_var_row_it,
- const Gtk::TreeView &a_tree_view,
+ Gtk::TreeView &a_tree_view,
const Glib::RefPtr<Gtk::TreeStore> &a_store);
NEMIVER_END_NAMESPACE (variables_utils2)
--
Dodji
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]