diff --git a/src/preview/PreviewModel.cpp b/src/preview/PreviewModel.cpp index 8b327f954..2abccfffc 100644 --- a/src/preview/PreviewModel.cpp +++ b/src/preview/PreviewModel.cpp @@ -248,6 +248,7 @@ void PreviewModel::Update() if(updateSaveInfoFinished && save) { + commentsTotal = save->Comments; try { save->SetGameSave(new GameSave(&saveDataBuffer[0], saveDataBuffer.size())); @@ -257,6 +258,7 @@ void PreviewModel::Update() throw PreviewModelException("Save file corrupt or from newer version"); } notifySaveChanged(); + notifyCommentsPageChanged(); } } } @@ -285,7 +287,7 @@ void PreviewModel::Update() } } notifySaveChanged(); - notifyCommentsPageChanged(); + if(!save) throw PreviewModelException("Unable to load save"); } diff --git a/src/search/SearchModel.cpp b/src/search/SearchModel.cpp index d05bf1d50..f6a9480d2 100644 --- a/src/search/SearchModel.cpp +++ b/src/search/SearchModel.cpp @@ -54,25 +54,25 @@ void * SearchModel::updateSaveListT() void SearchModel::UpdateSaveList(int pageNumber, std::string query) { - lastQuery = query; - lastError = ""; - saveListLoaded = false; - saveList.clear(); - //resultCount = 0; - currentPage = pageNumber; - notifySaveListChanged(); - notifyPageChanged(); - selected.clear(); - notifySelectedChanged(); - - if(pageNumber == 1 && !showOwn && !showFavourite && currentSort == "best" && query == "") - SetShowTags(true); - else - SetShowTags(false); - //Threading if(!updateSaveListWorking) { + lastQuery = query; + lastError = ""; + saveListLoaded = false; + saveList.clear(); + //resultCount = 0; + currentPage = pageNumber; + notifySaveListChanged(); + notifyPageChanged(); + selected.clear(); + notifySelectedChanged(); + + if(pageNumber == 1 && !showOwn && !showFavourite && currentSort == "best" && query == "") + SetShowTags(true); + else + SetShowTags(false); + updateSaveListFinished = false; updateSaveListWorking = true; pthread_create(&updateSaveListThread, 0, &SearchModel::updateSaveListTHelper, this); @@ -119,7 +119,8 @@ void SearchModel::Update() void ** tempInformation; //vector * tempSaveList; pthread_join(updateSaveListThread, (void**)(&tempInformation)); - resultCount = thResultCount; + + saveList = *(vector*)tempInformation[0]; delete (vector*)tempInformation[0]; @@ -140,7 +141,8 @@ void SearchModel::Update() { lastError = Client::Ref().GetLastError(); } - //currentPage = pageNumber; + + resultCount = thResultCount; notifyPageChanged(); notifySaveListChanged(); }