From 756f721cb648231cd11a2490c2ba65e18a9e5edb Mon Sep 17 00:00:00 2001 From: Sajid Anwar Date: Wed, 18 Jun 2014 15:41:12 -0700 Subject: [PATCH] Simple fix to prevent null reference error in main JS, see #196 --- radiant-player-mac/AppDelegate.m | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/radiant-player-mac/AppDelegate.m b/radiant-player-mac/AppDelegate.m index f74aec37..5da860e5 100644 --- a/radiant-player-mac/AppDelegate.m +++ b/radiant-player-mac/AppDelegate.m @@ -652,9 +652,13 @@ - (void)webView:(WebView *)webView didClearWindowObject:(WebScriptObject *)windo - (void)webView:(WebView *)sender didFinishLoadForFrame:(WebFrame *)frame { + // Only apply the main script file when the player is ready. + if ([[webView mainFrameDocument] querySelector:@"#playerSongInfo"]) { + [self evaluateJavaScriptFile:@"main"]; + } + [self evaluateJavaScriptFile:@"keyboard"]; [self evaluateJavaScriptFile:@"mouse"]; - [self evaluateJavaScriptFile:@"main"]; [self evaluateJavaScriptFile:@"styles"]; // Apply the navigation styles.