minor changes / fixes to last commit

This commit is contained in:
jacob1 2013-07-10 15:08:00 -04:00
parent 4f6904b1ed
commit e7a3fd1c29

View File

@ -23,7 +23,7 @@ void * PreviewModel::updateSaveInfoT(void * obj)
{ {
SaveInfo * tempSave = Client::Ref().GetSave(((threadInfo*)obj)->saveID, ((threadInfo*)obj)->saveDate); SaveInfo * tempSave = Client::Ref().GetSave(((threadInfo*)obj)->saveID, ((threadInfo*)obj)->saveDate);
((threadInfo*)obj)->threadFinished = true; ((threadInfo*)obj)->threadFinished = true;
if (((threadInfo*)obj)->previewExited) if (((threadInfo*)obj)->previewExited && tempSave)
delete tempSave; delete tempSave;
return tempSave; return tempSave;
} }
@ -36,7 +36,9 @@ void * PreviewModel::updateSaveDataT(void * obj)
((threadInfo*)obj)->threadFinished = true; ((threadInfo*)obj)->threadFinished = true;
if (((threadInfo*)obj)->previewExited) if (((threadInfo*)obj)->previewExited)
{ {
if (tempSave)
delete tempSave; delete tempSave;
if (tempData)
free(tempData); free(tempData);
} }
return tempSave; return tempSave;
@ -46,7 +48,7 @@ void * PreviewModel::updateSaveCommentsT(void * obj)
{ {
std::vector<SaveComment*> * tempComments = Client::Ref().GetComments(((threadInfo*)obj)->saveID, (((threadInfo*)obj)->saveDate-1)*20, 20); //saveDate is used as commentsPageNumber std::vector<SaveComment*> * tempComments = Client::Ref().GetComments(((threadInfo*)obj)->saveID, (((threadInfo*)obj)->saveDate-1)*20, 20); //saveDate is used as commentsPageNumber
((threadInfo*)obj)->threadFinished = true; ((threadInfo*)obj)->threadFinished = true;
if (((threadInfo*)obj)->previewExited) if (((threadInfo*)obj)->previewExited && tempComments)
{ {
for(int i = 0; i < tempComments->size(); i++) for(int i = 0; i < tempComments->size(); i++)
delete tempComments->at(i); delete tempComments->at(i);
@ -244,13 +246,11 @@ void PreviewModel::AddObserver(PreviewView * observer)
void PreviewModel::Update() void PreviewModel::Update()
{ {
if (updateSaveDataInfo) if (updateSaveDataInfo && updateSaveDataInfo->threadFinished)
{
if (updateSaveDataInfo->threadFinished)
{ {
pthread_join(updateSaveDataThread, (void**)(&saveData));
delete updateSaveDataInfo; delete updateSaveDataInfo;
updateSaveDataInfo = NULL; updateSaveDataInfo = NULL;
pthread_join(updateSaveDataThread, (void**)(&saveData));
if (save) if (save)
{ {
@ -267,20 +267,18 @@ void PreviewModel::Update()
notifyCommentsPageChanged(); notifyCommentsPageChanged();
} }
} }
}
if (updateSaveInfoInfo) if (updateSaveInfoInfo && updateSaveInfoInfo->threadFinished)
{
if (updateSaveInfoInfo->threadFinished)
{ {
if (save) if (save)
{ {
delete save; delete save;
save = NULL; save = NULL;
} }
pthread_join(updateSaveInfoThread, (void**)(&save));
delete updateSaveInfoInfo; delete updateSaveInfoInfo;
updateSaveInfoInfo = NULL; updateSaveInfoInfo = NULL;
pthread_join(updateSaveInfoThread, (void**)(&save));
if (save) if (save)
{ {
commentsTotal = save->Comments; commentsTotal = save->Comments;
@ -299,11 +297,8 @@ void PreviewModel::Update()
if(!save) if(!save)
throw PreviewModelException("Unable to load save"); throw PreviewModelException("Unable to load save");
} }
}
if (updateSaveCommentsInfo) if (updateSaveCommentsInfo && updateSaveCommentsInfo->threadFinished)
{
if (updateSaveCommentsInfo->threadFinished)
{ {
if(saveComments) if(saveComments)
{ {
@ -313,13 +308,13 @@ void PreviewModel::Update()
delete saveComments; delete saveComments;
saveComments = NULL; saveComments = NULL;
} }
commentsLoaded = true; commentsLoaded = true;
pthread_join(updateSaveCommentsThread, (void**)(&saveComments));
delete updateSaveCommentsInfo; delete updateSaveCommentsInfo;
updateSaveCommentsInfo = NULL; updateSaveCommentsInfo = NULL;
pthread_join(updateSaveCommentsThread, (void**)(&saveComments));
notifySaveCommentsChanged(); notifySaveCommentsChanged();
} }
}
} }
PreviewModel::~PreviewModel() PreviewModel::~PreviewModel()