From bf981aac891ebdbe287faaf5fceaaf734e58b053 Mon Sep 17 00:00:00 2001 From: Thurston Yates Date: Sat, 9 Nov 2024 19:10:16 -0500 Subject: [PATCH 1/6] Make image_dsc a pointer Despite being breaking, this change is necessary to avoid dangling pointers --- include/robodash/views/image.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/robodash/views/image.hpp b/include/robodash/views/image.hpp index 824fc3e..404fc73 100644 --- a/include/robodash/views/image.hpp +++ b/include/robodash/views/image.hpp @@ -48,10 +48,10 @@ class Image { /** * @brief Create a new Image * - * @param image_dsc LVGL image descriptor object + * @param image_dsc Pointer to LVGL image descriptor object * @param name Name to display on screen */ - Image(lv_img_dsc_t image_dsc, std::string name = "Image"); + Image(lv_img_dsc_t &image_dsc, std::string name = "Image"); /** * @brief Set this view to the active view From c0a63a61c00358a61a78c5810545f07970497858 Mon Sep 17 00:00:00 2001 From: Thurston Yates Date: Sat, 9 Nov 2024 19:10:57 -0500 Subject: [PATCH 2/6] Fix constructor Remove unnecessary sd card requirement, fix dangling pointer --- src/robodash/views/image.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/robodash/views/image.cpp b/src/robodash/views/image.cpp index 99e6215..9f5fc61 100644 --- a/src/robodash/views/image.cpp +++ b/src/robodash/views/image.cpp @@ -3,12 +3,10 @@ // ============================= Core Functions ============================= // -rd::Image::Image(lv_img_dsc_t image_dsc, std::string name) { - if (!pros::usd::is_installed()) return; - +rd::Image::Image(lv_img_dsc_t &image_dsc, std::string name) { this->view = rd_view_create(name.c_str()); lv_obj_t *image = lv_img_create(view->obj); - lv_img_set_src(image, &image_dsc); + lv_img_set_src(image, image_dsc); lv_obj_align(image, LV_ALIGN_CENTER, 0, 0); rd_view_set_anims(this->view, RD_ANIM_OFF); } From 9556ef1579424cdb967f480d19fe7c881f72ef5a Mon Sep 17 00:00:00 2001 From: Thurston Yates Date: Sat, 9 Nov 2024 19:13:36 -0500 Subject: [PATCH 3/6] Update image example in docs --- docs/source/guides/usage/widgets.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/source/guides/usage/widgets.md b/docs/source/guides/usage/widgets.md index 6ba9872..9b5a989 100644 --- a/docs/source/guides/usage/widgets.md +++ b/docs/source/guides/usage/widgets.md @@ -71,13 +71,13 @@ convert the image to a C array and place it in your project's `src` directory, or convert it to a a binary file and load it onto a microSD card. To create an image, we can construct it with a path to an LVGL-converted -`image.bin` file on a loaded SD card, or to an LVGL image variable. You also -must pass a name to the image. +`image.bin` file on a loaded SD card, or a pointer to an LVGL image variable. +You also must pass a name to the image. ```cpp // microSD approach rd::Image image1("S:/usd/logo.bin", "Team Logo"); // C array approach -rd::Image image2(team_logo, "Team Logo") +rd::Image image2(&team_logo, "Team Logo") ``` From d97d879d7673481ce0ae021a5d923032857e7951 Mon Sep 17 00:00:00 2001 From: Thurston Yates Date: Sat, 9 Nov 2024 19:22:39 -0500 Subject: [PATCH 4/6] Update changelog with fix --- CHANGELOG.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 988cbc0..4c48625 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,21 @@ Changes to this project will be logged in this file. This project uses [Semantic Versioning](https://semver.org/spec/v2.0.0.html). Format is loosely based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/). +# 2.1.2 + +Robodash 2.1.2 provides a fix for the image widget. + +> [!WARNING] This update has a breaking change +> +> When constructing an `rd::Image` with a C array, you must pass a pointer to +> your `lv_img_dsc_t` instead of a reference. This is to prevent a dangling +> pointer. + +### Fixed + +- A bug where constructing an `rd::Image` with a C array would not display the + image. + ## 2.1.1 Robodash 2.1.1 is a recompilation of 2.1.0 that upgrades to PROS version 4.1.0 From 8748c074318afdc22d74cba4060b089e0fbd097b Mon Sep 17 00:00:00 2001 From: Thurston Yates Date: Sat, 9 Nov 2024 19:24:31 -0500 Subject: [PATCH 5/6] Bump version --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index b426dac..9378e92 100644 --- a/Makefile +++ b/Makefile @@ -26,7 +26,7 @@ EXCLUDE_COLD_LIBRARIES:= # Set this to 1 to add additional rules to compile your project as a PROS library template IS_LIBRARY:=1 LIBNAME:=robodash -VERSION:=2.1.1 +VERSION:=2.1.2 # EXCLUDE_SRC_FROM_LIB= $(SRCDIR)/unpublishedfile.c # this line excludes opcontrol.c and similar files From a1c33717b5ff934670d75cbbf5b828cd653d6c6a Mon Sep 17 00:00:00 2001 From: Thurston Yates Date: Sat, 9 Nov 2024 19:29:44 -0500 Subject: [PATCH 6/6] Use pointers, not references Bruh moment --- include/robodash/views/image.hpp | 2 +- src/robodash/views/image.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/include/robodash/views/image.hpp b/include/robodash/views/image.hpp index 404fc73..2d059c4 100644 --- a/include/robodash/views/image.hpp +++ b/include/robodash/views/image.hpp @@ -51,7 +51,7 @@ class Image { * @param image_dsc Pointer to LVGL image descriptor object * @param name Name to display on screen */ - Image(lv_img_dsc_t &image_dsc, std::string name = "Image"); + Image(lv_img_dsc_t *image_dsc, std::string name = "Image"); /** * @brief Set this view to the active view diff --git a/src/robodash/views/image.cpp b/src/robodash/views/image.cpp index 9f5fc61..05e9955 100644 --- a/src/robodash/views/image.cpp +++ b/src/robodash/views/image.cpp @@ -3,7 +3,7 @@ // ============================= Core Functions ============================= // -rd::Image::Image(lv_img_dsc_t &image_dsc, std::string name) { +rd::Image::Image(lv_img_dsc_t *image_dsc, std::string name) { this->view = rd_view_create(name.c_str()); lv_obj_t *image = lv_img_create(view->obj); lv_img_set_src(image, image_dsc);