summaryrefslogtreecommitdiff
path: root/muse2
diff options
context:
space:
mode:
authorTim E. Real <termtech@rogers.com>2010-12-14 20:06:14 +0000
committerTim E. Real <termtech@rogers.com>2010-12-14 20:06:14 +0000
commitd3d0a38e8c203d658207fb0c8736c046658ceaaa (patch)
treee67ca04f64948d96b5f51f91a4b20d23b4093063 /muse2
parent37d66824699fad3727f1c035a8ad98dc21782757 (diff)
Fixed corruption to due latin1() conversions.
Diffstat (limited to 'muse2')
-rw-r--r--muse2/ChangeLog3
-rw-r--r--muse2/muse/arranger/trackinfo.cpp33
-rw-r--r--muse2/muse/instruments/editinstrument.cpp7
-rw-r--r--muse2/muse/instruments/editinstrument.h2
-rw-r--r--muse2/muse/instruments/minstrument.cpp4
-rw-r--r--muse2/muse/instruments/minstrument.h2
-rw-r--r--muse2/muse/liste/editevent.cpp5
-rw-r--r--muse2/muse/midi.cpp4
-rw-r--r--muse2/muse/synth.h3
9 files changed, 33 insertions, 30 deletions
diff --git a/muse2/ChangeLog b/muse2/ChangeLog
index ac5d8036..ec91076c 100644
--- a/muse2/ChangeLog
+++ b/muse2/ChangeLog
@@ -1,3 +1,6 @@
+14.12.2010:
+ - Fixed corruption on track info instrument patch button due to latin1() conversions. (Tim)
+ Changed MidiInstrument::getPatchName() and EditInstrument::getPatchName() to return QString.
13.12.2010:
- List the available locales in the --help output. (Orcan)
- Fixed audio/midi control right-click automation popups were greyed out due to typo. (Tim)
diff --git a/muse2/muse/arranger/trackinfo.cpp b/muse2/muse/arranger/trackinfo.cpp
index e1c8047e..fdf0b0ce 100644
--- a/muse2/muse/arranger/trackinfo.cpp
+++ b/muse2/muse/arranger/trackinfo.cpp
@@ -33,7 +33,6 @@
#include "route.h"
#include "popupmenu.h"
-
//---------------------------------------------------------
// midiTrackInfoHeartBeat
//---------------------------------------------------------
@@ -174,14 +173,15 @@ void Arranger::midiTrackInfoHeartBeat()
else
{
MidiInstrument* instr = mp->instrument();
- const char* name = instr->getPatchName(outChannel, nprogram, song->mtype(), track->type() == Track::DRUM);
- if(!name)
+ QString name = instr->getPatchName(outChannel, nprogram, song->mtype(), track->type() == Track::DRUM);
+ if(name.isEmpty())
{
- if(midiTrackInfo->iPatch->text() != ("???"))
- midiTrackInfo->iPatch->setText("???");
+ const QString n("???");
+ if(midiTrackInfo->iPatch->text() != n)
+ midiTrackInfo->iPatch->setText(n);
}
else
- if(strcmp(midiTrackInfo->iPatch->text().toLatin1().constData(), name) != 0)
+ if(midiTrackInfo->iPatch->text() != name)
{
//printf("Arranger::midiTrackInfoHeartBeat setting patch name\n");
@@ -202,9 +202,9 @@ void Arranger::midiTrackInfoHeartBeat()
//else
//{
MidiInstrument* instr = mp->instrument();
- const char* name = instr->getPatchName(outChannel, program, song->mtype(), track->type() == Track::DRUM);
- if(strcmp(midiTrackInfo->iPatch->text().toLatin1().constData(), name) != 0)
- midiTrackInfo->iPatch->setText(QString(name));
+ QString name = instr->getPatchName(outChannel, program, song->mtype(), track->type() == Track::DRUM);
+ if(midiTrackInfo->iPatch->text() != name)
+ midiTrackInfo->iPatch->setText(name);
int hb = ((program >> 16) & 0xff) + 1;
if (hb == 0x100)
@@ -714,8 +714,7 @@ void Arranger::iProgHBankChanged()
audio->msgPlayMidiEvent(&ev);
MidiInstrument* instr = mp->instrument();
- const char* name = instr->getPatchName(channel, program, song->mtype(), track->type() == Track::DRUM);
- midiTrackInfo->iPatch->setText(QString(name));
+ midiTrackInfo->iPatch->setText(instr->getPatchName(channel, program, song->mtype(), track->type() == Track::DRUM));
// updateTrackInfo();
}
@@ -791,8 +790,7 @@ void Arranger::iProgLBankChanged()
audio->msgPlayMidiEvent(&ev);
MidiInstrument* instr = mp->instrument();
- const char* name = instr->getPatchName(channel, program, song->mtype(), track->type() == Track::DRUM);
- midiTrackInfo->iPatch->setText(QString(name));
+ midiTrackInfo->iPatch->setText(instr->getPatchName(channel, program, song->mtype(), track->type() == Track::DRUM));
// updateTrackInfo();
}
@@ -868,8 +866,7 @@ void Arranger::iProgramChanged()
audio->msgPlayMidiEvent(&ev);
MidiInstrument* instr = mp->instrument();
- const char* name = instr->getPatchName(channel, program, song->mtype(), track->type() == Track::DRUM);
- midiTrackInfo->iPatch->setText(QString(name));
+ midiTrackInfo->iPatch->setText(instr->getPatchName(channel, program, song->mtype(), track->type() == Track::DRUM));
}
// updateTrackInfo();
@@ -1363,8 +1360,7 @@ void Arranger::updateMidiTrackInfo(int flags)
else
{
MidiInstrument* instr = mp->instrument();
- const char* name = instr->getPatchName(outChannel, nprogram, song->mtype(), track->type() == Track::DRUM);
- midiTrackInfo->iPatch->setText(QString(name));
+ midiTrackInfo->iPatch->setText(instr->getPatchName(outChannel, nprogram, song->mtype(), track->type() == Track::DRUM));
}
}
else
@@ -1380,8 +1376,7 @@ void Arranger::updateMidiTrackInfo(int flags)
//else
//{
MidiInstrument* instr = mp->instrument();
- const char* name = instr->getPatchName(outChannel, program, song->mtype(), track->type() == Track::DRUM);
- midiTrackInfo->iPatch->setText(QString(name));
+ midiTrackInfo->iPatch->setText(instr->getPatchName(outChannel, program, song->mtype(), track->type() == Track::DRUM));
int hb = ((program >> 16) & 0xff) + 1;
if (hb == 0x100)
diff --git a/muse2/muse/instruments/editinstrument.cpp b/muse2/muse/instruments/editinstrument.cpp
index a0aba89c..d82dff4f 100644
--- a/muse2/muse/instruments/editinstrument.cpp
+++ b/muse2/muse/instruments/editinstrument.cpp
@@ -3478,9 +3478,8 @@ void EditInstrument::enableDefaultControls(bool enVal, bool enPatch)
void EditInstrument::setDefaultPatchName(int val)
{
- const char* patchname = getPatchName(val);
patchButton->blockSignals(true);
- patchButton->setText(QString(patchname));
+ patchButton->setText(getPatchName(val));
patchButton->blockSignals(false);
}
@@ -3553,7 +3552,7 @@ void EditInstrument::setDefaultPatchControls(int val)
// getPatchName
//---------------------------------------------------------
-const char* EditInstrument::getPatchName(int prog)
+QString EditInstrument::getPatchName(int prog)
{
int pr = prog & 0xff;
if(prog == CTRL_VAL_UNKNOWN || pr == 0xff)
@@ -3579,7 +3578,7 @@ const char* EditInstrument::getPatchName(int prog)
//&& (lbank == mp->lbank || !lb || mp->lbank == -1))
&& (hbank == mp->hbank || mp->hbank == -1)
&& (lbank == mp->lbank || mp->lbank == -1))
- return mp->name.toLatin1().constData();
+ return mp->name;
}
}
return "---";
diff --git a/muse2/muse/instruments/editinstrument.h b/muse2/muse/instruments/editinstrument.h
index 62ad389e..b3c6b5e0 100644
--- a/muse2/muse/instruments/editinstrument.h
+++ b/muse2/muse/instruments/editinstrument.h
@@ -42,7 +42,7 @@ class EditInstrument : public QMainWindow, public Ui::EditInstrumentBase {
int getDefaultPatchNumber();
void setDefaultPatchNumbers(int);
void setDefaultPatchControls(int);
- const char* getPatchName(int);
+ QString getPatchName(int);
void deleteInstrument(QListWidgetItem*);
///QMenu* patchpopup;
diff --git a/muse2/muse/instruments/minstrument.cpp b/muse2/muse/instruments/minstrument.cpp
index a1544d64..db885113 100644
--- a/muse2/muse/instruments/minstrument.cpp
+++ b/muse2/muse/instruments/minstrument.cpp
@@ -806,7 +806,7 @@ void MidiInstrument::write(int level, Xml& xml)
// getPatchName
//---------------------------------------------------------
-const char* MidiInstrument::getPatchName(int channel, int prog, MType mode, bool drum)
+QString MidiInstrument::getPatchName(int channel, int prog, MType mode, bool drum)
{
int pr = prog & 0xff;
if(prog == CTRL_VAL_UNKNOWN || pr == 0xff)
@@ -849,7 +849,7 @@ const char* MidiInstrument::getPatchName(int channel, int prog, MType mode, bool
&& (hbank == mp->hbank || !hb || mp->hbank == -1)
&& (lbank == mp->lbank || !lb || mp->lbank == -1))
- return mp->name.toLatin1().constData();
+ return mp->name;
}
}
return "<unknown>";
diff --git a/muse2/muse/instruments/minstrument.h b/muse2/muse/instruments/minstrument.h
index 3e132633..09bfb9da 100644
--- a/muse2/muse/instruments/minstrument.h
+++ b/muse2/muse/instruments/minstrument.h
@@ -117,7 +117,7 @@ class MidiInstrument {
virtual void writeToGui(const MidiPlayEvent&) {}
virtual void reset(int, MType);
- virtual const char* getPatchName(int,int,MType,bool);
+ virtual QString getPatchName(int,int,MType,bool);
virtual void populatePatchPopup(QMenu*, int, MType, bool);
void read(Xml&);
void write(int level, Xml&);
diff --git a/muse2/muse/liste/editevent.cpp b/muse2/muse/liste/editevent.cpp
index efcb8e84..b162a3e6 100644
--- a/muse2/muse/liste/editevent.cpp
+++ b/muse2/muse/liste/editevent.cpp
@@ -86,6 +86,8 @@ char* hex2string(QWidget* parent, const char* src, int& len)
}
}
len = dst - buffer;
+ if(len == 0)
+ return 0;
char* b = new char[len+1];
memcpy(b, buffer, len);
b[len] = 0;
@@ -805,8 +807,7 @@ void EditCtrlDialog::updatePatch()
int port = track->outPort();
int channel = track->outChannel();
MidiInstrument* instr = midiPorts[port].instrument();
- const char* name = instr->getPatchName(channel, val, song->mtype(), track->type() == Track::DRUM);
- patchName->setText(QString(name));
+ patchName->setText(instr->getPatchName(channel, val, song->mtype(), track->type() == Track::DRUM));
int hb = ((val >> 16) & 0xff) + 1;
if (hb == 0x100)
diff --git a/muse2/muse/midi.cpp b/muse2/muse/midi.cpp
index c1a24c8e..e339f29b 100644
--- a/muse2/muse/midi.cpp
+++ b/muse2/muse/midi.cpp
@@ -100,8 +100,12 @@ QString midiMetaName(int meta)
QString nameSysex(unsigned int len, const unsigned char* buf)
{
QString s;
+ if(len == 0)
+ return s;
switch(buf[0]) {
case 0x00:
+ if(len < 3)
+ return s;
if (buf[1] == 0 && buf[2] == 0x41)
s = "Microsoft";
break;
diff --git a/muse2/muse/synth.h b/muse2/muse/synth.h
index aa3fc375..27c4d3b5 100644
--- a/muse2/muse/synth.h
+++ b/muse2/muse/synth.h
@@ -212,7 +212,8 @@ class SynthI : public AudioTrack, public MidiDevice,
Synth* synth() const { return synthesizer; }
virtual bool isSynti() const { return true; }
- virtual const char* getPatchName(int ch, int prog, MType t, bool dr) {
+ //virtual const char* getPatchName(int ch, int prog, MType t, bool dr) {
+ virtual QString getPatchName(int ch, int prog, MType t, bool dr) {
return _sif->getPatchName(ch, prog, t, dr);
}