mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-19 00:37:25 +01:00
[code] Load Variable box content before compiling any other python code
to avoid memory exhaustion when displaying variable box
This commit is contained in:
@@ -47,32 +47,6 @@ static bool shouldAddObject(const char * name, int maxLength) {
|
||||
return true;
|
||||
}
|
||||
|
||||
void VariableBoxController::viewWillAppear() {
|
||||
m_scriptNodesCount = 0;
|
||||
m_scriptStore->scanScriptsForFunctionsAndVariables(
|
||||
this,
|
||||
[](void * context, const char * functionName, int scriptIndex) {
|
||||
if (!shouldAddObject(functionName, k_maxScriptObjectNameSize)) {
|
||||
return;
|
||||
}
|
||||
VariableBoxController * cvc = static_cast<VariableBoxController *>(context);
|
||||
cvc->addFunctionAtIndex(functionName, scriptIndex);},
|
||||
[](void * context, const char * variableName, int scriptIndex) {
|
||||
if (!shouldAddObject(variableName, k_maxScriptObjectNameSize)) {
|
||||
return;
|
||||
}
|
||||
VariableBoxController * cvc = static_cast<VariableBoxController *>(context);
|
||||
cvc->addVariableAtIndex(variableName, scriptIndex);});
|
||||
NestedMenuController::viewWillAppear();
|
||||
}
|
||||
|
||||
void VariableBoxController::viewDidDisappear() {
|
||||
for (int i = 0; i < k_maxScriptNodesCount; i++) {
|
||||
m_scriptNodes[i] = ScriptNode();
|
||||
}
|
||||
NestedMenuController::viewDidDisappear();
|
||||
}
|
||||
|
||||
int VariableBoxController::numberOfRows() {
|
||||
return m_scriptNodesCount < k_maxScriptNodesCount ? m_scriptNodesCount : k_maxScriptNodesCount;
|
||||
}
|
||||
@@ -91,6 +65,24 @@ int VariableBoxController::typeAtLocation(int i, int j) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
void VariableBoxController::loadFunctionsAndVariables() {
|
||||
m_scriptNodesCount = 0;
|
||||
m_scriptStore->scanScriptsForFunctionsAndVariables(
|
||||
this,
|
||||
[](void * context, const char * functionName, int scriptIndex) {
|
||||
if (!shouldAddObject(functionName, k_maxScriptObjectNameSize)) {
|
||||
return;
|
||||
}
|
||||
VariableBoxController * cvc = static_cast<VariableBoxController *>(context);
|
||||
cvc->addFunctionAtIndex(functionName, scriptIndex);},
|
||||
[](void * context, const char * variableName, int scriptIndex) {
|
||||
if (!shouldAddObject(variableName, k_maxScriptObjectNameSize)) {
|
||||
return;
|
||||
}
|
||||
VariableBoxController * cvc = static_cast<VariableBoxController *>(context);
|
||||
cvc->addVariableAtIndex(variableName, scriptIndex);});
|
||||
}
|
||||
|
||||
HighlightCell * VariableBoxController::leafCellAtIndex(int index) {
|
||||
assert(index >= 0 && index < k_maxNumberOfDisplayedRows);
|
||||
return &m_leafCells[index];
|
||||
|
||||
Reference in New Issue
Block a user