From c37b69e1a5316956ce966cce6841f3d960e581b0 Mon Sep 17 00:00:00 2001 From: Radomir Dopieralski Date: Thu, 24 May 2018 11:16:30 +0200 Subject: [PATCH] Make the gamepad singleton long-lived So that it is not later moved. --- shared-bindings/gamepad/GamePad.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/shared-bindings/gamepad/GamePad.c b/shared-bindings/gamepad/GamePad.c index 99fdbb64a2..b103c59b4e 100644 --- a/shared-bindings/gamepad/GamePad.c +++ b/shared-bindings/gamepad/GamePad.c @@ -26,6 +26,7 @@ #include "py/obj.h" #include "py/runtime.h" #include "py/mphal.h" +#include "py/gc.h" #include "shared-module/gamepad/GamePad.h" #include "shared-bindings/digitalio/DigitalInOut.h" #include "shared-bindings/util.h" @@ -108,6 +109,7 @@ STATIC mp_obj_t gamepad_make_new(const mp_obj_type_t *type, size_t n_args, if (!gamepad_singleton) { gamepad_singleton = m_new_obj(gamepad_obj_t); gamepad_singleton->base.type = &gamepad_type; + gamepad_singleton = gc_make_long_lived(gamepad_singleton); } gamepad_init(n_args, args); return MP_OBJ_FROM_PTR(gamepad_singleton);