Android: Fix for uncaught java exception.

If an exception's getMessage() function returns a null object, we can't
send it directly to the Log function, as it will throw an exception...
To avoid this we can prepend the string from getMessage() with an empty
string.

Change-Id: Ie026cbf9af133352919a4536c152b6d35cb8c0a7
Reviewed-by: Paul Olav Tvete <paul.tvete@digia.com>
Reviewed-by: Yoann Lopes <yoann.lopes@digia.com>
This commit is contained in:
Christian Strømme
2013-06-13 15:42:12 +02:00
committed by The Qt Project
parent ccc4138304
commit 16a775d47a

View File

@@ -82,7 +82,7 @@ public class QtAndroidMediaPlayer extends MediaPlayer
try { try {
mApplicationContext = activity.getApplicationContext(); mApplicationContext = activity.getApplicationContext();
} catch(final Exception e) { } catch(final Exception e) {
Log.d(TAG, e.getMessage()); Log.d(TAG, "" + e.getMessage());
} }
} }
@@ -101,7 +101,7 @@ public class QtAndroidMediaPlayer extends MediaPlayer
currentPosition = getCurrentPosition(); currentPosition = getCurrentPosition();
} }
} catch (final InterruptedException e) { } catch (final InterruptedException e) {
Log.d(TAG, e.getMessage()); Log.d(TAG, "" + e.getMessage());
return; return;
} }
} }
@@ -262,7 +262,7 @@ public class QtAndroidMediaPlayer extends MediaPlayer
progressThread.start(); progressThread.start();
} catch (final IllegalStateException e) { } catch (final IllegalStateException e) {
reset(); reset();
Log.d(TAG, e.getMessage()); Log.d(TAG, "" + e.getMessage());
} }
} }
@@ -276,7 +276,7 @@ public class QtAndroidMediaPlayer extends MediaPlayer
super.pause(); super.pause();
} catch (final IllegalStateException e) { } catch (final IllegalStateException e) {
reset(); reset();
Log.d(TAG, e.getMessage()); Log.d(TAG, "" + e.getMessage());
} }
} }
@@ -289,7 +289,7 @@ public class QtAndroidMediaPlayer extends MediaPlayer
try { try {
super.stop(); super.stop();
} catch (final IllegalStateException e) { } catch (final IllegalStateException e) {
Log.d(TAG, e.getMessage()); Log.d(TAG, "" + e.getMessage());
} finally { } finally {
reset(); reset();
} }
@@ -305,7 +305,7 @@ public class QtAndroidMediaPlayer extends MediaPlayer
super.seekTo(msec); super.seekTo(msec);
onMediaPlayerInfoNative(MEDIA_PLAYER_PROGRESS, msec, mID); onMediaPlayerInfoNative(MEDIA_PLAYER_PROGRESS, msec, mID);
} catch (final IllegalStateException e) { } catch (final IllegalStateException e) {
Log.d(TAG, e.getMessage()); Log.d(TAG, "" + e.getMessage());
} }
} }
@@ -320,7 +320,7 @@ public class QtAndroidMediaPlayer extends MediaPlayer
try { try {
playing = super.isPlaying(); playing = super.isPlaying();
} catch (final IllegalStateException e) { } catch (final IllegalStateException e) {
Log.d(TAG, e.getMessage()); Log.d(TAG, "" + e.getMessage());
} }
return playing; return playing;
@@ -345,13 +345,13 @@ public class QtAndroidMediaPlayer extends MediaPlayer
/* MEDIA_ERROR_UNSUPPORTED= */ -1010, /* MEDIA_ERROR_UNSUPPORTED= */ -1010,
mID); mID);
} catch (final IllegalArgumentException e) { } catch (final IllegalArgumentException e) {
Log.d(TAG, e.getMessage()); Log.d(TAG, "" + e.getMessage());
} catch (final SecurityException e) { } catch (final SecurityException e) {
Log.d(TAG, e.getMessage()); Log.d(TAG, "" + e.getMessage());
} catch (final IllegalStateException e) { } catch (final IllegalStateException e) {
Log.d(TAG, e.getMessage()); Log.d(TAG, "" + e.getMessage());
} catch (final NullPointerException e) { } catch (final NullPointerException e) {
Log.d(TAG, e.getMessage()); Log.d(TAG, "" + e.getMessage());
} }
} }
@@ -366,7 +366,7 @@ public class QtAndroidMediaPlayer extends MediaPlayer
try { try {
currentPosition = super.getCurrentPosition(); currentPosition = super.getCurrentPosition();
} catch (final IllegalStateException e) { } catch (final IllegalStateException e) {
Log.d(TAG, e.getMessage()); Log.d(TAG, "" + e.getMessage());
} }
return currentPosition; return currentPosition;
@@ -383,7 +383,7 @@ public class QtAndroidMediaPlayer extends MediaPlayer
try { try {
duration = super.getDuration(); duration = super.getDuration();
} catch (final IllegalStateException e) { } catch (final IllegalStateException e) {
Log.d(TAG, e.getMessage()); Log.d(TAG, "" + e.getMessage());
} }
return duration; return duration;
@@ -415,7 +415,7 @@ public class QtAndroidMediaPlayer extends MediaPlayer
if (!mMuted) if (!mMuted)
mVolume = volume; mVolume = volume;
} catch (final IllegalStateException e) { } catch (final IllegalStateException e) {
Log.d(TAG, e.getMessage()); Log.d(TAG, "" + e.getMessage());
} }
} }