[poincare] Put setjmp in apps_container and in Expression::parse

This commit is contained in:
Léa Saviot
2018-09-05 14:37:11 +02:00
parent c762b31bc2
commit 679f9815c1
4 changed files with 48 additions and 37 deletions

View File

@@ -1,6 +1,7 @@
#include "apps_container.h"
#include "global_preferences.h"
#include <ion.h>
#include <poincare/tree_pool.h>
extern "C" {
#include <assert.h>
@@ -82,8 +83,18 @@ void AppsContainer::suspend(bool checkIfPowerKeyReleased) {
}
bool AppsContainer::dispatchEvent(Ion::Events::Event event) {
bool alphaLockWantsRedraw = updateAlphaLock();
jmp_buf jumpEnvironment;
Poincare::TreePool::sharedPool()->setJumpEnvironment(&jumpEnvironment);
int res = setjmp(jumpEnvironment);
if (res != 0) {
// There has been an exception, return an uninitialized node
Poincare::TreePool::sharedPool()->resetJumpEnvironment();// TODO Needed?
switchTo(appSnapshotAtIndex(0));
//displayMemoryExhaustionPopUp(); TODO
return true;
}
bool alphaLockWantsRedraw = updateAlphaLock();
bool didProcessEvent = false;
if (event == Ion::Events::USBEnumeration) {
@@ -114,8 +125,10 @@ bool AppsContainer::dispatchEvent(Ion::Events::Event event) {
}
if (!didProcessEvent && alphaLockWantsRedraw) {
window()->redraw();
Poincare::TreePool::sharedPool()->resetJumpEnvironment(); // TODO Needed?
return true;
}
Poincare::TreePool::sharedPool()->resetJumpEnvironment(); // TODO Needed?
return didProcessEvent || alphaLockWantsRedraw;
}