GUI: Fix missing audio drivers in Edit Game dialog.

This is a regression from 77c65648b1db8f8b7b245510681eafd856798d26.

Formerly the code used strtok to check for any audio related GUIO flag to be
present in _guioptions. Since strtok tokenizes the string this won't really
work. I changed it to use strpbrk, which searches a string for any character
from a set of characters (in our case flags). The code should now have the
same semantics as of before the above mentioned commit.

This also gets rid of copying the gui options into a char array and a strncpy
call.
This commit is contained in:
Johannes Schickel 2011-10-24 20:29:28 +02:00
parent 97207dcbe3
commit c087f917dd

View File

@ -616,11 +616,8 @@ void OptionsDialog::setAudioSettingsState(bool enabled) {
_midiPopUpDesc->setEnabled(enabled);
_midiPopUp->setEnabled(enabled);
Common::String allFlags = MidiDriver::musicType2GUIO((uint32)-1);
char opt[256];
strncpy(opt, _guioptions.c_str(), 256);
bool hasMidiDefined = (strtok(opt, allFlags.c_str()) != NULL);
const Common::String allFlags = MidiDriver::musicType2GUIO((uint32)-1);
bool hasMidiDefined = (strpbrk(_guioptions.c_str(), allFlags.c_str()) != NULL);
if (_domain != Common::ConfigManager::kApplicationDomain && // global dialog
hasMidiDefined && // No flags are specified
@ -766,11 +763,8 @@ void OptionsDialog::addAudioControls(GuiObject *boss, const Common::String &pref
_midiPopUp = new PopUpWidget(boss, prefix + "auMidiPopup", _("Specifies output sound device or sound card emulator"));
// Populate it
Common::String allFlags = MidiDriver::musicType2GUIO((uint32)-1);
char opt[256];
strncpy(opt, _guioptions.c_str(), 256);
bool hasMidiDefined = (strtok(opt, allFlags.c_str()) != NULL);
const Common::String allFlags = MidiDriver::musicType2GUIO((uint32)-1);
bool hasMidiDefined = (strpbrk(_guioptions.c_str(), allFlags.c_str()) != NULL);
const MusicPlugin::List p = MusicMan.getPlugins();
for (MusicPlugin::List::const_iterator m = p.begin(); m != p.end(); ++m) {