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

Commit 8cb200d

Browse files
author
runrevali
committed
Fix a couple of menu bugs; make sure empty strings are always THE empty string
1 parent 2339bdc commit 8cb200d

File tree

5 files changed

+21
-16
lines changed

5 files changed

+21
-16
lines changed

engine/src/desktop-ans.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ int MCA_folder(MCStringRef p_title, MCStringRef p_prompt, MCStringRef p_initial,
4848
MCAutoStringRef t_folder;
4949
for(;;)
5050
{
51-
MCValueRelease(*t_folder);
5251
t_result = MCPlatformEndFolderDialog(&t_folder);
5352
if (t_result != kMCPlatformDialogResultContinue)
5453
break;
@@ -57,9 +56,7 @@ int MCA_folder(MCStringRef p_title, MCStringRef p_prompt, MCStringRef p_initial,
5756
}
5857

5958
if (t_result == kMCPlatformDialogResultSuccess)
60-
r_result = MCValueRetain(*t_folder);
61-
else
62-
r_result = MCValueRetain(kMCEmptyString);
59+
r_value = MCValueRetain(*t_folder);
6360

6461
return 0;
6562
}

engine/src/desktop-pasteboard.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,6 @@ bool MCSystemPasteboard::Fetch(MCTransferType p_type, MCDataRef& r_data)
250250
/* UNCHECKED */ MCDataCreateWithBytesAndRelease((byte_t*)t_in_data_bytes, t_in_data_byte_count, &t_in_data);
251251

252252
MCAutoDataRef t_out_data;
253-
t_out_data = nil;
254253
switch(m_entries[t_entry] . flavor)
255254
{
256255
case kMCPlatformPasteboardFlavorUTF8:

engine/src/mac-dialog.mm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -612,7 +612,7 @@ MCPlatformDialogResult MCPlatformEndFileDialog(MCPlatformFileDialogKind p_kind,
612612
{
613613
/* UNCHECKED */ MCStringCreateWithCFString((CFStringRef)[s_dialog_nesting -> panel filename], r_paths);
614614
if (t_accessory != nil && [t_accessory currentType] != nil)
615-
/* UNCHECKED */ MCStringCreateWithCFString((CFStringRef)[t_accessory currentType], r_type);
615+
r_type = MCValueRetain([t_accessory currentType]);
616616
else
617617
r_type = nil;
618618
}
@@ -633,7 +633,7 @@ MCPlatformDialogResult MCPlatformEndFileDialog(MCPlatformFileDialogKind p_kind,
633633
[t_alias release];
634634
}
635635
if (t_accessory != nil && [t_accessory currentType] != nil)
636-
/* UNCHECKED */ MCStringCreateWithCFString((CFStringRef)[t_accessory currentType], r_type);
636+
r_type = MCValueRetain([t_accessory currentType]);
637637
else
638638
r_type = nil;
639639
}

engine/src/player.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1478,6 +1478,7 @@ bool MCPlayer::getversion(MCStringRef& r_string)
14781478
#ifdef FEATURE_PLATFORM_PLAYER
14791479
extern void MCQTGetVersion(MCStringRef &r_version);
14801480
MCQTGetVersion(r_string);
1481+
return true;
14811482
#else
14821483
#if defined(X11)
14831484

libfoundation/src/foundation-string.cpp

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4992,18 +4992,26 @@ static bool __MCStringCopyMutable(__MCString *self, __MCString*& r_new_string)
49924992
__MCString *t_string;
49934993
t_string = nil;
49944994

4995-
if (!__MCValueCreate(kMCValueTypeCodeString, t_string))
4996-
return false;
4997-
4998-
t_string -> char_count = self -> char_count;
4999-
if (MCStringIsNative(self))
5000-
t_string -> native_chars = self -> native_chars;
4995+
if (self -> char_count == 0)
4996+
{
4997+
t_string = MCValueRetain(kMCEmptyString);
4998+
MCMemoryDeleteArray(self -> native_chars);
4999+
}
50015000
else
50025001
{
5003-
t_string -> chars = self -> chars;
5004-
t_string -> flags |= kMCStringFlagIsNotNative;
5002+
if (!__MCValueCreate(kMCValueTypeCodeString, t_string))
5003+
return false;
5004+
5005+
t_string -> char_count = self -> char_count;
5006+
if (MCStringIsNative(self))
5007+
t_string -> native_chars = self -> native_chars;
5008+
else
5009+
{
5010+
t_string -> chars = self -> chars;
5011+
t_string -> flags |= kMCStringFlagIsNotNative;
5012+
}
5013+
t_string -> capacity = 0;
50055014
}
5006-
t_string -> capacity = 0;
50075015

50085016
self -> char_count = 0;
50095017
self -> chars = nil;

0 commit comments

Comments
 (0)