[glom] Dnd layout: Avoid a crash when dragging to empty space.
- From: Murray Cumming <murrayc src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [glom] Dnd layout: Avoid a crash when dragging to empty space.
- Date: Wed, 30 Dec 2009 20:57:04 +0000 (UTC)
commit 3a6c4cb509765c4eed5766d914ffc6e754c90c0a
Author: Murray Cumming <murrayc murrayc com>
Date: Wed Dec 30 21:56:53 2009 +0100
Dnd layout: Avoid a crash when dragging to empty space.
* glom/utility_widgets/flowtable_dnd.cc: on_drag_data_received():
Avoid dereferencing a null group. Bug #599232
ChangeLog | 7 +++++++
glom/mode_data/flowtablewithfields.cc | 3 ++-
glom/utility_widgets/flowtable_dnd.cc | 14 ++++++++------
3 files changed, 17 insertions(+), 7 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 20e82e3..ff64d44 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
2009-12-30 Murray Cumming <murrayc murrayc com>
+ Dnd layout: Avoid a crash when dragging to empty space.
+
+ * glom/utility_widgets/flowtable_dnd.cc: on_drag_data_received():
+ Avoid dereferencing a null group.
+
+2009-12-30 Murray Cumming <murrayc murrayc com>
+
Dnd layout: Avoid a crash.
* glom/utility_widgets/flowtable_dnd.cc: on_drag_data_received():
diff --git a/glom/mode_data/flowtablewithfields.cc b/glom/mode_data/flowtablewithfields.cc
index 58d1590..a6f43ff 100644
--- a/glom/mode_data/flowtablewithfields.cc
+++ b/glom/mode_data/flowtablewithfields.cc
@@ -1416,7 +1416,8 @@ void FlowTableWithFields::on_dnd_remove_placeholder()
void FlowTableWithFields::dnd_notify_failed_drop()
{
- // TODO: Avoid this error message
+ // TODO: Avoid this error message, maybe by adding a group.
+ // TODO: At least avoid losing the dragged item.
Gtk::MessageDialog dialog(_("You cannot drop anything here. Try to add a group first"),
false, Gtk::MESSAGE_ERROR);
dialog.run();
diff --git a/glom/utility_widgets/flowtable_dnd.cc b/glom/utility_widgets/flowtable_dnd.cc
index 42fd285..e0dd5bc 100644
--- a/glom/utility_widgets/flowtable_dnd.cc
+++ b/glom/utility_widgets/flowtable_dnd.cc
@@ -208,15 +208,17 @@ void FlowTableDnd::on_drag_data_received(const Glib::RefPtr<Gdk::DragContext>& d
sharedptr<LayoutItem> item = base->get_layout_item();
if(item)
{
+ m_internal_drag = false;
sharedptr<LayoutGroup> group = sharedptr<LayoutGroup>::cast_dynamic(get_layout_item());
- LayoutGroup::type_list_items items = group->m_list_items;
- if(std::find(items.begin(), items.end(), item) != items.end())
+ if(group)
{
- m_internal_drag = true;
- group->remove_item(item);
+ LayoutGroup::type_list_items items = group->m_list_items;
+ if(std::find(items.begin(), items.end(), item) != items.end())
+ {
+ m_internal_drag = true;
+ group->remove_item(item);
+ }
}
- else
- m_internal_drag = false;
LayoutWidgetBase* above_casted = dynamic_cast<LayoutWidgetBase*>(above);
on_dnd_add_layout_item(above_casted, item);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]