diff options
author | Florian Jung <flo@windfisch.org> | 2011-05-27 13:20:58 +0000 |
---|---|---|
committer | Florian Jung <flo@windfisch.org> | 2011-05-27 13:20:58 +0000 |
commit | 4b344cf08471bcfbce5814ddead384dddb9bb86b (patch) | |
tree | 12c3245f05008b21d51b6b29fb090ee8c43ee43f /muse2/muse/helper.cpp | |
parent | e8612708161b71b43d56ef47eede6cc58b035967 (diff) |
fixed bug: score editor didn't react on part changes which invalidate
the Part*; it simply worked with the old, invalid pointers, which may
lead to severe problems, and indeed leads to a bug when saving.
Diffstat (limited to 'muse2/muse/helper.cpp')
-rw-r--r-- | muse2/muse/helper.cpp | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/muse2/muse/helper.cpp b/muse2/muse/helper.cpp index 605d6f5c..d4a237ea 100644 --- a/muse2/muse/helper.cpp +++ b/muse2/muse/helper.cpp @@ -6,6 +6,9 @@ //========================================================= #include "helper.h" +#include "part.h" +#include "track.h" +#include "song.h" extern bool hIsB; static const char* vall[] = { @@ -38,3 +41,25 @@ QString pitch2string(int v) } + + +int partToIndex(Part* p) +{ + return p->track()->parts()->index(p); +} + +Part* partFromIndex(int index) +{ + TrackList* tl = song->tracks(); + for (iTrack it = tl->begin(); it != tl->end(); ++it) + { + PartList* pl = (*it)->parts(); + iPart ip; + for (ip = pl->begin(); ip != pl->end(); ++ip) + if (ip->second->sn() == index) + return ip->second; + } + + printf("ERROR: partFromIndex(%i) wasn't able to find an appropriate part!\n",index); + return NULL; +} |