summaryrefslogtreecommitdiff
path: root/muse2/muse/helper.cpp
diff options
context:
space:
mode:
authorFlorian Jung <flo@windfisch.org>2011-05-27 13:20:58 +0000
committerFlorian Jung <flo@windfisch.org>2011-05-27 13:20:58 +0000
commit4b344cf08471bcfbce5814ddead384dddb9bb86b (patch)
tree12c3245f05008b21d51b6b29fb090ee8c43ee43f /muse2/muse/helper.cpp
parente8612708161b71b43d56ef47eede6cc58b035967 (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.cpp25
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;
+}