[glom] Dnd layout: Avoid a crash.
- From: Murray Cumming <murrayc src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [glom] Dnd layout: Avoid a crash.
- Date: Wed, 30 Dec 2009 16:07:12 +0000 (UTC)
commit e16defe6a724ffe7e582b144368ffb05755a62ed
Author: Murray Cumming <murrayc murrayc com>
Date: Wed Dec 30 17:07:08 2009 +0100
Dnd layout: Avoid a crash.
* glom/utility_widgets/flowtable_dnd.cc: on_drag_data_received():
Use a dynamic_cast<> to avoid memory corruption with the MI class.
ChangeLog | 7 +++++++
glom/utility_widgets/flowtable_dnd.cc | 18 +++++++++++-------
2 files changed, 18 insertions(+), 7 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 885e070..20e82e3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2009-12-30 Murray Cumming <murrayc murrayc com>
+
+ Dnd layout: Avoid a crash.
+
+ * glom/utility_widgets/flowtable_dnd.cc: on_drag_data_received():
+ Use a dynamic_cast<> to avoid memory corruption with the MI class.
+
2009-12-16 Armin Burgmeier <armin arbur net>
* win32/build-installer:
diff --git a/glom/utility_widgets/flowtable_dnd.cc b/glom/utility_widgets/flowtable_dnd.cc
index 354622f..42fd285 100644
--- a/glom/utility_widgets/flowtable_dnd.cc
+++ b/glom/utility_widgets/flowtable_dnd.cc
@@ -195,11 +195,14 @@ void FlowTableDnd::on_drag_data_received(const Glib::RefPtr<Gdk::DragContext>& d
}
else
{
- //TODO: When is this code path taken?
- std::cout << "DEBUG: FlowTableDnd::on_drag_data_received(): Unexpected code path." << std::endl;
- /*
- gpointer* data = (gpointer*)selection_data.get_data();
- LayoutWidgetBase* base = (LayoutWidgetBase*)*data;
+ gpointer* pdata = (gpointer*)selection_data.get_data();
+ if(!pdata)
+ return;
+
+ Gtk::Widget* widget = static_cast<Gtk::Widget*>(*pdata); //The type that was set in on_child_drag_data_get().
+
+ //A dynamic cast (from Gtk::Widget) is necessary because of the virtual inheritance:
+ LayoutWidgetBase* base = dynamic_cast<LayoutWidgetBase*>(widget);
if(base)
{
sharedptr<LayoutItem> item = base->get_layout_item();
@@ -215,11 +218,12 @@ void FlowTableDnd::on_drag_data_received(const Glib::RefPtr<Gdk::DragContext>& d
else
m_internal_drag = false;
- on_dnd_add_layout_item(above, item);
+ LayoutWidgetBase* above_casted = dynamic_cast<LayoutWidgetBase*>(above);
+ on_dnd_add_layout_item(above_casted, item);
base->set_dnd_in_progress(false);
}
}
- */
+
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]