Commit 3cfbe5d2 authored by Geoffrey Métais's avatar Geoffrey Métais

Playlist creation can fail

parent ec52a521
......@@ -496,9 +496,7 @@ getPlaylist(JNIEnv* env, jobject thiz, jlong id)
{
AndroidMediaLibrary *aml = MediaLibrary_getInstance(env, thiz);
medialibrary::PlaylistPtr playlist = aml->playlist(id);
if (playlist != nullptr)
return convertPlaylistObject(env, &ml_fields, playlist);
return nullptr;
return playlist != nullptr ? convertPlaylistObject(env, &ml_fields, playlist) : nullptr;
}
jobject
......@@ -508,7 +506,7 @@ playlistCreate(JNIEnv* env, jobject thiz, jstring name)
const char *name_cstr = env->GetStringUTFChars(name, JNI_FALSE);
medialibrary::PlaylistPtr playlist = aml->PlaylistCreate(name_cstr);
env->ReleaseStringUTFChars(name, name_cstr);
return convertPlaylistObject(env, &ml_fields, playlist);
return playlist != nullptr ? convertPlaylistObject(env, &ml_fields, playlist) : nullptr;
}
/*
......
......@@ -148,6 +148,8 @@ public class SavePlaylistDialog extends DialogFragment implements View.OnClickLi
MediaWrapper[] tracks;
if (!exists)
playlist = mMedialibrary.createPlaylist(name);
if (playlist == null)
return;
if (addTracks) {
tracks = mNewTrack;
} else {//Save a playlist
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment