1
0
Fork 0
mirror of https://github.com/betaflight/betaflight-configurator.git synced 2025-07-26 01:35:28 +03:00

fix : Memory leak fix

This commit is contained in:
Syahmi Zul 2025-06-14 02:45:08 +08:00
parent 7df6587912
commit aeeda5755f

View file

@ -21,6 +21,8 @@ const FONT = {};
const SYM = {}; const SYM = {};
const OSD = {}; const OSD = {};
// Stuff related to the "preset" positioning
let globalMenuClickHandler = null;
const positionConfigs = { const positionConfigs = {
TL: { TL: {
label: "Top Left", label: "Top Left",
@ -3662,7 +3664,8 @@ osd.initialize = function (callback) {
$(this).removeClass("show"); $(this).removeClass("show");
}); });
// Global click handler to close menus // Global click handler to close menus
$(document).on("click", hideAllMenus); globalMenuClickHandler = hideAllMenus;
$(document).on("click", globalMenuClickHandler);
// Make field container relative positioned to contain the absolute positioned menu // Make field container relative positioned to contain the absolute positioned menu
$field.css("position", "relative"); $field.css("position", "relative");
// Append all elements // Append all elements
@ -3982,6 +3985,12 @@ osd.cleanup = function (callback) {
if (callback) { if (callback) {
callback(); callback();
} }
// Remove position menu click handler
if (globalMenuClickHandler) {
$(document).off("click", globalMenuClickHandler);
globalMenuClickHandler = null;
}
}; };
TABS.osd = osd; TABS.osd = osd;