mirror of
https://github.com/glest/glest-source.git
synced 2025-02-24 19:52:25 +01:00
- fixed mod menu crash bug after doing a remove
This commit is contained in:
parent
36ebfcf95e
commit
0a2ffde50f
@ -265,12 +265,14 @@ MenuStateMods::MenuStateMods(Program *program, MainMenu *mainMenu) :
|
||||
void MenuStateMods::simpleTask(BaseThread *callingThread) {
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
MutexSafeWrapper safeMutexThreadOwner(callingThread->getMutexThreadOwnerValid(),string(__FILE__) + "_" + intToStr(__LINE__));
|
||||
static string mutexOwnerId = string(__FILE__) + string("_") + intToStr(__LINE__);
|
||||
MutexSafeWrapper safeMutexThreadOwner(callingThread->getMutexThreadOwnerValid(),mutexOwnerId);
|
||||
if(callingThread->getQuitStatus() == true || safeMutexThreadOwner.isValidMutex() == false) {
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
return;
|
||||
}
|
||||
|
||||
callingThread->getMutexThreadOwnerValid()->setOwnerId(mutexOwnerId);
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
Lang &lang= Lang::getInstance();
|
||||
@ -854,8 +856,6 @@ void MenuStateMods::refreshScenarios() {
|
||||
|
||||
|
||||
void MenuStateMods::cleanUp() {
|
||||
clearUserButtons();
|
||||
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
if(modHttpServerThread != NULL) {
|
||||
@ -877,15 +877,24 @@ void MenuStateMods::cleanUp() {
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
if(ftpClientThread != NULL) {
|
||||
ftpClientThread->signalQuit();
|
||||
ftpClientThread->setCallBackObject(NULL);
|
||||
if(ftpClientThread->shutdownAndWait() == true) {
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
if( ftpClientThread->shutdownAndWait() == true) {
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
delete ftpClientThread;
|
||||
ftpClientThread = NULL;
|
||||
}
|
||||
ftpClientThread = NULL;
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
}
|
||||
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
clearUserButtons();
|
||||
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
cleanupPreviewTexture();
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
}
|
||||
|
||||
MenuStateMods::~MenuStateMods() {
|
||||
@ -902,6 +911,8 @@ void MenuStateMods::clearUserButtons() {
|
||||
delete keyTechButtons.back();
|
||||
keyTechButtons.pop_back();
|
||||
}
|
||||
keyTechScrollBar.setElementCount(0);
|
||||
|
||||
while(!labelsTech.empty()) {
|
||||
delete labelsTech.back();
|
||||
labelsTech.pop_back();
|
||||
@ -912,6 +923,7 @@ void MenuStateMods::clearUserButtons() {
|
||||
delete keyTilesetButtons.back();
|
||||
keyTilesetButtons.pop_back();
|
||||
}
|
||||
keyTilesetScrollBar.setElementCount(0);
|
||||
|
||||
// Maps
|
||||
while(!keyMapButtons.empty()) {
|
||||
@ -922,12 +934,14 @@ void MenuStateMods::clearUserButtons() {
|
||||
delete labelsMap.back();
|
||||
labelsMap.pop_back();
|
||||
}
|
||||
keyMapScrollBar.setElementCount(0);
|
||||
|
||||
// Scenarios
|
||||
while(!keyScenarioButtons.empty()) {
|
||||
delete keyScenarioButtons.back();
|
||||
keyScenarioButtons.pop_back();
|
||||
}
|
||||
keyScenarioScrollBar.setElementCount(0);
|
||||
}
|
||||
|
||||
void MenuStateMods::mouseClick(int x, int y, MouseButton mouseButton) {
|
||||
@ -1004,8 +1018,10 @@ void MenuStateMods::mouseClick(int x, int y, MouseButton mouseButton) {
|
||||
if(getItemAfterRemoval == true) {
|
||||
string mapName = selectedMapName;
|
||||
string mapURL = mapCacheList[mapName].url;
|
||||
ftpClientThread->addMapToRequests(mapName,mapURL);
|
||||
MutexSafeWrapper safeMutexFTPProgress((ftpClientThread != NULL ? ftpClientThread->getProgressMutex() : NULL),string(__FILE__) + "_" + intToStr(__LINE__));
|
||||
if(ftpClientThread != NULL) ftpClientThread->addMapToRequests(mapName,mapURL);
|
||||
static string mutexOwnerId = string(__FILE__) + string("_") + intToStr(__LINE__);
|
||||
MutexSafeWrapper safeMutexFTPProgress((ftpClientThread != NULL ? ftpClientThread->getProgressMutex() : NULL),mutexOwnerId);
|
||||
if(ftpClientThread != NULL && ftpClientThread->getProgressMutex() != NULL) ftpClientThread->getProgressMutex()->setOwnerId(mutexOwnerId);
|
||||
fileFTPProgressList[mapName] = pair<int,string>(0,"");
|
||||
safeMutexFTPProgress.ReleaseLock();
|
||||
buttonInstallMap.setEnabled(false);
|
||||
@ -1029,6 +1045,8 @@ void MenuStateMods::mouseClick(int x, int y, MouseButton mouseButton) {
|
||||
|
||||
bool remoteHasTileset = (tilesetCacheList.find(selectedTilesetName) != tilesetCacheList.end());
|
||||
if(remoteHasTileset == false) {
|
||||
//printf("\n\n\n$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ remote DOES NOT have removed tileset [%s]\n\n\n",selectedTilesetName.c_str());
|
||||
|
||||
for(unsigned int i = 0; i < keyTilesetButtons.size(); ++i) {
|
||||
GraphicButton *button = keyTilesetButtons[i];
|
||||
if(button != NULL && button->getText() == selectedTilesetName) {
|
||||
@ -1039,8 +1057,9 @@ void MenuStateMods::mouseClick(int x, int y, MouseButton mouseButton) {
|
||||
}
|
||||
}
|
||||
}
|
||||
MutexSafeWrapper safeMutexFTPProgress((ftpClientThread != NULL ? ftpClientThread->getProgressMutex() : NULL),string(__FILE__) + "_" + intToStr(__LINE__));
|
||||
safeMutexFTPProgress.Lock();
|
||||
static string mutexOwnerId = string(__FILE__) + string("_") + intToStr(__LINE__);
|
||||
MutexSafeWrapper safeMutexFTPProgress((ftpClientThread != NULL ? ftpClientThread->getProgressMutex() : NULL),mutexOwnerId);
|
||||
if(ftpClientThread != NULL && ftpClientThread->getProgressMutex() != NULL) ftpClientThread->getProgressMutex()->setOwnerId(mutexOwnerId);
|
||||
Checksum::clearFileCache();
|
||||
vector<string> paths = Config::getInstance().getPathListForType(ptTilesets);
|
||||
string pathSearchString = string("/") + selectedTilesetName + string("/*");
|
||||
@ -1058,13 +1077,15 @@ void MenuStateMods::mouseClick(int x, int y, MouseButton mouseButton) {
|
||||
if(getItemAfterRemoval == true) {
|
||||
string tilesetName = selectedTilesetName;
|
||||
string tilesetURL = tilesetCacheList[tilesetName].url;
|
||||
ftpClientThread->addTilesetToRequests(tilesetName,tilesetURL);
|
||||
MutexSafeWrapper safeMutexFTPProgress((ftpClientThread != NULL ? ftpClientThread->getProgressMutex() : NULL),string(__FILE__) + "_" + intToStr(__LINE__));
|
||||
if(ftpClientThread != NULL) ftpClientThread->addTilesetToRequests(tilesetName,tilesetURL);
|
||||
|
||||
static string mutexOwnerId = string(__FILE__) + string("_") + intToStr(__LINE__);
|
||||
MutexSafeWrapper safeMutexFTPProgress((ftpClientThread != NULL ? ftpClientThread->getProgressMutex() : NULL),mutexOwnerId);
|
||||
if(ftpClientThread != NULL && ftpClientThread->getProgressMutex() != NULL) ftpClientThread->getProgressMutex()->setOwnerId(mutexOwnerId);
|
||||
fileFTPProgressList[tilesetName] = pair<int,string>(0,"");
|
||||
safeMutexFTPProgress.ReleaseLock();
|
||||
buttonInstallTileset.setEnabled(false);
|
||||
}
|
||||
|
||||
}
|
||||
else if(mainMessageBoxState == ftpmsg_GetTechtree ||
|
||||
mainMessageBoxState == ftpmsg_ReplaceTechtree) {
|
||||
@ -1095,9 +1116,10 @@ void MenuStateMods::mouseClick(int x, int y, MouseButton mouseButton) {
|
||||
}
|
||||
}
|
||||
|
||||
MutexSafeWrapper safeMutexFTPProgress((ftpClientThread != NULL ? ftpClientThread->getProgressMutex() : NULL),string(__FILE__) + "_" + intToStr(__LINE__));
|
||||
static string mutexOwnerId = string(__FILE__) + string("_") + intToStr(__LINE__);
|
||||
MutexSafeWrapper safeMutexFTPProgress((ftpClientThread != NULL ? ftpClientThread->getProgressMutex() : NULL),mutexOwnerId);
|
||||
if(ftpClientThread != NULL && ftpClientThread->getProgressMutex() != NULL) ftpClientThread->getProgressMutex()->setOwnerId(mutexOwnerId);
|
||||
// Clear the CRC file Cache
|
||||
safeMutexFTPProgress.Lock();
|
||||
Checksum::clearFileCache();
|
||||
vector<string> paths = Config::getInstance().getPathListForType(ptTechs);
|
||||
string pathSearchString = string("/") + selectedTechName + string("/*");
|
||||
@ -1115,8 +1137,11 @@ void MenuStateMods::mouseClick(int x, int y, MouseButton mouseButton) {
|
||||
if(getItemAfterRemoval == true) {
|
||||
string techName = selectedTechName;
|
||||
string techURL = techCacheList[techName].url;
|
||||
ftpClientThread->addTechtreeToRequests(techName,techURL);
|
||||
MutexSafeWrapper safeMutexFTPProgress((ftpClientThread != NULL ? ftpClientThread->getProgressMutex() : NULL),string(__FILE__) + "_" + intToStr(__LINE__));
|
||||
if(ftpClientThread != NULL) ftpClientThread->addTechtreeToRequests(techName,techURL);
|
||||
|
||||
static string mutexOwnerId = string(__FILE__) + string("_") + intToStr(__LINE__);
|
||||
MutexSafeWrapper safeMutexFTPProgress((ftpClientThread != NULL ? ftpClientThread->getProgressMutex() : NULL),mutexOwnerId);
|
||||
if(ftpClientThread != NULL && ftpClientThread->getProgressMutex() != NULL) ftpClientThread->getProgressMutex()->setOwnerId(mutexOwnerId);
|
||||
fileFTPProgressList[techName] = pair<int,string>(0,"");
|
||||
safeMutexFTPProgress.ReleaseLock();
|
||||
buttonInstallTech.setEnabled(false);
|
||||
@ -1149,8 +1174,10 @@ void MenuStateMods::mouseClick(int x, int y, MouseButton mouseButton) {
|
||||
}
|
||||
}
|
||||
}
|
||||
MutexSafeWrapper safeMutexFTPProgress((ftpClientThread != NULL ? ftpClientThread->getProgressMutex() : NULL),string(__FILE__) + "_" + intToStr(__LINE__));
|
||||
safeMutexFTPProgress.Lock();
|
||||
|
||||
static string mutexOwnerId = string(__FILE__) + string("_") + intToStr(__LINE__);
|
||||
MutexSafeWrapper safeMutexFTPProgress((ftpClientThread != NULL ? ftpClientThread->getProgressMutex() : NULL),mutexOwnerId);
|
||||
if(ftpClientThread != NULL && ftpClientThread->getProgressMutex() != NULL) ftpClientThread->getProgressMutex()->setOwnerId(mutexOwnerId);
|
||||
Checksum::clearFileCache();
|
||||
vector<string> paths = Config::getInstance().getPathListForType(ptScenarios);
|
||||
string pathSearchString = string("/") + selectedScenarioName + string("/*");
|
||||
@ -1168,8 +1195,11 @@ void MenuStateMods::mouseClick(int x, int y, MouseButton mouseButton) {
|
||||
if(getItemAfterRemoval == true) {
|
||||
string scenarioName = selectedScenarioName;
|
||||
string scenarioURL = scenarioCacheList[scenarioName].url;
|
||||
ftpClientThread->addScenarioToRequests(scenarioName,scenarioURL);
|
||||
MutexSafeWrapper safeMutexFTPProgress((ftpClientThread != NULL ? ftpClientThread->getProgressMutex() : NULL),string(__FILE__) + "_" + intToStr(__LINE__));
|
||||
if(ftpClientThread != NULL) ftpClientThread->addScenarioToRequests(scenarioName,scenarioURL);
|
||||
|
||||
static string mutexOwnerId = string(__FILE__) + string("_") + intToStr(__LINE__);
|
||||
MutexSafeWrapper safeMutexFTPProgress((ftpClientThread != NULL ? ftpClientThread->getProgressMutex() : NULL),mutexOwnerId);
|
||||
if(ftpClientThread != NULL && ftpClientThread->getProgressMutex() != NULL) ftpClientThread->getProgressMutex()->setOwnerId(mutexOwnerId);
|
||||
fileFTPProgressList[scenarioName] = pair<int,string>(0,"");
|
||||
safeMutexFTPProgress.ReleaseLock();
|
||||
buttonInstallScenario.setEnabled(false);
|
||||
@ -1234,8 +1264,11 @@ void MenuStateMods::mouseClick(int x, int y, MouseButton mouseButton) {
|
||||
else {
|
||||
string techName = selectedTechName;
|
||||
string techURL = techCacheList[techName].url;
|
||||
ftpClientThread->addTechtreeToRequests(techName,techURL);
|
||||
MutexSafeWrapper safeMutexFTPProgress((ftpClientThread != NULL ? ftpClientThread->getProgressMutex() : NULL),string(__FILE__) + "_" + intToStr(__LINE__));
|
||||
if(ftpClientThread != NULL) ftpClientThread->addTechtreeToRequests(techName,techURL);
|
||||
|
||||
static string mutexOwnerId = string(__FILE__) + string("_") + intToStr(__LINE__);
|
||||
MutexSafeWrapper safeMutexFTPProgress((ftpClientThread != NULL ? ftpClientThread->getProgressMutex() : NULL),mutexOwnerId);
|
||||
if(ftpClientThread != NULL && ftpClientThread->getProgressMutex() != NULL) ftpClientThread->getProgressMutex()->setOwnerId(mutexOwnerId);
|
||||
fileFTPProgressList[techName] = pair<int,string>(0,"");
|
||||
safeMutexFTPProgress.ReleaseLock();
|
||||
buttonInstallTech.setEnabled(false);
|
||||
@ -1308,8 +1341,11 @@ void MenuStateMods::mouseClick(int x, int y, MouseButton mouseButton) {
|
||||
else {
|
||||
string tilesetName = selectedTilesetName;
|
||||
string tilesetURL = tilesetCacheList[tilesetName].url;
|
||||
ftpClientThread->addTilesetToRequests(tilesetName,tilesetURL);
|
||||
MutexSafeWrapper safeMutexFTPProgress((ftpClientThread != NULL ? ftpClientThread->getProgressMutex() : NULL),string(__FILE__) + "_" + intToStr(__LINE__));
|
||||
if(ftpClientThread != NULL) ftpClientThread->addTilesetToRequests(tilesetName,tilesetURL);
|
||||
|
||||
static string mutexOwnerId = string(__FILE__) + string("_") + intToStr(__LINE__);
|
||||
MutexSafeWrapper safeMutexFTPProgress((ftpClientThread != NULL ? ftpClientThread->getProgressMutex() : NULL),mutexOwnerId);
|
||||
if(ftpClientThread != NULL && ftpClientThread->getProgressMutex() != NULL) ftpClientThread->getProgressMutex()->setOwnerId(mutexOwnerId);
|
||||
fileFTPProgressList[tilesetName] = pair<int,string>(0,"");
|
||||
safeMutexFTPProgress.ReleaseLock();
|
||||
buttonInstallTileset.setEnabled(false);
|
||||
@ -1382,8 +1418,11 @@ void MenuStateMods::mouseClick(int x, int y, MouseButton mouseButton) {
|
||||
else {
|
||||
string mapName = selectedMapName;
|
||||
string mapURL = mapCacheList[mapName].url;
|
||||
ftpClientThread->addMapToRequests(mapName,mapURL);
|
||||
MutexSafeWrapper safeMutexFTPProgress((ftpClientThread != NULL ? ftpClientThread->getProgressMutex() : NULL),string(__FILE__) + "_" + intToStr(__LINE__));
|
||||
if(ftpClientThread != NULL) ftpClientThread->addMapToRequests(mapName,mapURL);
|
||||
|
||||
static string mutexOwnerId = string(__FILE__) + string("_") + intToStr(__LINE__);
|
||||
MutexSafeWrapper safeMutexFTPProgress((ftpClientThread != NULL ? ftpClientThread->getProgressMutex() : NULL),mutexOwnerId);
|
||||
if(ftpClientThread != NULL && ftpClientThread->getProgressMutex() != NULL) ftpClientThread->getProgressMutex()->setOwnerId(mutexOwnerId);
|
||||
fileFTPProgressList[mapName] = pair<int,string>(0,"");
|
||||
safeMutexFTPProgress.ReleaseLock();
|
||||
buttonInstallMap.setEnabled(false);
|
||||
@ -1457,8 +1496,11 @@ void MenuStateMods::mouseClick(int x, int y, MouseButton mouseButton) {
|
||||
string scenarioURL = scenarioCacheList[scenarioName].url;
|
||||
|
||||
//if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line %d] adding file to download [%s]\n",__FILE__,__FUNCTION__,__LINE__,scenarioURL.c_str());
|
||||
ftpClientThread->addScenarioToRequests(scenarioName,scenarioURL);
|
||||
MutexSafeWrapper safeMutexFTPProgress((ftpClientThread != NULL ? ftpClientThread->getProgressMutex() : NULL),string(__FILE__) + "_" + intToStr(__LINE__));
|
||||
if(ftpClientThread != NULL) ftpClientThread->addScenarioToRequests(scenarioName,scenarioURL);
|
||||
|
||||
static string mutexOwnerId = string(__FILE__) + string("_") + intToStr(__LINE__);
|
||||
MutexSafeWrapper safeMutexFTPProgress((ftpClientThread != NULL ? ftpClientThread->getProgressMutex() : NULL),mutexOwnerId);
|
||||
if(ftpClientThread != NULL && ftpClientThread->getProgressMutex() != NULL) ftpClientThread->getProgressMutex()->setOwnerId(mutexOwnerId);
|
||||
fileFTPProgressList[scenarioName] = pair<int,string>(0,"");
|
||||
safeMutexFTPProgress.ReleaseLock();
|
||||
buttonInstallScenario.setEnabled(false);
|
||||
@ -1615,7 +1657,7 @@ void MenuStateMods::showDesription(const ModInfo *modInfo) {
|
||||
cleanupPreviewTexture();
|
||||
string tempImage = getPreviewImageFileForMod(modInfo);
|
||||
if(tempImage != "" && fileExists(tempImage) == false) {
|
||||
ftpClientThread->addFileToRequests(tempImage,modInfo->imageUrl);
|
||||
if(ftpClientThread != NULL) ftpClientThread->addFileToRequests(tempImage,modInfo->imageUrl);
|
||||
}
|
||||
else {
|
||||
displayModPreviewImage = true;
|
||||
@ -1821,7 +1863,9 @@ void MenuStateMods::render() {
|
||||
}
|
||||
renderer.renderScrollBar(&keyScenarioScrollBar);
|
||||
|
||||
MutexSafeWrapper safeMutexFTPProgress((ftpClientThread != NULL ? ftpClientThread->getProgressMutex() : NULL),string(__FILE__) + "_" + intToStr(__LINE__));
|
||||
static string mutexOwnerId = string(__FILE__) + string("_") + intToStr(__LINE__);
|
||||
MutexSafeWrapper safeMutexFTPProgress((ftpClientThread != NULL ? ftpClientThread->getProgressMutex() : NULL),mutexOwnerId);
|
||||
if(ftpClientThread != NULL && ftpClientThread->getProgressMutex() != NULL) ftpClientThread->getProgressMutex()->setOwnerId(mutexOwnerId);
|
||||
if(fileFTPProgressList.size() > 0) {
|
||||
Lang &lang= Lang::getInstance();
|
||||
int yLocation = buttonReturn.getY();
|
||||
@ -1978,7 +2022,9 @@ void MenuStateMods::FTPClient_CallbackEvent(string itemName,
|
||||
}
|
||||
//if(SystemFlags::VERBOSE_MODE_ENABLED) printf("Got FTP Callback for [%s] current file [%s] fileProgress = %d [now = %f, total = %f]\n",itemName.c_str(),stats->currentFilename.c_str(), fileProgress,stats->download_now,stats->download_total);
|
||||
|
||||
MutexSafeWrapper safeMutexFTPProgress((ftpClientThread != NULL ? ftpClientThread->getProgressMutex() : NULL),string(__FILE__) + "_" + intToStr(__LINE__));
|
||||
static string mutexOwnerId = string(__FILE__) + string("_") + intToStr(__LINE__);
|
||||
MutexSafeWrapper safeMutexFTPProgress((ftpClientThread != NULL ? ftpClientThread->getProgressMutex() : NULL),mutexOwnerId);
|
||||
if(ftpClientThread != NULL && ftpClientThread->getProgressMutex() != NULL) ftpClientThread->getProgressMutex()->setOwnerId(mutexOwnerId);
|
||||
pair<int,string> lastProgress = fileFTPProgressList[itemName];
|
||||
fileFTPProgressList[itemName] = pair<int,string>(fileProgress,stats->currentFilename);
|
||||
safeMutexFTPProgress.ReleaseLock();
|
||||
@ -1987,7 +2033,9 @@ void MenuStateMods::FTPClient_CallbackEvent(string itemName,
|
||||
else if(type == ftp_cct_File) {
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("Got FTP Callback for [%s] result = %d [%s]\n",itemName.c_str(),result.first,result.second.c_str());
|
||||
|
||||
MutexSafeWrapper safeMutexFTPProgress((ftpClientThread != NULL ? ftpClientThread->getProgressMutex() : NULL),string(__FILE__) + "_" + intToStr(__LINE__));
|
||||
static string mutexOwnerId = string(__FILE__) + string("_") + intToStr(__LINE__);
|
||||
MutexSafeWrapper safeMutexFTPProgress((ftpClientThread != NULL ? ftpClientThread->getProgressMutex() : NULL),mutexOwnerId);
|
||||
if(ftpClientThread != NULL && ftpClientThread->getProgressMutex() != NULL) ftpClientThread->getProgressMutex()->setOwnerId(mutexOwnerId);
|
||||
fileFTPProgressList.erase(itemName);
|
||||
safeMutexFTPProgress.ReleaseLock();
|
||||
|
||||
@ -2008,7 +2056,9 @@ void MenuStateMods::FTPClient_CallbackEvent(string itemName,
|
||||
else if(type == ftp_cct_Map) {
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("Got FTP Callback for [%s] result = %d [%s]\n",itemName.c_str(),result.first,result.second.c_str());
|
||||
|
||||
MutexSafeWrapper safeMutexFTPProgress((ftpClientThread != NULL ? ftpClientThread->getProgressMutex() : NULL),string(__FILE__) + "_" + intToStr(__LINE__));
|
||||
static string mutexOwnerId = string(__FILE__) + string("_") + intToStr(__LINE__);
|
||||
MutexSafeWrapper safeMutexFTPProgress((ftpClientThread != NULL ? ftpClientThread->getProgressMutex() : NULL),mutexOwnerId);
|
||||
if(ftpClientThread != NULL && ftpClientThread->getProgressMutex() != NULL) ftpClientThread->getProgressMutex()->setOwnerId(mutexOwnerId);
|
||||
fileFTPProgressList.erase(itemName);
|
||||
safeMutexFTPProgress.ReleaseLock();
|
||||
selectedMapName = "";
|
||||
@ -2039,7 +2089,9 @@ void MenuStateMods::FTPClient_CallbackEvent(string itemName,
|
||||
else if(type == ftp_cct_Tileset) {
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("Got FTP Callback for [%s] result = %d [%s]\n",itemName.c_str(),result.first,result.second.c_str());
|
||||
|
||||
MutexSafeWrapper safeMutexFTPProgress((ftpClientThread != NULL ? ftpClientThread->getProgressMutex() : NULL),string(__FILE__) + "_" + intToStr(__LINE__));
|
||||
static string mutexOwnerId = string(__FILE__) + string("_") + intToStr(__LINE__);
|
||||
MutexSafeWrapper safeMutexFTPProgress((ftpClientThread != NULL ? ftpClientThread->getProgressMutex() : NULL),mutexOwnerId);
|
||||
if(ftpClientThread != NULL && ftpClientThread->getProgressMutex() != NULL) ftpClientThread->getProgressMutex()->setOwnerId(mutexOwnerId);
|
||||
fileFTPProgressList.erase(itemName);
|
||||
safeMutexFTPProgress.ReleaseLock(true);
|
||||
|
||||
@ -2084,7 +2136,9 @@ void MenuStateMods::FTPClient_CallbackEvent(string itemName,
|
||||
else if(type == ftp_cct_Techtree) {
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("Got FTP Callback for [%s] result = %d [%s]\n",itemName.c_str(),result.first,result.second.c_str());
|
||||
|
||||
MutexSafeWrapper safeMutexFTPProgress((ftpClientThread != NULL ? ftpClientThread->getProgressMutex() : NULL),string(__FILE__) + "_" + intToStr(__LINE__));
|
||||
static string mutexOwnerId = string(__FILE__) + string("_") + intToStr(__LINE__);
|
||||
MutexSafeWrapper safeMutexFTPProgress((ftpClientThread != NULL ? ftpClientThread->getProgressMutex() : NULL),mutexOwnerId);
|
||||
if(ftpClientThread != NULL && ftpClientThread->getProgressMutex() != NULL) ftpClientThread->getProgressMutex()->setOwnerId(mutexOwnerId);
|
||||
fileFTPProgressList.erase(itemName);
|
||||
safeMutexFTPProgress.ReleaseLock(true);
|
||||
|
||||
@ -2127,7 +2181,9 @@ void MenuStateMods::FTPClient_CallbackEvent(string itemName,
|
||||
else if(type == ftp_cct_Scenario) {
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("Got FTP Callback for [%s] result = %d [%s]\n",itemName.c_str(),result.first,result.second.c_str());
|
||||
|
||||
MutexSafeWrapper safeMutexFTPProgress((ftpClientThread != NULL ? ftpClientThread->getProgressMutex() : NULL),string(__FILE__) + "_" + intToStr(__LINE__));
|
||||
static string mutexOwnerId = string(__FILE__) + string("_") + intToStr(__LINE__);
|
||||
MutexSafeWrapper safeMutexFTPProgress((ftpClientThread != NULL ? ftpClientThread->getProgressMutex() : NULL),mutexOwnerId);
|
||||
if(ftpClientThread != NULL && ftpClientThread->getProgressMutex() != NULL) ftpClientThread->getProgressMutex()->setOwnerId(mutexOwnerId);
|
||||
fileFTPProgressList.erase(itemName);
|
||||
safeMutexFTPProgress.ReleaseLock(true);
|
||||
|
||||
|
@ -178,7 +178,7 @@ private:
|
||||
public:
|
||||
|
||||
MenuStateMods(Program *program, MainMenu *mainMenu);
|
||||
~MenuStateMods();
|
||||
virtual ~MenuStateMods();
|
||||
|
||||
void mouseClick(int x, int y, MouseButton mouseButton);
|
||||
void mouseMove(int x, int y, const MouseState *mouseState);
|
||||
|
@ -204,7 +204,9 @@ int file_progress(struct FtpFile *out,double download_total, double download_now
|
||||
stats.currentFilename = out->currentFilename;
|
||||
stats.downloadType = out->downloadType;
|
||||
|
||||
MutexSafeWrapper safeMutex(out->ftpServer->getProgressMutex(),string(__FILE__) + "_" + intToStr(__LINE__));
|
||||
static string mutexOwnerId = string(__FILE__) + string("_") + intToStr(__LINE__);
|
||||
MutexSafeWrapper safeMutex(out->ftpServer->getProgressMutex(),mutexOwnerId);
|
||||
out->ftpServer->getProgressMutex()->setOwnerId(mutexOwnerId);
|
||||
out->ftpServer->getCallBackObject()->FTPClient_CallbackEvent(out->itemName, ftp_cct_DownloadProgress, make_pair(ftp_crt_SUCCESS,""), &stats);
|
||||
}
|
||||
|
||||
@ -368,7 +370,9 @@ void FTPClientThread::getMapFromServer(pair<string,string> mapFileName) {
|
||||
}
|
||||
}
|
||||
|
||||
MutexSafeWrapper safeMutex(this->getProgressMutex(),string(__FILE__) + "_" + intToStr(__LINE__));
|
||||
static string mutexOwnerId = string(__FILE__) + string("_") + intToStr(__LINE__);
|
||||
MutexSafeWrapper safeMutex(this->getProgressMutex(),mutexOwnerId);
|
||||
this->getProgressMutex()->setOwnerId(mutexOwnerId);
|
||||
if(this->pCBObject != NULL) {
|
||||
this->pCBObject->FTPClient_CallbackEvent(mapFileName.first,ftp_cct_Map,result,NULL);
|
||||
}
|
||||
@ -376,7 +380,9 @@ void FTPClientThread::getMapFromServer(pair<string,string> mapFileName) {
|
||||
|
||||
void FTPClientThread::addMapToRequests(string mapFilename,string URL) {
|
||||
std::pair<string,string> item = make_pair(mapFilename,URL);
|
||||
MutexSafeWrapper safeMutex(&mutexMapFileList,string(__FILE__) + "_" + intToStr(__LINE__));
|
||||
static string mutexOwnerId = string(__FILE__) + string("_") + intToStr(__LINE__);
|
||||
MutexSafeWrapper safeMutex(&mutexMapFileList,mutexOwnerId);
|
||||
mutexMapFileList.setOwnerId(mutexOwnerId);
|
||||
if(std::find(mapFileList.begin(),mapFileList.end(),item) == mapFileList.end()) {
|
||||
mapFileList.push_back(item);
|
||||
}
|
||||
@ -384,7 +390,9 @@ void FTPClientThread::addMapToRequests(string mapFilename,string URL) {
|
||||
|
||||
void FTPClientThread::addTilesetToRequests(string tileSetName,string URL) {
|
||||
std::pair<string,string> item = make_pair(tileSetName,URL);
|
||||
MutexSafeWrapper safeMutex(&mutexTilesetList,string(__FILE__) + "_" + intToStr(__LINE__));
|
||||
static string mutexOwnerId = string(__FILE__) + string("_") + intToStr(__LINE__);
|
||||
MutexSafeWrapper safeMutex(&mutexTilesetList,mutexOwnerId);
|
||||
mutexTilesetList.setOwnerId(mutexOwnerId);
|
||||
if(std::find(tilesetList.begin(),tilesetList.end(),item) == tilesetList.end()) {
|
||||
tilesetList.push_back(item);
|
||||
}
|
||||
@ -392,7 +400,9 @@ void FTPClientThread::addTilesetToRequests(string tileSetName,string URL) {
|
||||
|
||||
void FTPClientThread::addTechtreeToRequests(string techtreeName,string URL) {
|
||||
std::pair<string,string> item = make_pair(techtreeName,URL);
|
||||
MutexSafeWrapper safeMutex(&mutexTechtreeList,string(__FILE__) + "_" + intToStr(__LINE__));
|
||||
static string mutexOwnerId = string(__FILE__) + string("_") + intToStr(__LINE__);
|
||||
MutexSafeWrapper safeMutex(&mutexTechtreeList,mutexOwnerId);
|
||||
mutexTechtreeList.setOwnerId(mutexOwnerId);
|
||||
if(std::find(techtreeList.begin(),techtreeList.end(),item) == techtreeList.end()) {
|
||||
techtreeList.push_back(item);
|
||||
}
|
||||
@ -400,7 +410,9 @@ void FTPClientThread::addTechtreeToRequests(string techtreeName,string URL) {
|
||||
|
||||
void FTPClientThread::addScenarioToRequests(string fileName,string URL) {
|
||||
std::pair<string,string> item = make_pair(fileName,URL);
|
||||
MutexSafeWrapper safeMutex(&mutexScenarioList,string(__FILE__) + "_" + intToStr(__LINE__));
|
||||
static string mutexOwnerId = string(__FILE__) + string("_") + intToStr(__LINE__);
|
||||
MutexSafeWrapper safeMutex(&mutexScenarioList,mutexOwnerId);
|
||||
mutexScenarioList.setOwnerId(mutexOwnerId);
|
||||
if(std::find(scenarioList.begin(),scenarioList.end(),item) == scenarioList.end()) {
|
||||
scenarioList.push_back(item);
|
||||
}
|
||||
@ -408,7 +420,9 @@ void FTPClientThread::addScenarioToRequests(string fileName,string URL) {
|
||||
|
||||
void FTPClientThread::addFileToRequests(string fileName,string URL) {
|
||||
std::pair<string,string> item = make_pair(fileName,URL);
|
||||
MutexSafeWrapper safeMutex(&mutexFileList,string(__FILE__) + "_" + intToStr(__LINE__));
|
||||
static string mutexOwnerId = string(__FILE__) + string("_") + intToStr(__LINE__);
|
||||
MutexSafeWrapper safeMutex(&mutexFileList,mutexOwnerId);
|
||||
mutexFileList.setOwnerId(mutexOwnerId);
|
||||
if(std::find(fileList.begin(),fileList.end(),item) == fileList.end()) {
|
||||
fileList.push_back(item);
|
||||
}
|
||||
@ -437,7 +451,9 @@ void FTPClientThread::getTilesetFromServer(pair<string,string> tileSetName) {
|
||||
}
|
||||
}
|
||||
|
||||
MutexSafeWrapper safeMutex(this->getProgressMutex(),string(__FILE__) + "_" + intToStr(__LINE__));
|
||||
static string mutexOwnerId = string(__FILE__) + string("_") + intToStr(__LINE__);
|
||||
MutexSafeWrapper safeMutex(this->getProgressMutex(),mutexOwnerId);
|
||||
this->getProgressMutex()->setOwnerId(mutexOwnerId);
|
||||
if(this->pCBObject != NULL) {
|
||||
this->pCBObject->FTPClient_CallbackEvent(tileSetName.first,ftp_cct_Tileset,result,NULL);
|
||||
}
|
||||
@ -745,7 +761,9 @@ void FTPClientThread::getTechtreeFromServer(pair<string,string> techtreeName) {
|
||||
}
|
||||
}
|
||||
|
||||
MutexSafeWrapper safeMutex(this->getProgressMutex(),string(__FILE__) + "_" + intToStr(__LINE__));
|
||||
static string mutexOwnerId = string(__FILE__) + string("_") + intToStr(__LINE__);
|
||||
MutexSafeWrapper safeMutex(this->getProgressMutex(),mutexOwnerId);
|
||||
this->getProgressMutex()->setOwnerId(mutexOwnerId);
|
||||
if(this->pCBObject != NULL) {
|
||||
this->pCBObject->FTPClient_CallbackEvent(techtreeName.first,ftp_cct_Techtree,result,NULL);
|
||||
}
|
||||
@ -924,7 +942,9 @@ void FTPClientThread::getScenarioFromServer(pair<string,string> fileName) {
|
||||
result = getScenarioInternalFromServer(fileName);
|
||||
}
|
||||
|
||||
MutexSafeWrapper safeMutex(this->getProgressMutex(),string(__FILE__) + "_" + intToStr(__LINE__));
|
||||
static string mutexOwnerId = string(__FILE__) + string("_") + intToStr(__LINE__);
|
||||
MutexSafeWrapper safeMutex(this->getProgressMutex(),mutexOwnerId);
|
||||
this->getProgressMutex()->setOwnerId(mutexOwnerId);
|
||||
if(this->pCBObject != NULL) {
|
||||
this->pCBObject->FTPClient_CallbackEvent(fileName.first,ftp_cct_Scenario,result,NULL);
|
||||
}
|
||||
@ -980,7 +1000,9 @@ void FTPClientThread::getFileFromServer(pair<string,string> fileName) {
|
||||
result = getFileInternalFromServer(fileName);
|
||||
}
|
||||
|
||||
MutexSafeWrapper safeMutex(this->getProgressMutex(),string(__FILE__) + "_" + intToStr(__LINE__));
|
||||
static string mutexOwnerId = string(__FILE__) + string("_") + intToStr(__LINE__);
|
||||
MutexSafeWrapper safeMutex(this->getProgressMutex(),mutexOwnerId);
|
||||
this->getProgressMutex()->setOwnerId(mutexOwnerId);
|
||||
if(this->pCBObject != NULL) {
|
||||
this->pCBObject->FTPClient_CallbackEvent(fileName.first,ftp_cct_File,result,NULL);
|
||||
}
|
||||
@ -1169,12 +1191,16 @@ pair<FTP_Client_ResultType,string> FTPClientThread::getFileFromServer(FTP_Clien
|
||||
|
||||
|
||||
FTPClientCallbackInterface * FTPClientThread::getCallBackObject() {
|
||||
MutexSafeWrapper safeMutex(this->getProgressMutex(),string(__FILE__) + "_" + intToStr(__LINE__));
|
||||
static string mutexOwnerId = string(__FILE__) + string("_") + intToStr(__LINE__);
|
||||
MutexSafeWrapper safeMutex(this->getProgressMutex(),mutexOwnerId);
|
||||
this->getProgressMutex()->setOwnerId(mutexOwnerId);
|
||||
return pCBObject;
|
||||
}
|
||||
|
||||
void FTPClientThread::setCallBackObject(FTPClientCallbackInterface *value) {
|
||||
MutexSafeWrapper safeMutex(this->getProgressMutex(),string(__FILE__) + "_" + intToStr(__LINE__));
|
||||
static string mutexOwnerId = string(__FILE__) + string("_") + intToStr(__LINE__);
|
||||
MutexSafeWrapper safeMutex(this->getProgressMutex(),mutexOwnerId);
|
||||
this->getProgressMutex()->setOwnerId(mutexOwnerId);
|
||||
pCBObject = value;
|
||||
}
|
||||
|
||||
@ -1192,7 +1218,9 @@ void FTPClientThread::execute() {
|
||||
|
||||
try {
|
||||
while(this->getQuitStatus() == false) {
|
||||
MutexSafeWrapper safeMutex(&mutexMapFileList,string(__FILE__) + "_" + intToStr(__LINE__));
|
||||
static string mutexOwnerId = string(__FILE__) + string("_") + intToStr(__LINE__);
|
||||
MutexSafeWrapper safeMutex(&mutexMapFileList,mutexOwnerId);
|
||||
mutexMapFileList.setOwnerId(mutexOwnerId);
|
||||
if(mapFileList.size() > 0) {
|
||||
pair<string,string> mapFilename = mapFileList[0];
|
||||
mapFileList.erase(mapFileList.begin() + 0);
|
||||
@ -1208,7 +1236,9 @@ void FTPClientThread::execute() {
|
||||
break;
|
||||
}
|
||||
|
||||
MutexSafeWrapper safeMutex2(&mutexTilesetList,string(__FILE__) + "_" + intToStr(__LINE__));
|
||||
static string mutexOwnerId2 = string(__FILE__) + string("_") + intToStr(__LINE__);
|
||||
MutexSafeWrapper safeMutex2(&mutexTilesetList,mutexOwnerId2);
|
||||
mutexTilesetList.setOwnerId(mutexOwnerId2);
|
||||
if(tilesetList.size() > 0) {
|
||||
pair<string,string> tileset = tilesetList[0];
|
||||
tilesetList.erase(tilesetList.begin() + 0);
|
||||
@ -1220,7 +1250,9 @@ void FTPClientThread::execute() {
|
||||
safeMutex2.ReleaseLock();
|
||||
}
|
||||
|
||||
MutexSafeWrapper safeMutex3(&mutexTechtreeList,string(__FILE__) + "_" + intToStr(__LINE__));
|
||||
static string mutexOwnerId3 = string(__FILE__) + string("_") + intToStr(__LINE__);
|
||||
MutexSafeWrapper safeMutex3(&mutexTechtreeList,mutexOwnerId3);
|
||||
mutexTechtreeList.setOwnerId(mutexOwnerId3);
|
||||
if(techtreeList.size() > 0) {
|
||||
pair<string,string> techtree = techtreeList[0];
|
||||
techtreeList.erase(techtreeList.begin() + 0);
|
||||
@ -1232,7 +1264,9 @@ void FTPClientThread::execute() {
|
||||
safeMutex3.ReleaseLock();
|
||||
}
|
||||
|
||||
MutexSafeWrapper safeMutex4(&mutexScenarioList,string(__FILE__) + "_" + intToStr(__LINE__));
|
||||
static string mutexOwnerId4 = string(__FILE__) + string("_") + intToStr(__LINE__);
|
||||
MutexSafeWrapper safeMutex4(&mutexScenarioList,mutexOwnerId4);
|
||||
mutexScenarioList.setOwnerId(mutexOwnerId4);
|
||||
if(scenarioList.size() > 0) {
|
||||
pair<string,string> file = scenarioList[0];
|
||||
scenarioList.erase(scenarioList.begin() + 0);
|
||||
@ -1244,7 +1278,9 @@ void FTPClientThread::execute() {
|
||||
safeMutex4.ReleaseLock();
|
||||
}
|
||||
|
||||
MutexSafeWrapper safeMutex5(&mutexFileList,string(__FILE__) + "_" + intToStr(__LINE__));
|
||||
static string mutexOwnerId5 = string(__FILE__) + string("_") + intToStr(__LINE__);
|
||||
MutexSafeWrapper safeMutex5(&mutexFileList,mutexOwnerId5);
|
||||
mutexFileList.setOwnerId(mutexOwnerId5);
|
||||
if(fileList.size() > 0) {
|
||||
pair<string,string> file = fileList[0];
|
||||
fileList.erase(fileList.begin() + 0);
|
||||
@ -1279,6 +1315,7 @@ void FTPClientThread::execute() {
|
||||
// Delete ourself when the thread is done (no other actions can happen after this
|
||||
// such as the mutex which modifies the running status of this method
|
||||
//delete this;
|
||||
deleteSelfIfRequired();
|
||||
}
|
||||
|
||||
}}//end namespace
|
||||
|
Loading…
x
Reference in New Issue
Block a user