Add weak pointer handling (#3763)

This commit is contained in:
Tim Sylvester
2025-09-02 07:35:25 -07:00
committed by GitHub
parent 5ba738f30c
commit 764f73c97a
28 changed files with 82 additions and 38 deletions

View File

@@ -37,8 +37,10 @@ public:
* performed on the GL Thread.
*
* The public methods are safe to call from the main thread, others are not.
*
* NOTE: Any derived class must invalidate `weakFactory` in the destructor
*/
class MapRenderer : public Scheduler {
class MapRenderer final : public Scheduler {
public:
static constexpr auto Name() { return "org/maplibre/android/maps/renderer/MapRenderer"; };
@@ -95,6 +97,10 @@ protected:
void scheduleSnapshot(std::unique_ptr<SnapshotCallback>);
// Allows derived classes to invalidate weak pointers in
// their destructor before their own members are torn down.
void invalidateWeakPtrsEarly() { weakFactory.invalidateWeakPtrs(); }
private:
struct MailboxData {
explicit MailboxData(Scheduler*);