fix nasty logic error that leads to crashing bugs when trying to operate on regions...
authorPaul Davis <paul@linuxaudiosystems.com>
Fri, 6 Apr 2007 02:27:24 +0000 (02:27 +0000)
committerPaul Davis <paul@linuxaudiosystems.com>
Fri, 6 Apr 2007 02:27:24 +0000 (02:27 +0000)
git-svn-id: svn://localhost/ardour2/trunk@1670 d708f5d6-7413-0410-9779-e7cbd77b26cf

gtk2_ardour/editor_audio_import.cc
gtk2_ardour/editor_mouse.cc
gtk2_ardour/selection.cc
gtk2_ardour/utils.cc
gtk2_ardour/utils.h
libs/ardour/ardour/playlist.h
libs/ardour/audiofilesource.cc
libs/ardour/playlist.cc
libs/ardour/session_time.cc
libs/pbd/SConscript

index cf57261aa62fa7de0f5d16daca2b577a70d2cf0a..df737429bdbe9206473fb3736f24060889c7ffd7 100644 (file)
@@ -19,6 +19,7 @@
 
 #include <pbd/pthread_utils.h>
 #include <pbd/basename.h>
+#include <pbd/shortpath.h>
 
 #include <gtkmm2ext/choice.h>
 #include <gtkmm2ext/window_title.h>
