summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Jung <flo@windfisch.org>2011-12-25 17:11:35 +0000
committerFlorian Jung <flo@windfisch.org>2011-12-25 17:11:35 +0000
commitf7bd12297b81b95371713af725c47f8c56a77550 (patch)
tree948d0d40dcd6b4cdd5cf8c7942c10652b8f075e8
parentc233aa121b59559bd29b675d2047efaf741e8879 (diff)
fixed segfault when dealing with empty drumlists
-rw-r--r--muse2/muse/midiedit/dlist.cpp26
-rw-r--r--muse2/muse/midiedit/scoreedit.cpp6
2 files changed, 22 insertions, 10 deletions
diff --git a/muse2/muse/midiedit/dlist.cpp b/muse2/muse/midiedit/dlist.cpp
index 2cbaceda..2eb5e64a 100644
--- a/muse2/muse/midiedit/dlist.cpp
+++ b/muse2/muse/midiedit/dlist.cpp
@@ -299,6 +299,7 @@ void DList::viewMousePressEvent(QMouseEvent* ev)
int instrument = y / TH;
if (instrument >= ourDrumMapSize) instrument=ourDrumMapSize-1;
if (instrument < 0) instrument=0;
+ if (ourDrumMapSize==0) return;
setCurDrumInstrument(instrument);
@@ -593,6 +594,7 @@ void DList::lineEdit(int line, int section)
{
if (line >= ourDrumMapSize) line=ourDrumMapSize-1;
if (line < 0) line=0;
+ if (ourDrumMapSize==0) return;
MusECore::DrumMap* dm = &ourDrumMap[line];
editEntry = dm;
@@ -664,6 +666,7 @@ void DList::pitchEdit(int line, int section)
{
if (line >= ourDrumMapSize) line=ourDrumMapSize-1;
if (line < 0) line=0;
+ if (ourDrumMapSize==0) return;
MusECore::DrumMap* dm = &ourDrumMap[line];
editEntry = dm;
@@ -978,8 +981,16 @@ DList::DList(QHeaderView* h, QWidget* parent, int ymag, DrumCanvas* dcanvas_, bo
editor = 0;
pitch_editor = 0;
editEntry = 0;
- // always select a drum instrument
- currentlySelected = &ourDrumMap[0];
+ if (ourDrumMapSize!=0)
+ {
+ // always select a drum instrument
+ currentlySelected = &ourDrumMap[0];
+ }
+ else
+ {
+ currentlySelected = NULL;
+ }
+
selectedColumn = -1;
}
@@ -1000,7 +1011,7 @@ void DList::viewMouseMoveEvent(QMouseEvent* ev)
curY = ev->y();
int delta = curY - startY;
switch (drag) {
- case START_DRAG:
+ case START_DRAG: // this cannot happen if ourDrumMapSize==0
if (delta < 0)
delta = -delta;
if (delta <= 2)
@@ -1077,7 +1088,7 @@ void DList::viewMouseReleaseEvent(QMouseEvent* ev)
int DList::getSelectedInstrument()
{
- if (currentlySelected == 0)
+ if (currentlySelected == NULL)
return -1;
return MusEGlobal::drumInmap[int(currentlySelected->enote)];
}
@@ -1085,7 +1096,7 @@ int DList::getSelectedInstrument()
void DList::ourDrumMapChanged(bool instrMapChanged)
{
- int selIdx = currentlySelected - ourDrumMap;
+ int selIdx = currentlySelected ? (currentlySelected - ourDrumMap) : -1;
int editIdx = editEntry ? (editEntry - ourDrumMap) : -1;
ourDrumMap=dcanvas->getOurDrumMap();
@@ -1116,7 +1127,10 @@ void DList::ourDrumMapChanged(bool instrMapChanged)
if (selIdx >= ourDrumMapSize) selIdx=ourDrumMapSize-1;
if (selIdx < 0) selIdx=0;
- currentlySelected = &ourDrumMap[selIdx];
+ currentlySelected = (ourDrumMapSize!=0) ? &ourDrumMap[selIdx] : NULL;
+
+ if (ourDrumMapSize==0)
+ drag = NORMAL;
redraw();
}
diff --git a/muse2/muse/midiedit/scoreedit.cpp b/muse2/muse/midiedit/scoreedit.cpp
index 2d544c90..716ac65d 100644
--- a/muse2/muse/midiedit/scoreedit.cpp
+++ b/muse2/muse/midiedit/scoreedit.cpp
@@ -4679,15 +4679,13 @@ void ScoreCanvas::add_new_parts(const std::map< MusECore::Part*, std::set<MusECo
* from clipboard failed. ignoring this one... ) [ not reproducible ]
*
* CURRENT TODO
- * o having the same drum track in two editors open, using "hide all"
- * on the first (while the second is in "only shown"-mode), this
- * has no effect in the second.
* o drum controllers
* update ctrlcanvas/panel
* test!
- * o drum editor is buggy. propagate_drum_map may operate on old values
+ * * drum editor is buggy. propagate_drum_map may operate on old values
* ("BUGGY! problem is: while changing entries, ourDrumMap
may be reallocated which causes abort()s and/or bugs.")
+ [ seems to work, needs further testing! ]
* o don't mix DRUM and NEW_DRUM in drumeditor!
* o quantize must round UP, not down when at 0.5
* o my record flag handling