summaryrefslogtreecommitdiff
path: root/muse2
diff options
context:
space:
mode:
authorTim E. Real <termtech@rogers.com>2010-11-14 22:16:33 +0000
committerTim E. Real <termtech@rogers.com>2010-11-14 22:16:33 +0000
commit8c3d365acbc4ea40beb2cf980591fe146c996ce3 (patch)
tree84538f8e74555c0483e8558819024e50df60e247 /muse2
parent1502072a96113f674d87d56e0b264e2963d65ff5 (diff)
Fix crash in TList::mousePressEvent
Diffstat (limited to 'muse2')
-rw-r--r--muse2/muse/arranger/tlist.cpp83
1 files changed, 44 insertions, 39 deletions
diff --git a/muse2/muse/arranger/tlist.cpp b/muse2/muse/arranger/tlist.cpp
index d2da81b1..8d8d430c 100644
--- a/muse2/muse/arranger/tlist.cpp
+++ b/muse2/muse/arranger/tlist.cpp
@@ -828,54 +828,59 @@ void TList::mousePressEvent(QMouseEvent* ev)
p->addMenu(synp);
// Show the menu
- int n = p->exec(ev->globalPos(), 0)->data().toInt();
+ QAction* act = p->exec(ev->globalPos(), 0);
// Valid click?
- if((n >= 0) && ((Track::TrackType)n != Track::AUDIO_SOFTSYNTH))
+ if(act)
{
- // Synth sub-menu id?
- if(n >= MENU_ADD_SYNTH_ID_BASE)
+ int n = act->data().toInt();
+ // Valid item?
+ if((n >= 0) && ((Track::TrackType)n != Track::AUDIO_SOFTSYNTH))
{
- n -= MENU_ADD_SYNTH_ID_BASE;
- //if(n < synthis.size())
- // t = song->createSynthI(synthis[n]->baseName());
- //if((n - MENU_ADD_SYNTH_ID_BASE) < (int)synthis.size())
- if(n < (int)synthis.size())
+ // Synth sub-menu id?
+ if(n >= MENU_ADD_SYNTH_ID_BASE)
{
- //t = song->createSynthI(synp->text(n));
- //t = song->createSynthI(synthis[n]->name());
- t = song->createSynthI(synthis[n]->baseName(), synthis[n]->name());
-
- if(t)
+ n -= MENU_ADD_SYNTH_ID_BASE;
+ //if(n < synthis.size())
+ // t = song->createSynthI(synthis[n]->baseName());
+ //if((n - MENU_ADD_SYNTH_ID_BASE) < (int)synthis.size())
+ if(n < (int)synthis.size())
{
- // Add instance last in midi device list.
- for (int i = 0; i < MIDI_PORTS; ++i)
+ //t = song->createSynthI(synp->text(n));
+ //t = song->createSynthI(synthis[n]->name());
+ t = song->createSynthI(synthis[n]->baseName(), synthis[n]->name());
+
+ if(t)
{
- MidiPort* port = &midiPorts[i];
- MidiDevice* dev = port->device();
- if (dev==0)
+ // Add instance last in midi device list.
+ for (int i = 0; i < MIDI_PORTS; ++i)
{
- midiSeq->msgSetMidiDevice(port, (SynthI*)t);
- muse->changeConfig(true); // save configuration file
- song->update();
- break;
- }
- }
- }
+ MidiPort* port = &midiPorts[i];
+ MidiDevice* dev = port->device();
+ if (dev==0)
+ {
+ midiSeq->msgSetMidiDevice(port, (SynthI*)t);
+ muse->changeConfig(true); // save configuration file
+ song->update();
+ break;
+ }
+ }
+ }
+ }
}
- }
- // Normal track.
- else
- t = song->addTrack((Track::TrackType)n);
-
- if(t)
- {
- song->deselectTracks();
- t->setSelected(true);
-
- emit selectionChanged();
- adjustScrollbar();
- }
+ // Normal track.
+ else
+ t = song->addTrack((Track::TrackType)n);
+
+ if(t)
+ {
+ song->deselectTracks();
+ t->setSelected(true);
+
+ emit selectionChanged();
+ adjustScrollbar();
+ }
+ }
}
// Just delete p, and all its children will go too, right?