@@ -380,7 +381,6 @@ Editor::embed_sndfile (vector<Glib::ustring> paths, bool split, bool multiple_fi
                                boost::shared_ptr<Source> s;
 
                                if ((s = session->source_by_path_and_channel (path, n)) == 0) {
-                                       cerr << "source doesn't exist yet\n";
                                        source = boost::dynamic_pointer_cast<AudioFileSource> (SourceFactory::createReadable 
                                                                                               (*session, path,  n,
                                                                                                (mode == ImportAsTapeTrack ? 
index e9b71e4e859e604b2925028e46b3d7d59f5c4b03..356504d809b17167a47a13227b750508c0899916 100644 (file)
@@ -3381,6 +3381,8 @@ Editor::region_drag_finished_callback (ArdourCanvas::Item* item, GdkEvent* event
 
                        boost::shared_ptr<Playlist> to_playlist = rv->region()->playlist();
 
+                       assert (to_playlist);
+
                        /* add the undo */
 
                        session->add_command (new MementoCommand<Playlist>(*to_playlist, &to_playlist->get_state(), 0));        
index 2b1b522d12fce2819f2aea42b69d9cdaf6bc0b51..1e8874444c2d5fa01ce8a3b3c9d22f21df73a0db 100644 (file)
@@ -20,6 +20,7 @@
 #include <algorithm>
 #include <sigc++/bind.h>
 #include <pbd/error.h>
+#include <pbd/stacktrace.h>
 
 #include <ardour/playlist.h>
 
index 9c1ef22a88c579ebcd38e08a3f24d270eeb0d538..b4d02591e9d7ff4111962120e5a633317556b0f5 100644 (file)
@@ -576,55 +576,4 @@ key_is_legal_for_numeric_entry (guint keyval)
 }
 
 
-ustring
-short_path (ustring path, uint32_t target_characters)
-{
-       ustring::size_type last_sep;
-       ustring::size_type len = path.length();
-       const char separator = '/';
-
-       if (len <= target_characters) {
-               return path;
-       }
-
-       if ((last_sep = path.find_last_of (separator)) == ustring::npos) {
-
-               /* just a filename, but its too long anyway */
-
-               if (target_characters > 3) {
-                       return path.substr (0, target_characters - 3) + ustring ("...");
-               } else {
-                       /* stupid caller, just hand back the whole thing */
-                       return path;
-               }
-       }
-
-       if (len - last_sep >= target_characters) {
-
-               /* even the filename itself is too long */
-
-               if (target_characters > 3) {
-                       return path.substr (last_sep+1, target_characters - 3) + ustring ("...");
-               } else {
-                       /* stupid caller, just hand back the whole thing */
-                       return path;
-               }
-       }
-       
-       uint32_t so_far = (len - last_sep);
-       uint32_t space_for = target_characters - so_far;
-
-       if (space_for >= 3) {
-               ustring res = "...";
-               res += path.substr (last_sep - space_for);
-               return res;
-       } else {
-               /* remove part of the end */
-               ustring res = "...";
-               res += path.substr (last_sep - space_for, len - last_sep + space_for - 3);
-               res += "...";
-               return res;
-               
-       }
-}
 
index b95f09d24336c5021371e73e5d1d1e6c0e94d781..7e26ba066c12c6ecb29500d2094c6669482022d9 100644 (file)
@@ -81,6 +81,5 @@ static std::map<std::string, Glib::RefPtr<Gdk::Pixbuf> > xpm_map;
 const char* const *get_xpm_data (std::string path);
 std::string longest (std::vector<std::string>&);
 bool key_is_legal_for_numeric_entry (guint keyval);
-Glib::ustring short_path (Glib::ustring, uint32_t target_characters);
 
 #endif /* __ardour_gtk_utils_h__ */
index 103e95929e2a7d347aece186d3440dd2f4884a63..5f33719ae7ee406afdfb3a2f6c51423f832c089e 100644 (file)
@@ -182,6 +182,7 @@ class Playlist : public PBD::StatefulDestructible, public boost::enable_shared_f
        bool             save_on_thaw;
        string           last_save_reason;
        uint32_t         in_set_state;
+       bool             first_set_state;
        bool            _hidden;
        bool            _splicing;
        bool            _nudging;
index 9a3bf266ae6930d1003ad796df20041934602bb0..929cfc808370f666b102b680144a2abc58720125 100644 (file)
 #include <pbd/pathscanner.h>
 #include <pbd/stl_delete.h>
 #include <pbd/strsplit.h>
+#include <pbd/shortpath.h>
 #include <pbd/enumwriter.h>
 
 #include <sndfile.h>
 
 #include <glibmm/miscutils.h>
+#include <glibmm/fileutils.h>
 
 #include <ardour/audiofilesource.h>
 #include <ardour/sndfile_helpers.h>
@@ -366,10 +368,33 @@ AudioFileSource::find (ustring& pathstr, bool must_exist, bool& isnew)
 
        isnew = false;
 
-       /* clean up PATH:CHANNEL notation so that we are looking for the correct path */
+       /* i (paul) made a nasty design error by using ':' as a special character in
+          Ardour 0.99 .. this hack tries to make things sort of work.
+       */
 
        if ((pos = pathstr.find_last_of (':')) != ustring::npos) {
-               pathstr = pathstr.substr (0, pos);
+               if (Glib::file_test (pathstr, Glib::FILE_TEST_EXISTS)) {
+                       /* its a real file, no problem */
+                       
+               } else {
+
+                       if (must_exist) {
+
+                               /* older session using file:channel syntax */
+                               
+                               warning << string_compose (_("This older session references an embedded\n\
+non-mono audio file:\n\n%1\n\n                                         \
+The session file may be edited or the file must be removed before it can be used."), 
+                                                          short_path (pathstr, 48))
+                                       << endmsg;
+                               return false;
+
+                       } else {
+                               
+                               /* new derived file (e.g. for timefx) being created in a newer session */
+
+                       }
+               }
        }
 
        if (pathstr[0] != '/') {
index ae9e23fcc94adc2ab7a9ba5195a6e7ce2d916b74..807bcd23ca66781d8e4a0e6974643136ef9c1a00 100644 (file)
@@ -74,6 +74,7 @@ Playlist::Playlist (Session& sess, string nom, bool hide)
        : _session (sess)
 {
        init (hide);
+       first_set_state = false;
        _name = nom;
        
 }
@@ -108,6 +109,7 @@ Playlist::Playlist (boost::shared_ptr<const Playlist> other, string namestr, boo
        _edit_mode = other->_edit_mode;
 
        in_set_state = 0;
+       first_set_state = false;
        in_flush = false;
        in_partition = false;
        subcnt = 0;
@@ -180,6 +182,7 @@ Playlist::Playlist (boost::shared_ptr<const Playlist> other, nframes_t start, nf
        }
        
        in_set_state--;
+       first_set_state = false;
 
        /* this constructor does NOT notify others (session) */
 }
@@ -220,6 +223,7 @@ Playlist::init (bool hide)
        g_atomic_int_set (&ignore_state_changes, 0);
        pending_modified = false;
        pending_length = false;
+       first_set_state = true;
        _refcnt = 0;
        _hidden = hide;
        _splicing = false;
@@ -508,10 +512,10 @@ Playlist::add_region_internal (boost::shared_ptr<Region> region, nframes_t posit
                 old_length = _get_maximum_extent();
        }
 
-       if (!in_set_state) {
+       if (!first_set_state) {
                boost::shared_ptr<Playlist> foo (shared_from_this());
                region->set_playlist (boost::weak_ptr<Playlist>(foo));
-       }
+       } 
 
        region->set_position (position, this);
 
@@ -1418,7 +1422,7 @@ Playlist::set_state (const XMLNode& node)
        }
 
        in_set_state--;
-
+       first_set_state = false;
        return 0;
 }
 
index 2a921c3dc96cd8393d74deb451d0071ee84d40a8..9ae3492ea7cb2227f1443f64187fb9af1db36c46 100644 (file)
@@ -25,6 +25,7 @@
 #include <ardour/timestamps.h>
 
 #include <pbd/error.h>
+#include <pbd/enumwriter.h>
 #include <pbd/stacktrace.h>
 
 #include <ardour/ardour.h>
index 12664a1fca2232a316ab67b1e6ab136db9f77b59..3aaeb1bf1b172e9a4389123f2ce0f97cb2e92fcb 100644 (file)
@@ -34,6 +34,7 @@ pathscanner.cc
 pool.cc
 pthread_utils.cc
 receiver.cc
+shortpath.cc
 stacktrace.cc
 stateful.cc
 strreplace.cc