Skip to content

Commit

Permalink
Fix use of invalid iterator fetch Crowdin project ID
Browse files Browse the repository at this point in the history
Don't capture in continuation and then use iterator long after the
container was destroyed (due to async nature of this code). Instead,
get the value directly from ProjectInfo.
  • Loading branch information
vslavik committed Jun 27, 2020
1 parent bf5711c commit 54b86a9
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/crowdin_gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -554,12 +554,12 @@ dispatch::future<void> CrowdinUpdateCatalogIDsFromHeaders(CatalogPtr catalog)
return CrowdinClient::Get().GetProjectInfo(projIt->id).then([=](CrowdinClient::ProjectInfo proj)
{
auto fileIt = find_if(proj.files.begin(), proj.files.end(),
[=](const auto& file) { return filePathName == file.pathName; });
[=](const auto& file) { return filePathName == file.pathName; });
if (fileIt == proj.files.end())
{
throw Exception(wxString::Format(_(L"File “%s” doesn’t exist in Crowdin project “%s”"), filePathName, projIdentifier));
}
catalog->SetCrowdinProjectAndFileId(projIt->id, fileIt->id);
catalog->SetCrowdinProjectAndFileId(proj.id, fileIt->id);
});
});

Expand Down

0 comments on commit 54b86a9

Please sign in to comment.