Skip to content

Commit

Permalink
Do not restart sessions without state. Fixes blinksh#427
Browse files Browse the repository at this point in the history
  • Loading branch information
yury committed Feb 3, 2018
1 parent 0fb7851 commit 09a04ba
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 9 deletions.
5 changes: 5 additions & 0 deletions Blink/TermController.m
Original file line number Diff line number Diff line change
Expand Up @@ -274,11 +274,16 @@ - (void)reload

- (void)suspend
{
[_sessionParameters cleanEncodedState];
[_session suspend];
}

- (void)resume
{
if (![_sessionParameters hasEncodedState]) {
return;
}

[self destroyPTY];
[self createPTY];
[self startSession];
Expand Down
6 changes: 1 addition & 5 deletions Sessions/MCPSession.m
Original file line number Diff line number Diff line change
Expand Up @@ -458,11 +458,7 @@ - (void)kill

- (void)suspend
{
if (_childSession == nil) {
[self out:@"\r\n".UTF8String];
} else {
[_childSession suspend];
}
[_childSession suspend];
}

@end
2 changes: 2 additions & 0 deletions Sessions/MCPSessionParameters.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,7 @@
@property NSString *fontName;
@property NSString *themeName;

- (BOOL)hasEncodedState;

@end

11 changes: 11 additions & 0 deletions Sessions/MCPSessionParameters.m
Original file line number Diff line number Diff line change
Expand Up @@ -78,5 +78,16 @@ + (BOOL)supportsSecureCoding
return YES;
}

- (BOOL)hasEncodedState
{
return _childSessionParameters.encodedState;
}

- (void)cleanEncodedState
{
[_childSessionParameters cleanEncodedState];
[super cleanEncodedState];
}

@end

1 change: 1 addition & 0 deletions Sessions/Session.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ typedef struct SessionParams {

@property (strong, atomic) SessionParameters *sessionParameters;
@property TermStream *stream;

@property (weak) NSObject<SessionDelegate>* delegate;

- (id)init __unavailable;
Expand Down
4 changes: 0 additions & 4 deletions Sessions/Session.m
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,4 @@ - (void)suspend
{
}

- (void)resume
{
}

@end
2 changes: 2 additions & 0 deletions Sessions/SessionParameters.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,6 @@

@interface SessionParameters: NSObject<NSSecureCoding>
@property NSData *encodedState;

- (void)cleanEncodedState;
@end
5 changes: 5 additions & 0 deletions Sessions/SessionParameters.m
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,9 @@ + (BOOL)supportsSecureCoding
return YES;
}

- (void)cleanEncodedState
{
_encodedState = nil;
}

@end

0 comments on commit 09a04ba

Please sign in to comment.