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);
((threadInfo*)obj)->threadFinished = true;
if (((threadInfo*)obj)->previewExited)
if (((threadInfo*)obj)->previewExited && tempSave)
delete tempSave;
return tempSave;
}
@@ -36,7 +36,9 @@ void * PreviewModel::updateSaveDataT(void * obj)
((threadInfo*)obj)->threadFinished = true;
if (((threadInfo*)obj)->previewExited)
{
if (tempSave)
delete tempSave;
if (tempData)
free(tempData);
}
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
((threadInfo*)obj)->threadFinished = true;
if (((threadInfo*)obj)->previewExited)
if (((threadInfo*)obj)->previewExited && tempComments)
{
for(int i = 0; i < tempComments->size(); i++)
delete tempComments->at(i);
@@ -244,13 +246,11 @@ void PreviewModel::AddObserver(PreviewView * observer)
void PreviewModel::Update()
{
if (updateSaveDataInfo)
{
if (updateSaveDataInfo->threadFinished)
if (updateSaveDataInfo && updateSaveDataInfo->threadFinished)
{
pthread_join(updateSaveDataThread, (void**)(&saveData));
delete updateSaveDataInfo;
updateSaveDataInfo = NULL;
pthread_join(updateSaveDataThread, (void**)(&saveData));
if (save)
{
@@ -267,20 +267,18 @@ void PreviewModel::Update()
notifyCommentsPageChanged();
}
}
}
if (updateSaveInfoInfo)
{
if (updateSaveInfoInfo->threadFinished)
if (updateSaveInfoInfo && updateSaveInfoInfo->threadFinished)
{
if (save)
{
delete save;
save = NULL;
}
pthread_join(updateSaveInfoThread, (void**)(&save));
delete updateSaveInfoInfo;
updateSaveInfoInfo = NULL;
pthread_join(updateSaveInfoThread, (void**)(&save));
if (save)
{
commentsTotal = save->Comments;
@@ -299,11 +297,8 @@ void PreviewModel::Update()
if(!save)
throw PreviewModelException("Unable to load save");
}
}
if (updateSaveCommentsInfo)
{
if (updateSaveCommentsInfo->threadFinished)
if (updateSaveCommentsInfo && updateSaveCommentsInfo->threadFinished)
{
if(saveComments)
{
@@ -313,13 +308,13 @@ void PreviewModel::Update()
delete saveComments;
saveComments = NULL;
}
commentsLoaded = true;
pthread_join(updateSaveCommentsThread, (void**)(&saveComments));
delete updateSaveCommentsInfo;
updateSaveCommentsInfo = NULL;
pthread_join(updateSaveCommentsThread, (void**)(&saveComments));
notifySaveCommentsChanged();
}
}
}
PreviewModel::~PreviewModel()