Ensure comments page count is loaded correctly, fixes #117

This commit is contained in:
Simon Robertshaw 2012-08-14 17:00:12 +01:00
parent 66fffe649d
commit 03188e5853
2 changed files with 23 additions and 19 deletions

View File

@ -248,6 +248,7 @@ void PreviewModel::Update()
if(updateSaveInfoFinished && save) if(updateSaveInfoFinished && save)
{ {
commentsTotal = save->Comments;
try try
{ {
save->SetGameSave(new GameSave(&saveDataBuffer[0], saveDataBuffer.size())); save->SetGameSave(new GameSave(&saveDataBuffer[0], saveDataBuffer.size()));
@ -257,6 +258,7 @@ void PreviewModel::Update()
throw PreviewModelException("Save file corrupt or from newer version"); throw PreviewModelException("Save file corrupt or from newer version");
} }
notifySaveChanged(); notifySaveChanged();
notifyCommentsPageChanged();
} }
} }
} }
@ -285,7 +287,7 @@ void PreviewModel::Update()
} }
} }
notifySaveChanged(); notifySaveChanged();
notifyCommentsPageChanged();
if(!save) if(!save)
throw PreviewModelException("Unable to load save"); throw PreviewModelException("Unable to load save");
} }

View File

@ -53,6 +53,9 @@ void * SearchModel::updateSaveListT()
} }
void SearchModel::UpdateSaveList(int pageNumber, std::string query) void SearchModel::UpdateSaveList(int pageNumber, std::string query)
{
//Threading
if(!updateSaveListWorking)
{ {
lastQuery = query; lastQuery = query;
lastError = ""; lastError = "";
@ -70,9 +73,6 @@ void SearchModel::UpdateSaveList(int pageNumber, std::string query)
else else
SetShowTags(false); SetShowTags(false);
//Threading
if(!updateSaveListWorking)
{
updateSaveListFinished = false; updateSaveListFinished = false;
updateSaveListWorking = true; updateSaveListWorking = true;
pthread_create(&updateSaveListThread, 0, &SearchModel::updateSaveListTHelper, this); pthread_create(&updateSaveListThread, 0, &SearchModel::updateSaveListTHelper, this);
@ -119,7 +119,8 @@ void SearchModel::Update()
void ** tempInformation; void ** tempInformation;
//vector<SaveInfo*> * tempSaveList; //vector<SaveInfo*> * tempSaveList;
pthread_join(updateSaveListThread, (void**)(&tempInformation)); pthread_join(updateSaveListThread, (void**)(&tempInformation));
resultCount = thResultCount;
saveList = *(vector<SaveInfo*>*)tempInformation[0]; saveList = *(vector<SaveInfo*>*)tempInformation[0];
delete (vector<SaveInfo*>*)tempInformation[0]; delete (vector<SaveInfo*>*)tempInformation[0];
@ -140,7 +141,8 @@ void SearchModel::Update()
{ {
lastError = Client::Ref().GetLastError(); lastError = Client::Ref().GetLastError();
} }
//currentPage = pageNumber;
resultCount = thResultCount;
notifyPageChanged(); notifyPageChanged();
notifySaveListChanged(); notifySaveListChanged();
} }