mirror of
https://github.com/meshtastic/firmware.git
synced 2026-11-06 06:14:45 -05:00
fix(graphics): make on-screen keyboard lifecycle safe and RAII-managed (#11460)
- VirtualKeyboard::handleLongPress VK_ESC invoked the onTextEntered member std::function directly, but that callback path reaches OnScreenKeyboardModule::stop(), which destroys the keyboard - and with it the std::function whose invocation is still on the stack. handlePress and submitText already deliberately copy-and-clear before invoking for exactly this reason (CannedMessageModule documents the same hazard); do the same here. - OnScreenKeyboardModule's keyboard becomes unique_ptr, replacing the delete-in-destructor / delete-then-new-in-start / delete-in-stop bookkeeping that runs on every keyboard open/close. The NotificationRenderer legacy hook receives a non-owning raw pointer, as before.
This commit is contained in:
1 parent
0ff10318ad
commit
fb6a212b44
3 files changed
+14
-20
No files matched your search
@@ -7,6 +7,7 @@
|
||||
#include "graphics/VirtualKeyboard.h"
|
||||
#include <OLEDDisplay.h>
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
namespace graphics
|
||||
@@ -34,7 +35,7 @@ class OnScreenKeyboardModule
|
||||
void onSubmit(const std::string &text);
|
||||
void onCancel();
|
||||
|
||||
VirtualKeyboard *keyboard = nullptr;
|
||||
std::unique_ptr<VirtualKeyboard> keyboard;
|
||||
std::function<void(const std::string &)> callback;
|
||||
};
|
||||
|
||||
|
||||
Reference in new issue
Block a user