Skip to content

Commit

Permalink
Undo delayed setting of representedFilename
Browse files Browse the repository at this point in the history
Back out change d9d383, which delayed setting of the filename
to help address Bug#18757 (or similar problems.)

Fixes a bug where second frames showing a different file did
not get a file icon, as sendEvent was not (no longer) called
for each frame right after the filename was set in the
global/static variable introduced to pass the filename.

No flicker observed.
  • Loading branch information
davidswelt committed Nov 27, 2015
1 parent cbfe25d commit 403fd18
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 24 deletions.
2 changes: 1 addition & 1 deletion src/nsfns.m
Original file line number Diff line number Diff line change
Expand Up @@ -620,7 +620,7 @@ Turn the input menu (an NSMenu) into a lisp list for tracking on lisp side
else
fstr = @"";

ns_set_represented_filename (fstr, f);
ns_set_represented_filename(fstr, f);
[[view window] setTitle: str];
fset_name (f, name);
}
Expand Down
36 changes: 13 additions & 23 deletions src/nsterm.m
Original file line number Diff line number Diff line change
Expand Up @@ -329,9 +329,6 @@ - (NSColor *)colorUsingDefaultColorSpace
NULL, 0, 0
};

static NSString *represented_filename = nil;
static struct frame *represented_frame = 0;

#ifdef NS_IMPL_COCOA
/*
* State for pending menu activation:
Expand Down Expand Up @@ -443,10 +440,20 @@ - (NSColor *)colorUsingDefaultColorSpace
========================================================================== */

void
ns_set_represented_filename (NSString* fstr, struct frame *f)
ns_set_represented_filename (NSString* filename, struct frame *f)
{
represented_filename = [fstr retain];
represented_frame = f;
if (filename != nil && f)
{
NSView *view = FRAME_NS_VIEW (f);
#ifdef NS_IMPL_COCOA
/* work around a bug observed on 10.3 and later where
setTitleWithRepresentedFilename does not clear out previous state
if given filename does not exist */
if (! [[NSFileManager defaultManager] fileExistsAtPath: filename])
[[view window] setRepresentedFilename: @""];
#endif
[[view window] setRepresentedFilename: filename];
}
}

void
Expand Down Expand Up @@ -5255,23 +5262,6 @@ - (void)sendEvent: (NSEvent *)theEvent
}
#endif

if (represented_filename != nil && represented_frame)
{
NSString *fstr = represented_filename;
NSView *view = FRAME_NS_VIEW (represented_frame);
#ifdef NS_IMPL_COCOA
/* work around a bug observed on 10.3 and later where
setTitleWithRepresentedFilename does not clear out previous state
if given filename does not exist */
if (! [[NSFileManager defaultManager] fileExistsAtPath: fstr])
[[view window] setRepresentedFilename: @""];
#endif
[[view window] setRepresentedFilename: fstr];
[represented_filename release];
represented_filename = nil;
represented_frame = NULL;
}

if (type == NSApplicationDefined)
{
switch ([theEvent data2])
Expand Down

0 comments on commit 403fd18

Please sign in to comment.