From 091da296c4a4b3461bdd87573ca421e8c99786ec Mon Sep 17 00:00:00 2001 From: Brahim Hadriche Date: Tue, 21 Oct 2025 16:52:41 -0400 Subject: [PATCH] Fix crash when trying to display error messages with very long text --- CHANGELOG.md | 4 +++- playlet-lib/src/components/Dialog/DialogUtils.bs | 11 ++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3c879ee4..1dff01e9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] -- Nothing worth mentioning yet. +### Fixed + +- Crash when trying to display error messages with very long text ## [0.42.4] - 2025-10-17 diff --git a/playlet-lib/src/components/Dialog/DialogUtils.bs b/playlet-lib/src/components/Dialog/DialogUtils.bs index e649d637..ed9af62a 100644 --- a/playlet-lib/src/components/Dialog/DialogUtils.bs +++ b/playlet-lib/src/components/Dialog/DialogUtils.bs @@ -5,6 +5,9 @@ import "pkg:/source/utils/Types.bs" namespace DialogUtils + ' Very large messages can lead to execution timeout + const MESSAGE_LENGTH_LIMIT = 1000 + function ShowDialogEx(options as object) as object currentDialog = m.top.getScene().dialog alwaysOnTop = false @@ -24,6 +27,9 @@ namespace DialogUtils if options.DoesExist("message") message = options.message if IsString(message) + if message.Len() > MESSAGE_LENGTH_LIMIT + message = message.Left(MESSAGE_LENGTH_LIMIT) + "..." + end if message = message.Tokenize(`\n`).ToArray() end if dialog.message = message @@ -82,7 +88,10 @@ namespace DialogUtils end if dialog = CreateObject("roSGNode", "TimedDialog") - if GetInterface(message, "ifArray") = invalid + if IsString(message) + if message.Len() > MESSAGE_LENGTH_LIMIT + message = message.Left(MESSAGE_LENGTH_LIMIT) + "..." + end if message = message.Tokenize(`\n`).ToArray() end if dialog.message = message