mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-18 16:27:34 +01:00
[apps/code] Fix crashes on full buffer
Change-Id: If9297f1ca29015cad0cc1cdda3ad610fd1493392
This commit is contained in:
committed by
Émilie Feral
parent
aba135bc8b
commit
d937bc692b
@@ -23,7 +23,7 @@ void EditorController::setScript(Script script, int scriptIndex) {
|
||||
m_script = script;
|
||||
m_scriptIndex = scriptIndex;
|
||||
|
||||
/* We edit the script direclty in the storage buffer. We thus put all the
|
||||
/* We edit the script directly in the storage buffer. We thus put all the
|
||||
* storage available space at the end of the current edited script and we set
|
||||
* its size.
|
||||
*
|
||||
@@ -36,8 +36,8 @@ void EditorController::setScript(Script script, int scriptIndex) {
|
||||
*
|
||||
* */
|
||||
|
||||
size_t newScriptSize = Ion::Storage::sharedStorage()->putAvailableSpaceAtEndOfRecord(m_script);
|
||||
m_editorView.setText(const_cast<char *>(m_script.content()), newScriptSize - Script::StatusSize());
|
||||
Ion::Storage::sharedStorage()->putAvailableSpaceAtEndOfRecord(m_script);
|
||||
m_editorView.setText(const_cast<char *>(m_script.content()), m_script.contentSize());
|
||||
}
|
||||
|
||||
void EditorController::willExitApp() {
|
||||
|
||||
@@ -441,9 +441,7 @@ void PythonTextArea::addAutocompletion() {
|
||||
const int scriptIndex = m_contentView.pythonDelegate()->menuController()->editedScriptIndex();
|
||||
m_contentView.pythonDelegate()->variableBoxController()->loadFunctionsAndVariables(scriptIndex, autocompletionTokenBeginning, autocompletionLocation - autocompletionTokenBeginning);
|
||||
|
||||
if (addAutocompletionTextAtIndex(0)) {
|
||||
m_contentView.setAutocompleting(true);
|
||||
}
|
||||
addAutocompletionTextAtIndex(0);
|
||||
}
|
||||
|
||||
bool PythonTextArea::addAutocompletionTextAtIndex(int nextIndex, int * currentIndexToUpdate) {
|
||||
@@ -468,6 +466,7 @@ bool PythonTextArea::addAutocompletionTextAtIndex(int nextIndex, int * currentIn
|
||||
return false;
|
||||
}
|
||||
autocompletionLocation += textToInsertLength;
|
||||
m_contentView.setAutocompleting(true);
|
||||
m_contentView.setAutocompletionEnd(autocompletionLocation);
|
||||
}
|
||||
|
||||
@@ -480,8 +479,9 @@ bool PythonTextArea::addAutocompletionTextAtIndex(int nextIndex, int * currentIn
|
||||
if (addParentheses && m_contentView.insertTextAtLocation(parentheses, const_cast<char *>(autocompletionLocation), parenthesesLength)) {
|
||||
m_contentView.setAutocompleting(true);
|
||||
m_contentView.setAutocompletionEnd(autocompletionLocation + parenthesesLength);
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
return (textToInsertLength > 0);
|
||||
}
|
||||
|
||||
void PythonTextArea::cycleAutocompletion(bool downwards) {
|
||||
|
||||
@@ -49,6 +49,7 @@ public:
|
||||
bool autoImportationStatus() const;
|
||||
void toggleAutoimportationStatus();
|
||||
const char * content() const;
|
||||
size_t contentSize() { return value().size - k_statusSize; }
|
||||
|
||||
/* Fetched status */
|
||||
bool fetchedFromConsole() const;
|
||||
|
||||
@@ -99,6 +99,7 @@ void Storage::log() {
|
||||
size_t Storage::availableSize() {
|
||||
/* TODO maybe do: availableSize(char ** endBuffer) to get the endBuffer if it
|
||||
* is needed after calling availableSize */
|
||||
assert(k_storageSize >= (endBuffer() - m_buffer) + sizeof(record_size_t));
|
||||
return k_storageSize-(endBuffer()-m_buffer)-sizeof(record_size_t);
|
||||
}
|
||||
|
||||
@@ -479,7 +480,7 @@ bool Storage::isBaseNameWithExtensionTaken(const char * baseName, const char * e
|
||||
bool Storage::isNameOfRecordTaken(Record r, const Record * recordToExclude) {
|
||||
if (r == Record()) {
|
||||
/* If the CRC32 of fullName is 0, we want to refuse the name as it would
|
||||
* interfere with our escape case in the Record contructor, when the given
|
||||
* interfere with our escape case in the Record constructor, when the given
|
||||
* name is nullptr. */
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user