penguin-statistics / recognizer

Penguin Statistics result recognizer based on OpenCV, compiled using Emscripten and delivered via WASM to users with browsers.
MIT License
81 stars 6 forks source link

fix: Fix build error on Linux with gunstl #9

Closed MistEO closed 2 years ago

MistEO commented 2 years ago

The contribution from @aa889788

User stories: https://github.com/penguin-statistics/recognizer/issues/7 https://github.com/MaaAssistantArknights/MaaAssistantArknights/issues/419

Original PR: https://github.com/MaaAssistantArknights/MaaAssistantArknights/pull/462

KumoSiunaus commented 2 years ago

This workaround using std::deque is not a good way to address the problem. I inspected the issue again, and find that actually there is a bug in GNUSTL. When using std::vector as the element type of std::priority_queue (q), you cannot directly assign q.top() to a pre-defined vector using operator=. Here is the problem code:

auto last_pop = _stage_chrs; // auto == std::vector<penguin::Widget_Character>
...
last_pop = q.top(); // error

As a workaround, you can use std::vector.assign instead.

auto temp = q.top();
last_pop.assign(temp.begin(), temp.end());