]> git.sesse.net Git - vlc/blobdiff - modules/gui/skins2/src/theme_repository.cpp
* skins2: when restoring the previous skin because a new one failed to load,
[vlc] / modules / gui / skins2 / src / theme_repository.cpp
index c63a6261790bf9e7778fe4d26730ffd9205a1d2e..7cd5fbc9de99768859acef15ddfe3dce4a3978ce 100644 (file)
@@ -18,7 +18,7 @@
  *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
  *****************************************************************************/
 
 #include "theme_repository.hpp"
@@ -109,30 +109,40 @@ void ThemeRepository::parseDirectory( const string &rDir )
     if( pDir == NULL )
     {
         // An error occurred
-        msg_Dbg( getIntf(), "Cannot open directory %s", rDir.c_str() );
+        msg_Dbg( getIntf(), "cannot open directory %s", rDir.c_str() );
         return;
     }
 
     // Get the first directory entry
-    pDirContent = readdir( pDir );
+    pDirContent = (dirent*)readdir( pDir );
 
     // While we still have entries in the directory
     while( pDirContent != NULL )
     {
         string name = pDirContent->d_name;
-        if( name.size() > 4 && name.substr( name.size() - 4, 4 ) == ".vlt" )
+        string extension;
+        if( name.size() > 4 )
+        {
+            extension = name.substr( name.size() - 4, 4 );
+        }
+        if( extension == ".vlt" || extension == ".wsz" )
         {
             string path = rDir + sep + name;
             msg_Dbg( getIntf(), "found skin %s", path.c_str() );
 
             // Add the theme in the popup menu
-            val.psz_string = (char*)path.c_str();
-            text.psz_string = (char*)name.substr(0, name.size() - 4).c_str();
+            string shortname = name.substr( 0, name.size() - 4 );
+            val.psz_string = new char[path.size() + 1];
+            text.psz_string = new char[shortname.size() + 1];
+            strcpy( val.psz_string, path.c_str() );
+            strcpy( text.psz_string, shortname.c_str() );
             var_Change( getIntf(), "intf-skins", VLC_VAR_ADDCHOICE, &val,
                         &text );
+            delete[] val.psz_string;
+            delete[] text.psz_string;
         }
 
-        pDirContent = readdir( pDir );
+        pDirContent = (dirent*)readdir( pDir );
     }
 
     closedir( pDir );
@@ -158,7 +168,6 @@ int ThemeRepository::changeSkin( vlc_object_t *pIntf, char const *pCmd,
         CmdChangeSkin *pCmd = new CmdChangeSkin( pThis->getIntf(),
                                                  newval.psz_string );
         AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
-        pQueue->remove( "change skin" );
         pQueue->push( CmdGenericPtr( pCmd ) );
     }