Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash when project name too long #402

Merged
merged 2 commits into from
Feb 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions sources/Application/Views/BaseClasses/UITextField.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ void UITextField::OnClick() {
};

void UITextField::OnEditClick() {
char name[40];
char name[MAX_PROJECT_NAME_LENGTH + 1];
strcpy(name, src_->GetString().c_str());
uint8_t len = std::strlen(name);
deleteChar(name, currentChar_);
Expand All @@ -57,7 +57,7 @@ void UITextField::OnEditClick() {
};

void UITextField::ProcessArrow(unsigned short mask) {
char name[40];
char name[MAX_PROJECT_NAME_LENGTH + 1];
strcpy(name, src_->GetString().c_str());
int len = std::strlen(name);

Expand Down Expand Up @@ -92,7 +92,7 @@ void UITextField::ProcessArrow(unsigned short mask) {
case EPBM_RIGHT:
if (currentChar_ < len - 1) {
currentChar_++;
} else if (currentChar_ < 39) {
} else if (currentChar_ < MAX_PROJECT_NAME_LENGTH - 1) {
currentChar_++;
name[currentChar_] = 'A';
name[currentChar_ + 1] = '\0';
Expand All @@ -105,7 +105,9 @@ void UITextField::ProcessArrow(unsigned short mask) {
};
};

etl::string<40> UITextField::GetString() { return src_->GetString(); };
etl::string<MAX_PROJECT_NAME_LENGTH> UITextField::GetString() {
return src_->GetString();
};

char getNext(char c, bool reverse) {
// Valid characters in order
Expand Down
2 changes: 1 addition & 1 deletion sources/Application/Views/BaseClasses/UITextField.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class UITextField : public UIField, public Observable {
void ProcessArrow(unsigned short mask);
void OnClick();
void OnEditClick();
etl::string<40> GetString();
etl::string<MAX_PROJECT_NAME_LENGTH> GetString();

private:
int selected_;
Expand Down
5 changes: 3 additions & 2 deletions usermanual/content/pages/projects.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ You can ***explicitly*** save the current project by pressing [SAVE] on the proj
- **New** *REPLACE* the current project with a new, *Blank* project.
- **Random** *RENAME* the current project with a new, *Randomly generated* name.

The project name is **limited to 12 characters**.
The project name is **limited to 16 characters**.

You edit to project name by moving onto the name field and then holding the `ENTER` key while using the `UP` and `DOWN` keys to change the selected character and `LEFT` and `RIGHT` keys to move the cursor to the left or right of the current character. When on the last character, you can add chararacter to the end of the project name by using the `RIGHT` key.
You edit to project name by moving onto the name field and then holding the `ENTER` key while using the `UP` and `DOWN` keys to change the selected character and `LEFT` and `RIGHT` keys to move the cursor to the left or right of the current character. When on the last character, you can add chararacter to the end of the project name by using the `RIGHT` key.
To delete a character, select the character and press `EDIT`.