Skip to content
This repository was archived by the owner on Aug 31, 2021. It is now read-only.

Commit d345ee8

Browse files
committed
Merge remote-tracking branch 'origin/develop-8.1' into merge-develop-8.1_30.05.17
2 parents f5ce5aa + da34b44 commit d345ee8

File tree

3 files changed

+21
-10
lines changed

3 files changed

+21
-10
lines changed

docs/notes/bugfix-19730.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Fix resolution of relative paths of images in Mac standalones

engine/src/dskmac.cpp

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -916,14 +916,25 @@ static bool MCS_apply_redirect(MCStringRef p_path, bool p_is_file, MCStringRef&
916916

917917
// Construct the new path from the path after MacOS/ inside Resources/_macos.
918918
MCAutoStringRef t_new_path;
919-
MCRange t_cmd_range, t_path_range;
920-
t_cmd_range = MCRangeMake(0, t_engine_path_length - 6);
921-
t_path_range = MCRangeMake(t_engine_path_length + 1, UINDEX_MAX);
922-
923-
// AL-2014-09-19: Range argument to MCStringFormat is a pointer to an MCRange.
924-
/* UNCHECKED */ MCStringFormat(&t_new_path, "%*@/Resources/_MacOS%*@", &t_cmd_range, MCcmd, &t_path_range, p_path);
925-
926-
if (p_is_file && !MCS_file_exists_at_path(*t_new_path))
919+
MCRange t_cmd_range = MCRangeMake(0, t_engine_path_length - 6);
920+
uindex_t t_path_end = MCStringGetLength(p_path);
921+
bool t_success = true;
922+
923+
if (MCStringGetCodepointAtIndex(p_path, t_path_end) == '/')
924+
t_path_end--;
925+
926+
if (t_engine_path_length == t_path_end)
927+
{
928+
t_success = MCStringFormat(&t_new_path, "%*@/Resources/_MacOS", &t_cmd_range, MCcmd);
929+
}
930+
else
931+
{
932+
MCRange t_path_range = MCRangeMakeMinMax(t_engine_path_length + 1, t_path_end);
933+
// AL-2014-09-19: Range argument to MCStringFormat is a pointer to an MCRange.
934+
t_success = MCStringFormat(&t_new_path, "%*@/Resources/_MacOS/%*@", &t_cmd_range, MCcmd, &t_path_range, p_path);
935+
}
936+
937+
if (!t_success || (p_is_file && !MCS_file_exists_at_path(*t_new_path)))
927938
return false;
928939

929940
r_redirected = MCValueRetain(*t_new_path);

tests/lcs/core/files/files.livecodescript

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,7 @@ on TestSpecialFolderPath
127127
put specialFolderPath("resources") into tResources
128128
if the platform is "macos" and the environment is "standalone" then
129129
// Standalone on Mac have their non-executable resource in a specific folder
130-
set the itemDelimiter to slash
131-
TestAssert "Resources folder on standalone Mac app in is Resources/_MacOS", item -2 to -1 of tResources is "Resources/_MacOS"
130+
TestAssert "Resources folder on standalone Mac app in is Resources/_MacOS", tResources ends with "Resources/_MacOS"
132131
else if the environment is "mobile" then
133132
testAssert "Resources and Engine specialfolderPaths are the same on mobile", tResources is tEngine
134133
else

0 commit comments

Comments
 (0)