Skip to content

Commit f417361

Browse files
author
Monte Goulding
committed
[[ DocumentFilename ]] Init to empty string
1 parent 03ef0c3 commit f417361

File tree

6 files changed

+16
-14
lines changed

6 files changed

+16
-14
lines changed

docs/dictionary/property/documentFilename.lcdoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Type: property
44

55
Syntax: set the documentFilename of <stack> to <filename>
66

7-
Summary: Specifies the file path to the file that the stack is represents.
7+
Summary: Specifies the file path to the file that the stack represents.
88

99
Associations: stack
1010

engine/src/desktop-stack.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,8 +217,7 @@ void MCStack::realize(void)
217217
resetcursor(True);
218218

219219
// MERG-2015-10-11: [[ DocumentFilename ]] update the window with the document filename property
220-
if (m_document_filename != nil)
221-
MCPlatformSetWindowProperty(t_window, kMCPlatformWindowPropertyDocumentFilename, kMCPlatformPropertyTypeMCString, &m_document_filename);
220+
MCPlatformSetWindowProperty(t_window, kMCPlatformWindowPropertyDocumentFilename, kMCPlatformPropertyTypeMCString, &m_document_filename);
222221
}
223222

224223
start_externals();

engine/src/exec-interface-stack.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2187,17 +2187,18 @@ void MCStack::SetScriptOnly(MCExecContext& ctxt, bool p_script_only)
21872187
// MERG-2015-10-11: [[ DocumentFilename ]] Add stack documentFilename property
21882188
void MCStack::GetDocumentFilename(MCExecContext &ctxt, MCStringRef& r_document_filename)
21892189
{
2190-
if (m_document_filename == nil)
2191-
return;
2192-
21932190
r_document_filename = MCValueRetain(m_document_filename);
21942191
}
21952192

21962193
void MCStack::SetDocumentFilename(MCExecContext &ctxt, MCStringRef p_document_filename)
21972194
{
21982195
MCStringRef t_resolved_filename;
21992196

2200-
if (!MCS_resolvepath(p_document_filename, t_resolved_filename))
2197+
if (MCStringIsEmpty(p_document_filename))
2198+
{
2199+
t_resolved_filename = p_document_filename;
2200+
}
2201+
else if (!MCS_resolvepath(p_document_filename, t_resolved_filename))
22012202
{
22022203
ctxt . LegacyThrow(EE_DOCUMENTFILENAME_BADFILENAME);
22032204
return;

engine/src/mac-window.mm

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1898,8 +1898,7 @@ - (void)setFrameSize: (NSSize)size
18981898
[m_window_handle setHidesOnDeactivate: m_hides_on_suspend];
18991899

19001900
// MERG-2015-10-11: [[ DocumentFilename ]] Set documentFilename.
1901-
if (m_document_filename != nil)
1902-
UpdateDocumentFilename();
1901+
UpdateDocumentFilename();
19031902
}
19041903

19051904
void MCMacPlatformWindow::DoSynchronize(void)
@@ -2210,11 +2209,14 @@ bool MCMacDoUpdateRegionCallback(void *p_context, const MCRectangle &p_rect)
22102209
NSString * t_represented_filename;
22112210
t_represented_filename = nil;
22122211

2213-
if (m_document_filename != nil && MCS_pathtonative(m_document_filename, t_native_filename))
2212+
if (!MCStringIsEmpty(m_document_filename) && MCS_pathtonative(m_document_filename, t_native_filename))
22142213
{
22152214
t_represented_filename = [NSString stringWithMCStringRef: t_native_filename];
22162215
}
2216+
else
2217+
t_represented_filename = @"";
22172218

2219+
// It appears setRepresentedFilename can't be set to nil
22182220
[m_window_handle setRepresentedFilename: t_represented_filename];
22192221
}
22202222

engine/src/platform-window.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ MCPlatformWindow::MCPlatformWindow(void)
6767
m_is_opaque = true;
6868

6969
// MERG-2015-10-11: [[ DocumentFilename ]] documentFilename property
70-
m_document_filename = nil;
70+
m_document_filename = MCValueRetain(kMCEmptyString);
7171
}
7272

7373
MCPlatformWindow::~MCPlatformWindow(void)

engine/src/stack.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ MCStack::MCStack()
296296
m_purge_fonts = false;
297297

298298
// MERG-2015-10-11: [[ DocumentFilename ]] The filename the stack represnts
299-
m_document_filename = nil;
299+
m_document_filename = MCValueRetain(kMCEmptyString);
300300

301301
m_view_need_redraw = false;
302302
m_view_need_resize = false;
@@ -506,8 +506,8 @@ MCStack::MCStack(const MCStack &sref) : MCObject(sref)
506506

507507
m_attachments = nil;
508508

509-
// MERG-2015-10-100: [[ DocumentFilename ]] No document filename to begin with
510-
m_document_filename = nil;
509+
// MERG-2015-10-12: [[ DocumentFilename ]] No document filename to begin with
510+
m_document_filename = MCValueRetain(kMCEmptyString);
511511

512512
view_copy(sref);
513513
}

0 commit comments

Comments
 (0)