Commit 9ee8da32 authored by Clément Stenac's avatar Clément Stenac

Don't save an empty playlist

Fix refcount problem
parent 491b9e70
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* playlist.cpp : wxWindows plugin for vlc * playlist.cpp : wxWindows plugin for vlc
***************************************************************************** *****************************************************************************
* Copyright (C) 2000-2004 VideoLAN * Copyright (C) 2000-2004 VideoLAN
* $Id: playlist.cpp,v 1.49 2004/02/29 14:05:45 zorglub Exp $ * $Id$
* *
* Authors: Olivier Teulire <ipkiss@via.ecp.fr> * Authors: Olivier Teulire <ipkiss@via.ecp.fr>
* *
...@@ -594,6 +594,23 @@ void Playlist::OnSave( wxCommandEvent& WXUNUSED(event) ) ...@@ -594,6 +594,23 @@ void Playlist::OnSave( wxCommandEvent& WXUNUSED(event) )
} formats[] = {{ _("M3U file"), "*.m3u", "export-m3u" }, } formats[] = {{ _("M3U file"), "*.m3u", "export-m3u" },
{ _("PLS file"), "*.pls", "export-pls" }}; { _("PLS file"), "*.pls", "export-pls" }};
wxString filter = wxT(""); wxString filter = wxT("");
playlist_t * p_playlist =
(playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
FIND_ANYWHERE );
if( ! p_playlist )
{
return;
}
if( p_playlist->i_size == 0 )
{
wxMessageBox( wxU(_("Playlist is empty") ), wxU(_("Can't save")),
wxICON_WARNING | wxOK, this );
vlc_object_release( p_playlist );
return;
}
for( unsigned int i = 0; i < sizeof(formats)/sizeof(formats[0]); i++) for( unsigned int i = 0; i < sizeof(formats)/sizeof(formats[0]); i++)
{ {
filter.Append( wxU(formats[i].psz_desc) ); filter.Append( wxU(formats[i].psz_desc) );
...@@ -606,23 +623,15 @@ void Playlist::OnSave( wxCommandEvent& WXUNUSED(event) ) ...@@ -606,23 +623,15 @@ void Playlist::OnSave( wxCommandEvent& WXUNUSED(event) )
if( dialog.ShowModal() == wxID_OK ) if( dialog.ShowModal() == wxID_OK )
{ {
if( dialog.GetFilename().mb_str() )
playlist_t * p_playlist =
(playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
FIND_ANYWHERE );
if( p_playlist )
{ {
if( dialog.GetFilename().mb_str() ) playlist_Export( p_playlist, dialog.GetFilename().mb_str(),
{ formats[dialog.GetFilterIndex()].psz_module );
playlist_Export( p_playlist, dialog.GetFilename().mb_str(),
formats[dialog.GetFilterIndex()].psz_module );
}
} }
}
vlc_object_release( p_playlist ); vlc_object_release( p_playlist );
}
} }
void Playlist::OnOpen( wxCommandEvent& WXUNUSED(event) ) void Playlist::OnOpen( wxCommandEvent& WXUNUSED(event) )
......
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