diff --git a/src/gui/gtk-lumiera.hpp b/src/gui/gtk-lumiera.hpp index a25927712..e86e44fbd 100644 --- a/src/gui/gtk-lumiera.hpp +++ b/src/gui/gtk-lumiera.hpp @@ -32,6 +32,7 @@ #include #include #include +#include extern "C" { #include diff --git a/src/gui/model/project.cpp b/src/gui/model/project.cpp index 25ab3f964..843351cc3 100644 --- a/src/gui/model/project.cpp +++ b/src/gui/model/project.cpp @@ -25,6 +25,9 @@ #include "project.hpp" #include "sequence.hpp" +using namespace std; +using namespace boost; + namespace gui { namespace model { @@ -37,11 +40,10 @@ Project::Project() Project::~Project() { - BOOST_FOREACH( Sequence* const sequence, sequences ) - delete sequence; + } -const std::list& +const std::list< shared_ptr >& Project::get_sequences() { return sequences; @@ -50,7 +52,7 @@ Project::get_sequences() void Project::add_new_sequence(Glib::ustring name) { - Sequence* const sequence = new Sequence(); + shared_ptr sequence(new Sequence()); sequence->set_name(name); sequences.push_back(sequence); sequenceListChangedSignal.emit(); diff --git a/src/gui/model/project.hpp b/src/gui/model/project.hpp index 1bd7a7f4a..cb7945204 100644 --- a/src/gui/model/project.hpp +++ b/src/gui/model/project.hpp @@ -39,7 +39,7 @@ public: ~Project(); - const std::list& get_sequences(); + const std::list< boost::shared_ptr >& get_sequences(); void add_new_sequence(Glib::ustring name); @@ -48,7 +48,7 @@ public: private: - std::list sequences; + std::list< boost::shared_ptr > sequences; sigc::signal sequenceListChangedSignal; }; diff --git a/src/gui/panels/timeline-panel.cpp b/src/gui/panels/timeline-panel.cpp index a64b97e34..94c07cc02 100644 --- a/src/gui/panels/timeline-panel.cpp +++ b/src/gui/panels/timeline-panel.cpp @@ -34,6 +34,7 @@ extern "C" { using namespace Gtk; using namespace sigc; using namespace std; +using namespace boost; using namespace gui::widgets; using namespace gui::model; @@ -114,7 +115,7 @@ TimelinePanel::TimelinePanel(model::Project *const owner_project) : TimelinePanel::~TimelinePanel() { // Free allocated widgets - pair pair; + pair pair; BOOST_FOREACH( pair, notebook_pages ) delete pair.second; } @@ -220,13 +221,15 @@ TimelinePanel::on_sequence_list_changed() void TimelinePanel::update_notebook() { - std::map old_pages(notebook_pages); + std::map + old_pages(notebook_pages); notebook_pages.clear(); - - BOOST_FOREACH( Sequence* const sequence, project->get_sequences() ) + + BOOST_FOREACH( boost::shared_ptr< model::Sequence > sequence, + project->get_sequences() ) { - std::map::iterator iterator = - old_pages.find(sequence); + std::map::iterator + iterator = old_pages.find(sequence.get()); if(iterator != old_pages.end()) { // This sequence has not been changed @@ -238,14 +241,14 @@ TimelinePanel::update_notebook() { // This is a new sequence, add it in TimelineWidget * const widget = new TimelineWidget(sequence); - notebook_pages[sequence] = widget; + notebook_pages[sequence.get()] = widget; notebook.append_page(*widget, sequence->get_name()); notebook.set_tab_reorderable(*widget); } } // Free widgets which have been removed - pair pair; + pair pair; BOOST_FOREACH( pair, old_pages ) delete pair.second; diff --git a/src/gui/panels/timeline-panel.hpp b/src/gui/panels/timeline-panel.hpp index d801ce08b..1966e711e 100644 --- a/src/gui/panels/timeline-panel.hpp +++ b/src/gui/panels/timeline-panel.hpp @@ -106,7 +106,8 @@ private: // Body Widgets Gtk::Notebook notebook; - std::map notebook_pages; + std::map< const model::Sequence*, TimelineWidget*> + notebook_pages; // Toolbar Widgets diff --git a/src/gui/widgets/timeline-widget.cpp b/src/gui/widgets/timeline-widget.cpp index 07fd3d6f9..f712b915d 100644 --- a/src/gui/widgets/timeline-widget.cpp +++ b/src/gui/widgets/timeline-widget.cpp @@ -37,7 +37,8 @@ const int TimelineWidget::HeaderWidth = 150; const double TimelineWidget::ZoomIncrement = 1.25; const int64_t TimelineWidget::MaxScale = 30000000; -TimelineWidget::TimelineWidget(model::Sequence* const source_sequence) : +TimelineWidget::TimelineWidget( + boost::shared_ptr source_sequence) : Table(2, 2), sequence(source_sequence), viewWindow(this, 0, 1), @@ -53,7 +54,7 @@ TimelineWidget::TimelineWidget(model::Sequence* const source_sequence) : horizontalScroll(horizontalAdjustment), verticalScroll(verticalAdjustment) { - REQUIRE(sequence != NULL); + REQUIRE(sequence); body = new TimelineBody(this); ENSURE(body != NULL); @@ -276,7 +277,7 @@ TimelineWidget::on_view_window_changed() void TimelineWidget::update_tracks() { - REQUIRE(sequence != NULL); + REQUIRE(sequence); // Create timeline tracks from all the model tracks create_timeline_tracks(); @@ -297,7 +298,7 @@ TimelineWidget::update_tracks() void TimelineWidget::create_timeline_tracks() { - REQUIRE(sequence != NULL); + REQUIRE(sequence); BOOST_FOREACH(model::Track* child, sequence->get_tracks()) create_timeline_tracks_from_branch(child); @@ -345,7 +346,7 @@ TimelineWidget::create_timeline_track_from_model_track( timeline::Track* TimelineWidget::lookup_timeline_track(model::Track *model_track) { - ASSERT(sequence != NULL); + REQUIRE(sequence); std::map::const_iterator iterator = trackMap.find(model_track); if(iterator == trackMap.end()) diff --git a/src/gui/widgets/timeline-widget.hpp b/src/gui/widgets/timeline-widget.hpp index eb70aa45e..6e1c31c84 100644 --- a/src/gui/widgets/timeline-widget.hpp +++ b/src/gui/widgets/timeline-widget.hpp @@ -57,7 +57,7 @@ public: /** * Constructor */ - TimelineWidget(model::Sequence *source_sequence); + TimelineWidget(boost::shared_ptr source_sequence); /** * Destructor @@ -211,7 +211,7 @@ private: protected: // Model Data - model::Sequence* const sequence; + const boost::shared_ptr sequence; std::map trackMap; // View State diff --git a/src/gui/widgets/timeline/timeline-body.cpp b/src/gui/widgets/timeline/timeline-body.cpp index 6456acce4..1601ba601 100644 --- a/src/gui/widgets/timeline/timeline-body.cpp +++ b/src/gui/widgets/timeline/timeline-body.cpp @@ -268,7 +268,7 @@ TimelineBody::draw_tracks(Cairo::RefPtr cr) { REQUIRE(cr); REQUIRE(timelineWidget != NULL); - REQUIRE(timelineWidget->sequence != NULL); + REQUIRE(timelineWidget->sequence); // Prepare const Allocation allocation = get_allocation(); @@ -424,7 +424,7 @@ timeline::Track* TimelineBody::track_from_point(const int y) const { REQUIRE(timelineWidget != NULL); - REQUIRE(timelineWidget->sequence != NULL); + REQUIRE(timelineWidget->sequence); int offset = -get_vertical_offset(); diff --git a/src/gui/widgets/timeline/timeline-header-container.cpp b/src/gui/widgets/timeline/timeline-header-container.cpp index 805807807..5bace4b4a 100644 --- a/src/gui/widgets/timeline/timeline-header-container.cpp +++ b/src/gui/widgets/timeline/timeline-header-container.cpp @@ -492,7 +492,7 @@ const std::list& TimelineHeaderContainer::get_tracks() const { REQUIRE(timelineWidget != NULL); - REQUIRE(timelineWidget->sequence != NULL); + REQUIRE(timelineWidget->sequence); return timelineWidget->sequence->get_tracks(); }