Skip to content

Commit

Permalink
Fix all Xcode10 warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
typcn committed Sep 29, 2018
1 parent 893c9c9 commit ec27aed
Show file tree
Hide file tree
Showing 19 changed files with 127 additions and 127 deletions.
2 changes: 1 addition & 1 deletion BarrageRenderer/BarrageEngine/BarrageRenderer.m
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ - (void)initClock
__weak id weakSelf = self;
_clock = [BarrageClock clockWithHandler:^(NSTimeInterval time){
BarrageRenderer * strongSelf = weakSelf;
_time = time;
self->_time = time;
[strongSelf update];
}];
}
Expand Down
12 changes: 6 additions & 6 deletions BarrageRenderer/NHDisplayLink.m
Original file line number Diff line number Diff line change
Expand Up @@ -85,27 +85,27 @@ - (void)setDispatchQueue:(dispatch_queue_t)dispatchQueue {

- (void)start {
dispatch_async(_stateChangeQueue, ^{
if (_isRunning)
if (self->_isRunning)
return;

_isRunning = true;
self->_isRunning = true;

// We CFRetain self while the displaylink thread is active, to ensure it
// always has a valid 'self' pointer. The CFRetain is undone by [1].
CFRetain((__bridge CFTypeRef)self);

CVDisplayLinkStart(_displayLink);
CVDisplayLinkStart(self->_displayLink);
});
}

- (void)stop {
dispatch_async(_stateChangeQueue, ^{
if (!_isRunning)
if (!self->_isRunning)
return;

_isRunning = false;
self->_isRunning = false;
// The displaylink thread resumes the queue at [2]
dispatch_suspend(_stateChangeQueue);
dispatch_suspend(self->_stateChangeQueue);
});
}

Expand Down
2 changes: 1 addition & 1 deletion bilibili/Browser/AddressBar.m
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ - (void)updateSuggestContext{

- (BOOL)textShouldEndEditing:(NSText *)textObject{
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[ASTable removeFromSuperview];
[self->ASTable removeFromSuperview];
});
isEditing = false;
return YES;
Expand Down
10 changes: 5 additions & 5 deletions bilibili/Browser/AutoSuggestTable.m
Original file line number Diff line number Diff line change
Expand Up @@ -130,13 +130,13 @@ - (void)loadOnlineResultAsync:(NSTableView *)tv{
/* Start a new Task */
NSURLSessionDataTask* task = [session dataTaskWithRequest:request completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error == nil) {
if([currentKey isEqualToString:online_cache_key]){
if([currentKey isEqualToString:self->online_cache_key]){
NSError *err;
NSDictionary *dic = [NSJSONSerialization JSONObjectWithData:data options:0 error:&err];
if(err || !dic){
return;
}
online_cache = [[NSMutableArray alloc] init];
self->online_cache = [[NSMutableArray alloc] init];
// FXXK Objective-C JSON processing
@try {
if(dic[@"result"]){
Expand All @@ -146,7 +146,7 @@ - (void)loadOnlineResultAsync:(NSTableView *)tv{
for(int i = 0; i < [b count]; i++){
NSString *bgmName = [b objectAtIndex:i][@"value"];
if(bgmName){
[online_cache addObject:bgmName];
[self->online_cache addObject:bgmName];
}
}
}
Expand All @@ -157,7 +157,7 @@ - (void)loadOnlineResultAsync:(NSTableView *)tv{
for(int i = 0; i < [tags count]; i++){
NSString *tagName = [tags objectAtIndex:i][@"value"];
if(tagName){
[online_cache addObject:tagName];
[self->online_cache addObject:tagName];
}
}
}
Expand All @@ -166,7 +166,7 @@ - (void)loadOnlineResultAsync:(NSTableView *)tv{
}@catch ( NSException *e ) {
NSLog(@"[AddressBar] Ignore json read exception %@",e);
}
NSLog(@"[AddressBar] Online Suggest Load Succeeded with %lu object",(unsigned long)[online_cache count]);
NSLog(@"[AddressBar] Online Suggest Load Succeeded with %lu object",(unsigned long)[self->online_cache count]);
dispatch_async(dispatch_get_main_queue(), ^(void){
if(tv){
[tv reloadData];
Expand Down
2 changes: 1 addition & 1 deletion bilibili/Browser/ToolBar.m
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ - (id)init{
}


- (void)finalize {
- (void)dealloc {
[[NSNotificationCenter defaultCenter] removeObserver:self];
}

Expand Down
2 changes: 1 addition & 1 deletion bilibili/Browser/WebTabView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ -(void)viewFrameDidChange:(NSRect)newFrame {
dispatch_async(dispatch_get_global_queue(0, 0), ^(void){
[[NSUserDefaults standardUserDefaults] setDouble:frame.size.width forKey:@"webwidth"];
[[NSUserDefaults standardUserDefaults] setDouble:frame.size.height forKey:@"webheight"];
pm = [PluginManager sharedInstance];
self->pm = [PluginManager sharedInstance];
});
}

Expand Down
2 changes: 1 addition & 1 deletion bilibili/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@
</dict>
</array>
<key>CFBundleVersion</key>
<string>3546</string>
<string>3551</string>
<key>Fabric</key>
<dict>
<key>APIKey</key>
Expand Down
16 changes: 8 additions & 8 deletions bilibili/LiveChat/BilibiliSocketProvider.m
Original file line number Diff line number Diff line change
Expand Up @@ -58,17 +58,17 @@ - (void)loadWithPlayer: (id)player{
if(range.length > 0){
NSString *server = [resp substringWithRange:range];
NSLog(@"[LiveComment] Found server: %@",server);
host = server;
self->host = server;
[self connect];
}
}else{
NSLog(@"[LiveComment] Failed with status Code %d",code);
[delegate onNewError:@"无法获取服务器地址"];
[self->delegate onNewError:@"无法获取服务器地址"];
}
}
else {
NSLog(@"[LiveComment] Failed to request server url: %@", [error localizedDescription]);
[delegate onNewError:@"无法连接到 API"];
[self->delegate onNewError:@"无法连接到 API"];
}
}];

Expand Down Expand Up @@ -133,11 +133,11 @@ - (void)reconnect {

- (void)doRecv {
dispatch_async(dispatch_get_global_queue(0, 0), ^(void){
while (!disconnected) {
while (!self->disconnected) {
uint8_t buf[1024];
[lock lock];
ssize_t recvlen = recv(sockfd, buf, 1024, 0);
[lock unlock];
[self->lock lock];
ssize_t recvlen = recv(self->sockfd, buf, 1024, 0);
[self->lock unlock];
if(recvlen == 0){
[self reconnect];
return;
Expand All @@ -149,7 +149,7 @@ - (void)doRecv {
return;
}

[mBuf appendBytes:buf length:recvlen];
[self->mBuf appendBytes:buf length:recvlen];
[self checkData];
}
});
Expand Down
4 changes: 2 additions & 2 deletions bilibili/LiveChat/LiveChat.m
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ - (void)viewDidLoad {
- (void)onNewMessage:(NSString *)cmContent :(NSString *)userName :(int)ftype :(int)fsize :(NSColor *)color{
dispatch_async(dispatch_get_main_queue(), ^(void){
bool isBlocked = false;
if([blockwords count] > 0){
for (NSString* string in blockwords) {
if([self->blockwords count] > 0){
for (NSString* string in self->blockwords) {
if([cmContent containsString:string]){
isBlocked = true;
}
Expand Down
2 changes: 1 addition & 1 deletion bilibili/Notifications/Popover.m
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ - (id)init{

- (void)startMonitor{
monitor = [NSEvent addGlobalMonitorForEventsMatchingMask:NSLeftMouseDownMask | NSRightMouseDownMask handler:^(NSEvent* evt){
if(popover.shown){
if(self->popover.shown){
[self hidePopover:evt];
}
}];
Expand Down
62 changes: 31 additions & 31 deletions bilibili/Player/Control/PlayerControlView.m
Original file line number Diff line number Diff line change
Expand Up @@ -286,47 +286,47 @@ - (IBAction)rightTextSwitch:(id)sender {

- (void)onVolume:(double)volume{
dispatch_async(dispatch_get_main_queue(), ^(void){
volumeSlider.doubleValue = volume;
self->volumeSlider.doubleValue = volume;
});
}

- (void)onDuration:(double)duration{
dispatch_async(dispatch_get_main_queue(), ^(void){
timeSlider.maxValue = duration;
rightTimeText.stringValue = [self timeFormatted:duration];
v_duration = duration;
self->timeSlider.maxValue = duration;
self->rightTimeText.stringValue = [self timeFormatted:duration];
self->v_duration = duration;
});
}

- (void)onPlaybackTime:(double)t{
dispatch_async(dispatch_get_main_queue(), ^(void){
timeSlider.doubleValue = t;
timeText.stringValue = [self timeFormatted:t];
v_playback_time = t;
self->timeSlider.doubleValue = t;
self->timeText.stringValue = [self timeFormatted:t];
self->v_playback_time = t;
});
}

- (void)onCacheSize:(double)t{
dispatch_async(dispatch_get_main_queue(), ^(void){
if(t > 0){
int sizeMB = t/1024;
rightTimeText.stringValue = [NSString stringWithFormat:@"%d MB",sizeMB];
if(sizeMB > 10 && !isFirstBuffed){
isFirstBuffed = YES;
isShowingDuration = YES;
self->rightTimeText.stringValue = [NSString stringWithFormat:@"%d MB",sizeMB];
if(sizeMB > 10 && !self->isFirstBuffed){
self->isFirstBuffed = YES;
self->isShowingDuration = YES;
}
}
});
}

- (void)onCacheFillRate:(double)t{
dispatch_async(dispatch_get_main_queue(), ^(void){
if(t > 0 && v_duration > 0){
double playbackRate = (v_playback_time / v_duration)*100;
if(t > 0 && self->v_duration > 0){
double playbackRate = (self->v_playback_time / self->v_duration)*100;
double allRate = playbackRate + t;
if(allRate > 90){
rightTimeText.stringValue = @"缓冲完成";
isShowingDuration = YES;
self->rightTimeText.stringValue = @"缓冲完成";
self->isShowingDuration = YES;
}
}
});
Expand All @@ -336,35 +336,35 @@ - (void)onCacheFillRate:(double)t{
- (void)onPaused:(int)isPaused{
dispatch_async(dispatch_get_main_queue(), ^(void){
if(isPaused){
currentPaused = YES;
playPauseButton.state = NSOffState;
self->currentPaused = YES;
self->playPauseButton.state = NSOffState;
}else{
currentPaused = NO;
playPauseButton.state = NSOnState;
self->currentPaused = NO;
self->playPauseButton.state = NSOnState;
}
});
}

- (void)onMuted:(int)isMuted{
dispatch_async(dispatch_get_main_queue(), ^(void){
if(isMuted){
currentMuted = YES;
muteButton.state = NSOnState;
self->currentMuted = YES;
self->muteButton.state = NSOnState;
}else{
currentMuted = NO;
muteButton.state = NSOffState;
self->currentMuted = NO;
self->muteButton.state = NSOffState;
}
});
}

- (void)onSubVisibility:(int)vis{
dispatch_async(dispatch_get_main_queue(), ^(void){
if(vis){
currentSubVis = YES;
subVisButton.state = NSOffState;
self->currentSubVis = YES;
self->subVisButton.state = NSOffState;
}else{
currentSubVis = NO;
subVisButton.state = NSOnState;
self->currentSubVis = NO;
self->subVisButton.state = NSOnState;
}
});
}
Expand All @@ -380,11 +380,11 @@ - (void)onKeepAspect:(int)keep{
[videoView setFrame:rect];

if(keep){
isKeepAspect = YES;
keepAspectButton.state = NSOffState;
self->isKeepAspect = YES;
self->keepAspectButton.state = NSOffState;
}else{
isKeepAspect = NO;
keepAspectButton.state = NSOnState;
self->isKeepAspect = NO;
self->keepAspectButton.state = NSOnState;
}
});
}
Expand Down
16 changes: 8 additions & 8 deletions bilibili/Player/PlayerLoader.m
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,10 @@ - (void)loadVideo:(VideoAddress *)video withAttrs:(NSDictionary *)attrs{
}
dispatch_async(vl_queue, ^(void){
NSDictionary *_attrs = attrs;
BOOL haveSub = [subHelper canHandle:_attrs];
BOOL haveSub = [self->subHelper canHandle:_attrs];
if(haveSub){
[self setText:@"正在下载弹幕/字幕"];
_attrs = [subHelper getSubtitle:attrs];
_attrs = [self->subHelper getSubtitle:attrs];
}
dispatch_async(dispatch_get_main_queue(), ^(void){
[self _loadVideo:video withAttrs:_attrs];
Expand Down Expand Up @@ -163,17 +163,17 @@ - (void)_loadVideo:(VideoAddress *)video withAttrs:(NSDictionary *)attrs{

- (void)showError:(NSString *)title :(NSString *)desc{
dispatch_async(dispatch_get_main_queue(), ^(void){
hud.mode = MBProgressHUDModeText;
hud.labelText = NSLocalizedString(title, nil);
hud.detailsLabelText = NSLocalizedString(desc, nil);
self->hud.mode = MBProgressHUDModeText;
self->hud.labelText = NSLocalizedString(title, nil);
self->hud.detailsLabelText = NSLocalizedString(desc, nil);
[self hide:3.0];
});
}

- (void)setText:(NSString *)text{
dispatch_async(dispatch_get_main_queue(), ^(void){
[self show];
hud.labelText = NSLocalizedString(text, nil);
self->hud.labelText = NSLocalizedString(text, nil);
});
}

Expand All @@ -192,7 +192,7 @@ - (void)show{

- (void)hide:(NSTimeInterval)i{
dispatch_async(dispatch_get_main_queue(), ^(void){
[hud hide:YES afterDelay:i];
[self->hud hide:YES afterDelay:i];
[NSTimer scheduledTimerWithTimeInterval:i+0.5
target:self
selector:@selector(hideWindow)
Expand Down Expand Up @@ -258,4 +258,4 @@ - (void)drawRect:(NSRect)rect
//NSRectFill([selfframe]);
}

@end
@end
Loading

0 comments on commit ec27aed

Please sign in to comment.