forked from mirrors/0ad
Don't execute the task when no Future awaits it anymore
Summary: Most of the times the callback stores a reference to a variable in scope where the `Future` is in. When the scope is left the reference get's dangling. `CancelOrWait` is called in multiple places (mostly destructors) to ensure the callback isn't executed anymore. This patch deduplicates thous calls to `CancelOrWait`. Refs: #5874 Comments by: @Stan, @vladislavbelov Differential Revision: https://code.wildfiregames.com/D5208 This was SVN commit r28128.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2023 Wildfire Games.
|
||||
/* Copyright (C) 2024 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
@@ -1331,11 +1331,6 @@ struct CMapReader::GeneratorState
|
||||
{
|
||||
std::atomic<int> progress{1};
|
||||
Future<Script::StructuredClone> task;
|
||||
|
||||
~GeneratorState()
|
||||
{
|
||||
task.CancelOrWait();
|
||||
}
|
||||
};
|
||||
|
||||
int CMapReader::StartMapGeneration(const CStrW& scriptFile)
|
||||
|
||||
Reference in New Issue
Block a user