[android] reset renderer on the GL thread when map is destroyed
- ensures cleanup of resources on the right thread
This commit is contained in:
committed by
Ivo van Dongen
parent
8b9794b1a7
commit
18bb6da109
@@ -27,8 +27,9 @@ MapRenderer::MapRenderer(jni::JNIEnv& _env, jni::Object<MapRenderer> obj,
|
||||
MapRenderer::~MapRenderer() = default;
|
||||
|
||||
void MapRenderer::reset() {
|
||||
assert (renderer);
|
||||
renderer.reset();
|
||||
// Make sure to destroy the renderer on the GL Thread
|
||||
auto self = ActorRef<MapRenderer>(*this, mailbox);
|
||||
self.ask(&MapRenderer::resetRenderer).wait();
|
||||
|
||||
// Lock to make sure there is no concurrent initialisation on the gl thread
|
||||
std::lock_guard<std::mutex> lock(initialisationMutex);
|
||||
@@ -91,6 +92,11 @@ void MapRenderer::requestSnapshot(SnapshotCallback callback) {
|
||||
|
||||
// Called on OpenGL thread //
|
||||
|
||||
void MapRenderer::resetRenderer() {
|
||||
assert (renderer);
|
||||
renderer.reset();
|
||||
}
|
||||
|
||||
void MapRenderer::scheduleSnapshot(std::unique_ptr<SnapshotCallback> callback) {
|
||||
snapshotCallback = std::move(callback);
|
||||
requestRender();
|
||||
|
||||
Reference in New Issue
Block a user