From: Orcan O. <oge...@gm...> - 2010-12-13 10:54:36
|
On Sun, Dec 12, 2010 at 9:01 PM, Tim E. Real wrote: > On December 12, 2010 08:11:31 pm you wrote: >> On Sun, Dec 12, 2010 at 7:39 PM, Tim E. Real wrote: >> > On December 12, 2010 10:40:09 am you wrote: >> >> >> > -several of my instrument program name presets are coming up as >> >> >> > jibberish. Had a few like this in muse1, but seems worse now. >> >> > >> >> > Ooh, that's not nice. Which instruments? Are you using a non-english >> >> > locale? Let's concentrate on this. Need to fix this. >> >> >> >> I'm using using english.. >> >> >> >> $ env | grep LANG >> >> LANG=en_US.utf8 >> >> GDM_LANG=en_US.utf8 >> >> >> >> SEE Screenshot attached. They do show up correctly on the list so that I >> >> can pick them, but are jibberish on the trackinfo page. >> > >> > I could not make the corruption happen. >> > >> > You say the popup list displays them fine but when you click on one >> > and the list goes away, then the track info 'instrument patch' button >> > shows corruption, correct? >> > >> > If so, it's likely that button, or the function in midiinstrument which >> > gets a single patch name... >> > >> > Hold the presses! Here it is I think: A casualty of the latin1() >> > conversions, breaking the temp object lifetime rules we discussed: >> > >> > const char* MidiInstrument::getPatchName(int channel, int prog, MType >> > mode, bool drum) >> > { >> > ... >> > return mp->name.toLatin1().constData(); >> > ... >> > } >> > >> > Yikes... I suspect maybe more like this. >> > Tim. >> >> Ah, that's bad. Fortunately there are not too many: >> >> $ grep -r toLatin * |grep return |grep -v build| grep -v svn >> muse/instruments/minstrument.cpp: return >> mp->name.toLatin1().constData(); >> muse/instruments/editinstrument.cpp: return >> mp->name.toLatin1().constData(); >> muse/plugin.cpp: return new DoubleLabel(parent, >> name.toLatin1().constData()); >> muse/plugin.cpp: return new Slider(parent, >> name.toLatin1().constData(), Qt::Horizontal); >> muse/remote/pyapi.cpp: return Py_BuildValue("s", >> track->name().toLatin1()); >> >> I think only the first two need a correction. What is the proper way >> of doing this? Allocating a *char in the caller function and pass it >> to this function by reference? > Nope. Just a string. > > Here's evolution > QString MidiInstrument::getPatchName(int /*channel*/, int prog) > { > ... > return mp->name; > ... > } > Indeed. Very good eye. This would even have caused a crash at some random place, and we would be spending hours to figure out why. Orcan |