fix nasty logic error that leads to crashing bugs when trying to operate on regions that have been subject to undo/redo
git-svn-id: svn://localhost/ardour2/trunk@1670 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
parent
d4a73c373a
commit
8ed825c3dd
@ -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 ?
|
||||
|
@ -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));
|
||||
|
@ -20,6 +20,7 @@
|
||||
#include <algorithm>
|
||||
#include <sigc++/bind.h>
|
||||
#include <pbd/error.h>
|
||||
#include <pbd/stacktrace.h>
|
||||
|
||||
#include <ardour/playlist.h>
|
||||
|
||||
|
@ -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;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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__ */
|
||||
|
@ -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;
|
||||
|
@ -29,11 +29,13 @@
|
||||
#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] != '/') {
|
||||
|
@ -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,7 +512,7 @@ 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));
|
||||
}
|
||||
@ -1418,7 +1422,7 @@ Playlist::set_state (const XMLNode& node)
|
||||
}
|
||||
|
||||
in_set_state--;
|
||||
|
||||
first_set_state = false;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include <ardour/timestamps.h>
|
||||
|
||||
#include <pbd/error.h>
|
||||
#include <pbd/enumwriter.h>
|
||||
#include <pbd/stacktrace.h>
|
||||
|
||||
#include <ardour/ardour.h>
|
||||
|
@ -34,6 +34,7 @@ pathscanner.cc
|
||||
pool.cc
|
||||
pthread_utils.cc
|
||||
receiver.cc
|
||||
shortpath.cc
|
||||
stacktrace.cc
|
||||
stateful.cc
|
||||
strreplace.cc
|
||||
|
Loading…
Reference in New Issue
Block a user