[glom] Revert "Use std::weak_ptr instead of shared_ptr for callbacks."
- From: Murray Cumming <murrayc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glom] Revert "Use std::weak_ptr instead of shared_ptr for callbacks."
- Date: Fri, 30 Sep 2016 08:38:09 +0000 (UTC)
commit 8150d79fa940df3f6c1d959366c63711a8cc40cf
Author: Murray Cumming <murrayc murrayc com>
Date: Fri Sep 30 08:43:19 2016 +0200
Revert "Use std::weak_ptr instead of shared_ptr for callbacks."
This reverts commit 84042a5a29f0bb7b9ea31d1b97079460bae30b11.
Because this is only necessary for bound parameters.
glom/mode_data/box_data_details.cc | 21 ++++-----------------
glom/mode_data/box_data_details.h | 8 ++++----
glom/mode_data/box_data_list.cc | 9 ++-------
glom/mode_data/box_data_list.h | 4 ++--
glom/mode_data/box_data_list_related.cc | 9 ++-------
glom/mode_data/box_data_list_related.h | 4 ++--
glom/mode_data/flowtablewithfields.cc | 24 ++++--------------------
glom/mode_data/flowtablewithfields.h | 16 ++++++++--------
glom/mode_find/box_data_details_find.cc | 2 +-
glom/mode_find/box_data_details_find.h | 2 +-
10 files changed, 30 insertions(+), 69 deletions(-)
---
diff --git a/glom/mode_data/box_data_details.cc b/glom/mode_data/box_data_details.cc
index cdd1c87..77bafd6 100644
--- a/glom/mode_data/box_data_details.cc
+++ b/glom/mode_data/box_data_details.cc
@@ -645,12 +645,8 @@ void Box_Data_Details::on_flowtable_related_record_changed(const Glib::ustring&
recalculate_fields_for_related_records(relationship_name);
}
-void Box_Data_Details::on_flowtable_field_open_details_requested(const std::weak_ptr<const
LayoutItem_Field>& layout_field_weak, const Gnome::Gda::Value& field_value)
+void Box_Data_Details::on_flowtable_field_open_details_requested(const std::shared_ptr<const
LayoutItem_Field>& layout_field, const Gnome::Gda::Value& field_value)
{
- const auto layout_field = layout_field_weak.lock();
- if(!layout_field)
- return;
-
if(Conversions::value_is_empty(field_value))
return; //Ignore empty ID fields.
@@ -681,9 +677,8 @@ void Box_Data_Details::on_flowtable_field_open_details_requested(const std::weak
}
}
-void Box_Data_Details::on_flowtable_script_button_clicked(const std::weak_ptr<const LayoutItem_Button>&
layout_item_weak)
+void Box_Data_Details::on_flowtable_script_button_clicked(const std::shared_ptr<const LayoutItem_Button>&
layout_item)
{
- const auto layout_item = layout_item_weak.lock();
if(!layout_item)
{
std::cerr << G_STRFUNC << ": layout_item is null\n";
@@ -711,15 +706,11 @@ void Box_Data_Details::on_flowtable_script_button_clicked(const std::weak_ptr<co
}
}
-void Box_Data_Details::on_flowtable_field_edited(const std::weak_ptr<const LayoutItem_Field>&
layout_field_weak, const Gnome::Gda::Value& field_value)
+void Box_Data_Details::on_flowtable_field_edited(const std::shared_ptr<const LayoutItem_Field>&
layout_field, const Gnome::Gda::Value& field_value)
{
if(m_ignore_signals)
return;
- const auto layout_field = layout_field_weak.lock();
- if (!layout_field)
- return;
-
const auto strFieldName = layout_field->get_name();
auto window = get_app_window();
@@ -905,15 +896,11 @@ void Box_Data_Details::on_flowtable_field_edited(const std::weak_ptr<const Layou
} //if(get_primary_key_value_selected().size())
}
-void Box_Data_Details::on_flowtable_field_choices_changed(const std::weak_ptr<const LayoutItem_Field>&
layout_field_weak)
+void Box_Data_Details::on_flowtable_field_choices_changed(const std::shared_ptr<const LayoutItem_Field>&
layout_field)
{
if(m_ignore_signals)
return;
- const auto layout_field = layout_field_weak.lock();
- if (!layout_field)
- return;
-
m_FlowTable.update_choices(*layout_field);
}
diff --git a/glom/mode_data/box_data_details.h b/glom/mode_data/box_data_details.h
index f6af984..e10f75d 100644
--- a/glom/mode_data/box_data_details.h
+++ b/glom/mode_data/box_data_details.h
@@ -119,14 +119,14 @@ protected:
//void on_related_user_requested_details(Gnome::Gda::Value key_value, Glib::ustring table_name);
//This is virtual so it can be overriden in Box_Data_Details_Find.
- virtual void on_flowtable_field_edited(const std::weak_ptr<const LayoutItem_Field>& layout_field_weak,
const Gnome::Gda::Value& value);
+ virtual void on_flowtable_field_edited(const std::shared_ptr<const LayoutItem_Field>& layout_field, const
Gnome::Gda::Value& value);
- void on_flowtable_field_choices_changed(const std::weak_ptr<const LayoutItem_Field>& layout_field_weak);
- void on_flowtable_field_open_details_requested(const std::weak_ptr<const LayoutItem_Field>& id_weak, const
Gnome::Gda::Value& value);
+ void on_flowtable_field_choices_changed(const std::shared_ptr<const LayoutItem_Field>& layout_field);
+ void on_flowtable_field_open_details_requested(const std::shared_ptr<const LayoutItem_Field>& id, const
Gnome::Gda::Value& value);
void on_flowtable_related_record_changed(const Glib::ustring& relationship_name);
void on_flowtable_requested_related_details(const Glib::ustring& table_name, Gnome::Gda::Value
primary_key_value);
- void on_flowtable_script_button_clicked(const std::weak_ptr<const LayoutItem_Button>& layout_item_weak);
+ void on_flowtable_script_button_clicked(const std::shared_ptr<const LayoutItem_Button>& layout_item);
void recalculate_fields_for_related_records(const Glib::ustring& relationship_name);
diff --git a/glom/mode_data/box_data_list.cc b/glom/mode_data/box_data_list.cc
index f2b97be..2b61205 100644
--- a/glom/mode_data/box_data_list.cc
+++ b/glom/mode_data/box_data_list.cc
@@ -175,9 +175,8 @@ void Box_Data_List::set_primary_key_value(const Gtk::TreeModel::iterator& row, c
m_AddDel.set_value_key(row, value);
}
-void Box_Data_List::on_adddel_script_button_clicked(const std::weak_ptr<const LayoutItem_Button>&
layout_item_weak, const Gtk::TreeModel::iterator& row)
+void Box_Data_List::on_adddel_script_button_clicked(const std::shared_ptr<const LayoutItem_Button>&
layout_item, const Gtk::TreeModel::iterator& row)
{
- const auto layout_item = layout_item_weak.lock();
if(!layout_item)
return;
@@ -196,12 +195,8 @@ void Box_Data_List::on_adddel_script_button_clicked(const std::weak_ptr<const La
primary_key_value));
}
-bool Box_Data_List::on_script_button_idle(const std::weak_ptr<const LayoutItem_Button>& layout_item_weak,
const Gnome::Gda::Value& primary_key)
+bool Box_Data_List::on_script_button_idle(const std::shared_ptr<const LayoutItem_Button>& layout_item, const
Gnome::Gda::Value& primary_key)
{
- const auto layout_item = layout_item_weak.lock();
- if(!layout_item)
- return false;
-
execute_button_script(layout_item, primary_key);
// Refill view from database as the script might have changed arbitrary records
diff --git a/glom/mode_data/box_data_list.h b/glom/mode_data/box_data_list.h
index 2544e9a..1ba572f 100644
--- a/glom/mode_data/box_data_list.h
+++ b/glom/mode_data/box_data_list.h
@@ -96,8 +96,8 @@ protected:
void on_adddel_user_requested_layout();
#endif // !GLOM_ENABLE_CLIENT_ONLY
- void on_adddel_script_button_clicked(const std::weak_ptr<const LayoutItem_Button>& layout_item_weak, const
Gtk::TreeModel::iterator& row);
- bool on_script_button_idle(const std::weak_ptr<const LayoutItem_Button>& layout_item_weak, const
Gnome::Gda::Value& primary_key);
+ void on_adddel_script_button_clicked(const std::shared_ptr<const LayoutItem_Button>& layout_item, const
Gtk::TreeModel::iterator& row);
+ bool on_script_button_idle(const std::shared_ptr<const LayoutItem_Button>& layout_item, const
Gnome::Gda::Value& primary_key);
#ifndef GLOM_ENABLE_CLIENT_ONLY
Dialog_Layout* create_layout_dialog() const override;
diff --git a/glom/mode_data/box_data_list_related.cc b/glom/mode_data/box_data_list_related.cc
index f273582..5d28d05 100644
--- a/glom/mode_data/box_data_list_related.cc
+++ b/glom/mode_data/box_data_list_related.cc
@@ -216,9 +216,8 @@ void Box_Data_List_Related::on_adddel_user_requested_layout()
#endif // !GLOM_ENABLE_CLIENT_ONLY
-void Box_Data_List_Related::on_adddel_script_button_clicked(const std::weak_ptr<const LayoutItem_Button>&
layout_item_weak, const Gtk::TreeModel::iterator& row)
+void Box_Data_List_Related::on_adddel_script_button_clicked(const std::shared_ptr<const LayoutItem_Button>&
layout_item, const Gtk::TreeModel::iterator& row)
{
- const auto layout_item = layout_item_weak.lock();
if(!layout_item)
return;
@@ -237,12 +236,8 @@ void Box_Data_List_Related::on_adddel_script_button_clicked(const std::weak_ptr<
primary_key_value));
}
-bool Box_Data_List_Related::on_script_button_idle(const std::weak_ptr<const LayoutItem_Button>&
layout_item_weak, const Gnome::Gda::Value& primary_key)
+bool Box_Data_List_Related::on_script_button_idle(const std::shared_ptr<const LayoutItem_Button>&
layout_item, const Gnome::Gda::Value& primary_key)
{
- const auto layout_item = layout_item_weak.lock();
- if(!layout_item)
- return false;
-
execute_button_script(layout_item, primary_key);
// Refill view from database as the script might have changed arbitrary records
diff --git a/glom/mode_data/box_data_list_related.h b/glom/mode_data/box_data_list_related.h
index c5189a1..b46fa7f 100644
--- a/glom/mode_data/box_data_list_related.h
+++ b/glom/mode_data/box_data_list_related.h
@@ -50,8 +50,8 @@ protected:
void on_adddel_record_changed();
void on_adddel_user_requested_edit(const Gtk::TreeModel::iterator& row);
- void on_adddel_script_button_clicked(const std::weak_ptr<const LayoutItem_Button>& layout_item_weak, const
Gtk::TreeModel::iterator& row);
- bool on_script_button_idle(const std::weak_ptr<const LayoutItem_Button>& layout_item_weak, const
Gnome::Gda::Value& primary_key);
+ void on_adddel_script_button_clicked(const std::shared_ptr<const LayoutItem_Button>& layout_item, const
Gtk::TreeModel::iterator& row);
+ bool on_script_button_idle(const std::shared_ptr<const LayoutItem_Button>& layout_item, const
Gnome::Gda::Value& primary_key);
void on_adddel_record_added(const Gtk::TreeModel::iterator& row, const Gnome::Gda::Value&
primary_key_value);
diff --git a/glom/mode_data/flowtablewithfields.cc b/glom/mode_data/flowtablewithfields.cc
index 2f02086..3373985 100644
--- a/glom/mode_data/flowtablewithfields.cc
+++ b/glom/mode_data/flowtablewithfields.cc
@@ -1010,39 +1010,23 @@ FlowTableWithFields::type_signal_script_button_clicked FlowTableWithFields::sign
return m_signal_script_button_clicked;
}
-void FlowTableWithFields::on_script_button_clicked(const std::weak_ptr< LayoutItem_Button>& layout_item_weak)
+void FlowTableWithFields::on_script_button_clicked(const std::shared_ptr< LayoutItem_Button>& layout_item)
{
- const auto layout_item = layout_item_weak.lock();
- if(!layout_item)
- return;
-
m_signal_script_button_clicked.emit(layout_item);
}
-void FlowTableWithFields::on_entry_edited(const Gnome::Gda::Value& value, const std::weak_ptr<const
LayoutItem_Field>& field_weak)
+void FlowTableWithFields::on_entry_edited(const Gnome::Gda::Value& value, const std::shared_ptr<const
LayoutItem_Field>& field)
{
- const auto field = field_weak.lock();
- if(!field)
- return;
-
m_signal_field_edited.emit(field, value);
}
-void FlowTableWithFields::on_entry_choices_changed(const std::weak_ptr<const LayoutItem_Field>& field_weak)
+void FlowTableWithFields::on_entry_choices_changed(const std::shared_ptr<const LayoutItem_Field>& field)
{
- const auto field = field_weak.lock();
- if(!field)
- return;
-
m_signal_field_choices_changed.emit(field);
}
-void FlowTableWithFields::on_entry_open_details_requested(const Gnome::Gda::Value& value, const
std::weak_ptr<const LayoutItem_Field>& field_weak)
+void FlowTableWithFields::on_entry_open_details_requested(const Gnome::Gda::Value& value, const
std::shared_ptr<const LayoutItem_Field>& field)
{
- const auto field = field_weak.lock();
- if(!field)
- return;
-
m_signal_field_open_details_requested.emit(field, value);
}
diff --git a/glom/mode_data/flowtablewithfields.h b/glom/mode_data/flowtablewithfields.h
index e31f05d..952e3b8 100644
--- a/glom/mode_data/flowtablewithfields.h
+++ b/glom/mode_data/flowtablewithfields.h
@@ -140,20 +140,20 @@ public:
void set_enable_drag_and_drop(bool enabled = true);
/** For instance,
- * void on_flowtable_field_edited(const std::weak_ptr<const LayoutItem_Field>& field_weak, const
Gnome::Gda::Value& value);
+ * void on_flowtable_field_edited(const std::shared_ptr<const LayoutItem_Field>& field, const
Gnome::Gda::Value& value);
*/
typedef sigc::signal<void(const std::shared_ptr<const LayoutItem_Field>&, const Gnome::Gda::Value&)>
type_signal_field_edited;
type_signal_field_edited signal_field_edited();
/** For instance,
- * void on_flowtable_field_choices_changed(const std::weak_ptr<const LayoutItem_Field>& field_weak);
+ * void on_flowtable_field_choices_changed(const std::shared_ptr<const LayoutItem_Field>& field);
*/
typedef sigc::signal<void(const std::shared_ptr<const LayoutItem_Field>&)>
type_signal_field_choices_changed;
type_signal_field_choices_changed signal_field_choices_changed();
/** For instance,
- * void on_flowtable_field_open_details_requested(const std::weak_ptr<const LayoutItem_Field>& field_weak,
const Gnome::Gda::Value& value);
+ * void on_flowtable_field_open_details_requested(const std::shared_ptr<const LayoutItem_Field>& field,
const Gnome::Gda::Value& value);
*/
typedef sigc::signal<void(const std::shared_ptr<const LayoutItem_Field>&, const Gnome::Gda::Value&)>
type_signal_field_open_details_requested;
type_signal_field_open_details_requested signal_field_open_details_requested();
@@ -171,7 +171,7 @@ public:
type_signal_requested_related_details signal_requested_related_details();
/** For instance,
- * void on_script_button_clicked(const std::weak_ptr<LayoutItem_Button>& layout_item_weak>);
+ * void on_script_button_clicked(const std::shared_ptr<LayoutItem_Button>& layout_item>);
*/
typedef sigc::signal<void(const std::shared_ptr<LayoutItem_Button>&)> type_signal_script_button_clicked;
type_signal_script_button_clicked signal_script_button_clicked();
@@ -203,11 +203,11 @@ private:
//int get_suitable_width(Field::glom_field_type field_type);
- void on_entry_edited(const Gnome::Gda::Value& value, const std::weak_ptr<const LayoutItem_Field>&
field_weak);
- void on_entry_choices_changed(const std::weak_ptr<const LayoutItem_Field>& field_weak);
- void on_entry_open_details_requested(const Gnome::Gda::Value& value, const std::weak_ptr<const
LayoutItem_Field>& field_weak);
+ void on_entry_edited(const Gnome::Gda::Value& value, const std::shared_ptr<const LayoutItem_Field>& field);
+ void on_entry_choices_changed(const std::shared_ptr<const LayoutItem_Field>& field);
+ void on_entry_open_details_requested(const Gnome::Gda::Value& value, const std::shared_ptr<const
LayoutItem_Field>& field);
- void on_script_button_clicked(const std::weak_ptr<LayoutItem_Button>& layout_item_weak);
+ void on_script_button_clicked(const std::shared_ptr<LayoutItem_Button>& layout_item);
#ifndef GLOM_ENABLE_CLIENT_ONLY
void on_datawidget_layout_item_added(LayoutWidgetBase::enumType item_type, DataWidget* pDataWidget);
diff --git a/glom/mode_find/box_data_details_find.cc b/glom/mode_find/box_data_details_find.cc
index 7a8fbc0..6ab3450 100644
--- a/glom/mode_find/box_data_details_find.cc
+++ b/glom/mode_find/box_data_details_find.cc
@@ -73,7 +73,7 @@ bool Box_Data_Details_Find::fill_from_database()
return result;
}
-void Box_Data_Details_Find::on_flowtable_field_edited(const std::weak_ptr<const LayoutItem_Field>& /* id */,
const Gnome::Gda::Value& /* value */)
+void Box_Data_Details_Find::on_flowtable_field_edited(const std::shared_ptr<const LayoutItem_Field>& /* id
*/, const Gnome::Gda::Value& /* value */)
{
//Don't do anything.
//This just blocks the method in the base class.
diff --git a/glom/mode_find/box_data_details_find.h b/glom/mode_find/box_data_details_find.h
index f26df91..4a8ac73 100644
--- a/glom/mode_find/box_data_details_find.h
+++ b/glom/mode_find/box_data_details_find.h
@@ -39,7 +39,7 @@ private:
bool fill_from_database() override;
- void on_flowtable_field_edited(const std::weak_ptr<const LayoutItem_Field>& id_weak, const
Gnome::Gda::Value& value) override;
+ void on_flowtable_field_edited(const std::shared_ptr<const LayoutItem_Field>& id, const Gnome::Gda::Value&
value) override;
};
} //namespace Glom
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]