fixes for drag-n-drop broken by use of boost::shared_ptr<T>
[ardour.git] / gtk2_ardour / editor_canvas.cc
index 946df13334291e71054be72d3c97865074f3c85c..26995c39ef36f98fa5e597bb62408dc688b1b091 100644 (file)
@@ -266,8 +266,10 @@ Editor::initialize_canvas ()
        
        edit_cursor = new Cursor (*this, "blue", &Editor::canvas_edit_cursor_event);
        playhead_cursor = new Cursor (*this, "red", &Editor::canvas_playhead_cursor_event);
-       
+
+       initial_ruler_update_required = true;
        track_canvas.signal_size_allocate().connect (mem_fun(*this, &Editor::track_canvas_allocate));
+
 }
 
 void
@@ -317,10 +319,15 @@ Editor::track_canvas_allocate (Gtk::Allocation alloc)
                transport_punchout_line->property_y2() = canvas_height;
        }
                
-       update_fixed_rulers ();
-
-       if (is_visible()) {
+               if (is_visible() && initial_ruler_update_required) {
+         /*
+           this is really dumb, but signal_size_allocate() gets emitted intermittently 
+            depending on whether the canvas contents are visible or not. 
+            we only want to do this once 
+         */
+               update_fixed_rulers();
                tempo_map_changed (Change (0));
+               initial_ruler_update_required = false;
        } 
        
        Resized (); /* EMIT_SIGNAL */
@@ -410,6 +417,8 @@ Editor::track_canvas_drag_data_received (const RefPtr<Gdk::DragContext>& context
                                         const SelectionData& data,
                                         guint info, guint time)
 {
+       cerr << "dropping, target = " << data.get_target() << endl;
+
        if (data.get_target() == "regions") {
                drop_regions (context, x, y, data, info, time);
        } else {
@@ -479,11 +488,12 @@ Editor::drop_regions (const RefPtr<Gdk::DragContext>& context,
                      const SelectionData& data,
                      guint info, guint time)
 {
-       const DnDTreeView::SerializedObjectPointers* sr = reinterpret_cast<const DnDTreeView::SerializedObjectPointers*> (data.get_data());
+       const SerializedObjectPointers<boost::shared_ptr<Region> >* sr = 
+               reinterpret_cast<const SerializedObjectPointers<boost::shared_ptr<Region> > *> (data.get_data());
 
        for (uint32_t i = 0; i < sr->cnt; ++i) {
 
-               boost::shared_ptr<Region> r (reinterpret_cast<Region*> (sr->ptr[i]));
+               boost::shared_ptr<Region> r = sr->data[i];
                boost::shared_ptr<AudioRegion> ar;
 
                if ((ar = boost::dynamic_pointer_cast<AudioRegion>(r)) != 0) {