fix(color): Bitmap name truncation if exactly 14 characters long (#4232)
Co-authored-by: Peter Feerick <peter.feerick@gmail.com>
This commit is contained in:
@@ -66,19 +66,16 @@ struct ModelNameEdit : public ModelTextEdit {
|
||||
|
||||
static std::string getModelBitmap()
|
||||
{
|
||||
return std::string(g_model.header.bitmap, sizeof(g_model.header.bitmap));
|
||||
return std::string(g_model.header.bitmap, LEN_BITMAP_NAME);
|
||||
}
|
||||
|
||||
static void setModelBitmap(std::string newValue)
|
||||
{
|
||||
strncpy(g_model.header.bitmap, newValue.c_str(),
|
||||
sizeof(g_model.header.bitmap));
|
||||
g_model.header.bitmap[sizeof(g_model.header.bitmap)-1] = '\0';
|
||||
strncpy(g_model.header.bitmap, newValue.c_str(), LEN_BITMAP_NAME);
|
||||
auto model = modelslist.getCurrentModel();
|
||||
if (model) {
|
||||
strncpy(model->modelBitmap, newValue.c_str(),
|
||||
sizeof(ModelCell::modelBitmap));
|
||||
model->modelBitmap[sizeof(ModelCell::modelBitmap)-1] = '\0';
|
||||
strncpy(model->modelBitmap, newValue.c_str(), LEN_BITMAP_NAME);
|
||||
model->modelBitmap[LEN_BITMAP_NAME] = '\0';
|
||||
}
|
||||
SET_DIRTY();
|
||||
}
|
||||
@@ -86,7 +83,7 @@ static void setModelBitmap(std::string newValue)
|
||||
struct ModelBitmapEdit : public FileChoice {
|
||||
ModelBitmapEdit(Window *parent, const rect_t &rect) :
|
||||
FileChoice(parent, rect, BITMAPS_PATH, BITMAPS_EXT,
|
||||
sizeof(g_model.header.bitmap), getModelBitmap, setModelBitmap)
|
||||
LEN_BITMAP_NAME, getModelBitmap, setModelBitmap)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
@@ -363,12 +363,14 @@ void RadioSdManagerPage::fileAction(const char* path, const char* name,
|
||||
MultiFirmwareUpdate(fullpath, EXTERNAL_MODULE, MULTI_TYPE_ELRS);
|
||||
});
|
||||
} else if (!strcasecmp(BITMAPS_PATH, path) &&
|
||||
isExtensionMatching(ext, BITMAPS_EXT)) {
|
||||
isExtensionMatching(ext, BITMAPS_EXT) &&
|
||||
strlen(name) <= LEN_BITMAP_NAME) {
|
||||
menu->addLine(STR_ASSIGN_BITMAP, [=]() {
|
||||
memcpy(g_model.header.bitmap, name, sizeof(g_model.header.bitmap));
|
||||
memcpy(g_model.header.bitmap, name, LEN_BITMAP_NAME);
|
||||
storageDirty(EE_MODEL);
|
||||
});
|
||||
} else if (!strcasecmp(ext, TEXT_EXT) || !strcasecmp(ext, LOGS_EXT) || !strcasecmp(ext, SCRIPT_EXT)) {
|
||||
} else if (!strcasecmp(ext, TEXT_EXT) || !strcasecmp(ext, LOGS_EXT) ||
|
||||
!strcasecmp(ext, SCRIPT_EXT)) {
|
||||
menu->addLine(STR_VIEW_TEXT, [=]() {
|
||||
FIL file;
|
||||
if (FR_OK == f_open(&file, fullpath, FA_OPEN_EXISTING | FA_READ)) {
|
||||
|
||||
@@ -97,7 +97,7 @@ class ModelBitmapWidget: public Widget
|
||||
|
||||
uint32_t getHash()
|
||||
{
|
||||
return hash(g_model.header.bitmap, sizeof(g_model.header.bitmap));
|
||||
return hash(g_model.header.bitmap, LEN_BITMAP_NAME);
|
||||
}
|
||||
|
||||
void loadBitmap()
|
||||
|
||||
Reference in New Issue
Block a user