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) );
...@@ -605,13 +622,6 @@ void Playlist::OnSave( wxCommandEvent& WXUNUSED(event) ) ...@@ -605,13 +622,6 @@ void Playlist::OnSave( wxCommandEvent& WXUNUSED(event) )
wxT(""), wxT(""), filter, wxSAVE ); wxT(""), wxT(""), filter, wxSAVE );
if( dialog.ShowModal() == wxID_OK ) if( dialog.ShowModal() == wxID_OK )
{
playlist_t * p_playlist =
(playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
FIND_ANYWHERE );
if( p_playlist )
{ {
if( dialog.GetFilename().mb_str() ) if( dialog.GetFilename().mb_str() )
{ {
...@@ -622,7 +632,6 @@ void Playlist::OnSave( wxCommandEvent& WXUNUSED(event) ) ...@@ -622,7 +632,6 @@ void Playlist::OnSave( wxCommandEvent& WXUNUSED(event) )
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