From 35628b057c0ac7c89f8051d6a452bdab55d4e72b Mon Sep 17 00:00:00 2001 From: doitux Date: Mon, 17 Dec 2012 14:19:02 +0100 Subject: [PATCH] bugfix for logfiledialog crash --- src/gui/qt/logfiledialog/logfiledialog.cpp | 3 + src/gui/qt/sound/sdlplayer.cpp | 124 ++++++++++----------- 2 files changed, 65 insertions(+), 62 deletions(-) diff --git a/src/gui/qt/logfiledialog/logfiledialog.cpp b/src/gui/qt/logfiledialog/logfiledialog.cpp index 3c09d440..eb5658b0 100644 --- a/src/gui/qt/logfiledialog/logfiledialog.cpp +++ b/src/gui/qt/logfiledialog/logfiledialog.cpp @@ -67,6 +67,7 @@ void LogFileDialog::refreshLogFileList() QFileInfo currentSqliteLogFile(QString::fromStdString(myGuiLog->getMySqliteLogFileName())); + ui->treeWidget_logFiles->blockSignals(TRUE); ui->treeWidget_logFiles->clear(); int i; for (i=0; i < dbFilesList.size(); i++) { @@ -86,6 +87,8 @@ void LogFileDialog::refreshLogFileList() ui->treeWidget_logFiles->addTopLevelItem(item); } ui->treeWidget_logFiles->sortItems(0, Qt::DescendingOrder); + ui->treeWidget_logFiles->blockSignals(FALSE); + ui->treeWidget_logFiles->setCurrentItem(ui->treeWidget_logFiles->topLevelItem(0)); } void LogFileDialog::deleteLogFile() diff --git a/src/gui/qt/sound/sdlplayer.cpp b/src/gui/qt/sound/sdlplayer.cpp index 7f69555f..0f2776ea 100644 --- a/src/gui/qt/sound/sdlplayer.cpp +++ b/src/gui/qt/sound/sdlplayer.cpp @@ -72,76 +72,76 @@ void SDLPlayer::initAudio() void SDLPlayer::playSound(string audioString, int playerID) { #ifndef ANDROID -// if(audioEnabled && myConfig->readConfigInt("PlaySoundEffects")) { + if(audioEnabled && myConfig->readConfigInt("PlaySoundEffects")) { -// QFile myFile(myAppDataPath + "sounds/default/" + QString::fromStdString(audioString)+".wav"); + QFile myFile(myAppDataPath + "sounds/default/" + QString::fromStdString(audioString)+".wav"); -// if(myFile.open(QIODevice::ReadOnly)) { + if(myFile.open(QIODevice::ReadOnly)) { -// //set 3d position for player -// int position = 0; -// int distance = 0; + //set 3d position for player + int position = 0; + int distance = 0; -// switch (playerID) { + switch (playerID) { -// case 0: { -// position = 180; -// distance = 10; -// } -// break; -// case 1: { -// position = 281; -// distance = 50; -// } -// break; -// case 2: { -// position = 315; -// distance = 120; -// } -// break; -// case 3: { -// position = 338; -// distance = 160; -// } -// break; -// case 4: { -// position = 23; -// distance = 160; -// } -// break; -// case 5: { -// position = 45; -// distance = 120; -// } -// break; -// case 6: { -// position = 79; -// distance = 50; -// } -// break; -// default: { -// position = 0; -// distance = 0; -// } -// break; -// } + case 0: { + position = 180; + distance = 10; + } + break; + case 1: { + position = 281; + distance = 50; + } + break; + case 2: { + position = 315; + distance = 120; + } + break; + case 3: { + position = 338; + distance = 160; + } + break; + case 4: { + position = 23; + distance = 160; + } + break; + case 5: { + position = 45; + distance = 120; + } + break; + case 6: { + position = 79; + distance = 50; + } + break; + default: { + position = 0; + distance = 0; + } + break; + } -// QDataStream in(&myFile); -// soundData = new Uint8[(int)myFile.size()]; -// in.readRawData( (char*)soundData, (int)myFile.size() ); -// sound = Mix_QuickLoad_WAV(soundData); + QDataStream in(&myFile); + soundData = new Uint8[(int)myFile.size()]; + in.readRawData( (char*)soundData, (int)myFile.size() ); + sound = Mix_QuickLoad_WAV(soundData); -// // set channel 0 to settings volume -// Mix_Volume(-1,myConfig->readConfigInt("SoundVolume")*10); + // set channel 0 to settings volume + Mix_Volume(-1,myConfig->readConfigInt("SoundVolume")*10); -// // set 3d effect -// if(!Mix_SetPosition(0, position, distance)) { -// printf("Mix_SetPosition: %s\n", Mix_GetError()); -// // no position effect, is it ok? -// } -// currentChannel = Mix_PlayChannel(-1, sound,0); -// } -// } + // set 3d effect + if(!Mix_SetPosition(0, position, distance)) { + printf("Mix_SetPosition: %s\n", Mix_GetError()); + // no position effect, is it ok? + } + currentChannel = Mix_PlayChannel(-1, sound,0); + } + } #endif }