fix(color): Deleting empty label caused EM/Hang (#2392)
* If deleting a label, don't check size * If rename to blank, do nothing
This commit is contained in:
@@ -776,15 +776,17 @@ void ModelLabelsWindow::buildBody(FormWindow *window)
|
|||||||
strncpy(tmpLabel, oldLabel.c_str(), LABEL_LENGTH);
|
strncpy(tmpLabel, oldLabel.c_str(), LABEL_LENGTH);
|
||||||
tmpLabel[LABEL_LENGTH] = '\0';
|
tmpLabel[LABEL_LENGTH] = '\0';
|
||||||
new LabelDialog(this, tmpLabel, [=](std::string newLabel) {
|
new LabelDialog(this, tmpLabel, [=](std::string newLabel) {
|
||||||
auto rndialog =
|
if(newLabel.size() > 0) {
|
||||||
new ProgressDialog(this, STR_RENAME_LABEL, [=]() {});
|
auto rndialog =
|
||||||
modelslabels.renameLabel(
|
new ProgressDialog(this, STR_RENAME_LABEL, [=]() {});
|
||||||
oldLabel, newLabel, [=](const char *name, int percentage) {
|
modelslabels.renameLabel(
|
||||||
rndialog->updateProgress(name, percentage);
|
oldLabel, newLabel, [=](const char *name, int percentage) {
|
||||||
});
|
rndialog->updateProgress(name, percentage);
|
||||||
auto labels = getLabels();
|
});
|
||||||
lblselector->setNames(labels);
|
auto labels = getLabels();
|
||||||
updateFilteredLabels(modelslabels.filteredLabels(), false);
|
lblselector->setNames(labels);
|
||||||
|
updateFilteredLabels(modelslabels.filteredLabels(), false);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
return 0;
|
return 0;
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -616,15 +616,19 @@ bool ModelMap::renameLabel(const std::string &from, std::string to,
|
|||||||
if (from == "") return true;
|
if (from == "") return true;
|
||||||
DEBUG_TIMER_START(debugTimerYamlScan);
|
DEBUG_TIMER_START(debugTimerYamlScan);
|
||||||
|
|
||||||
// Limit max label name. TODO: Warn user they entered too long of a string
|
if(to.size() > 0) { // Ignore check if deleting a label, size will be zero
|
||||||
to = to.substr(0, LABEL_LENGTH);
|
to = to.substr(0, LABEL_LENGTH); // Limit max label name. TODO: Warn user they entered too long of a string
|
||||||
removeYAMLChars(to);
|
removeYAMLChars(to); // Remove special chars
|
||||||
if(to.size() == 0) return true;
|
if(to.size() == 0 || from == to) { // Abort rename if no chars left or same
|
||||||
|
if (progress != nullptr) progress("", 100); // Kill progress dialog
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ModelData *modeldata = (ModelData *)malloc(sizeof(ModelData));
|
ModelData *modeldata = (ModelData *)malloc(sizeof(ModelData));
|
||||||
if (!modeldata) {
|
if (!modeldata) {
|
||||||
TRACE("Labels: Out Of Memory");
|
TRACE("Labels: Out Of Memory");
|
||||||
|
if (progress != nullptr) progress("", 100); // Kill progress dialog
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user