X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Flibr2c2%2Ftrack.cpp;h=7a1746716574abdbedb40c0356042ae7932dba66;hb=05b95b6b6b095821f1e79dabed802b853c296c9d;hp=8ecb9b9bac00833eaa70190982fcb1933b43e9ae;hpb=64d23de66c33d0f77454c3db2e40cccc18f7851b;p=r2c2.git diff --git a/source/libr2c2/track.cpp b/source/libr2c2/track.cpp index 8ecb9b9..7a17467 100644 --- a/source/libr2c2/track.cpp +++ b/source/libr2c2/track.cpp @@ -183,6 +183,13 @@ void Track::set_active_path(unsigned p) layout.get_driver().set_turnout(turnout_id, p); } +float Track::get_path_length(int p) const +{ + if(p<0) + p = active_path; + return type.get_path_length(p); +} + OrientedPoint Track::get_point(unsigned epi, unsigned path, float d) const { OrientedPoint p = type.get_point(epi, path, d); @@ -337,9 +344,14 @@ bool Track::break_link(unsigned i) return false; links[i] = 0; - other->break_link(*this); - // XXX Creates the blocks twice, because the other track calls this too - layout.create_blocks(*this); + if(!other->break_link(*this)) + { + /* If the call doesn't succeed, it means that the other track already + broke the link and is calling us right now. Recreate blocks in the inner + call so it occurs before any signals are emitted. */ + layout.create_blocks(*this); + } + signal_link_changed.emit(i, 0); return true;