|
From: Yoda-JM <yo...@us...> - 2007-06-08 17:20:14
|
Update of /cvsroot/ultrastar-ng/UltraStar-ng/src In directory sc8-pr-cvs8.sourceforge.net:/tmp/cvs-serv14996/src Modified Files: songs.cpp Log Message: Fixed unclosed file descriptors Index: songs.cpp =================================================================== RCS file: /cvsroot/ultrastar-ng/UltraStar-ng/src/songs.cpp,v retrieving revision 1.44 retrieving revision 1.45 diff -C2 -d -r1.44 -r1.45 *** songs.cpp 30 Apr 2007 17:56:35 -0000 1.44 --- songs.cpp 8 Jun 2007 17:20:04 -0000 1.45 *************** *** 266,270 **** char * theme_path = new char[1024]; CScreenManager::getSingletonPtr()->getThemePathFile(theme_path,"no_cover.png"); ! SDL_RWops *rwop_nocover = SDL_RWFromFile(theme_path, "rb"); delete[] theme_path; --- 266,271 ---- char * theme_path = new char[1024]; CScreenManager::getSingletonPtr()->getThemePathFile(theme_path,"no_cover.png"); ! SDL_RWops *rwop_nocover = NULL; ! rwop_nocover = SDL_RWFromFile(theme_path, "rb"); delete[] theme_path; *************** *** 277,281 **** surface_nocover = zoomSurface(surface_nocover_tmp,(double)w/surface_nocover_tmp->w,(double)h/surface_nocover_tmp->h,1); SDL_FreeSurface(surface_nocover_tmp); ! SDL_FreeRW(rwop_nocover); } --- 278,283 ---- surface_nocover = zoomSurface(surface_nocover_tmp,(double)w/surface_nocover_tmp->w,(double)h/surface_nocover_tmp->h,1); SDL_FreeSurface(surface_nocover_tmp); ! if( rwop_nocover != NULL ) ! SDL_RWclose(rwop_nocover); } *************** *** 324,343 **** snprintf(buff,1024,"%s/%s/%s",songs_dir,dirEntry->d_name,tmp->cover); ! SDL_RWops *rwop = SDL_RWFromFile(buff, "rb"); SDL_Surface * coverSurface = NULL; if(strstr(tmp->cover, ".png")) ! coverSurface = IMG_LoadPNG_RW(rwop); else if(strstr(tmp->cover, ".jpg")) ! coverSurface = IMG_LoadJPG_RW(rwop); ! SDL_FreeRW(rwop); if( coverSurface == NULL ) ! tmp->coverSurf = surface_nocover; else { ! // Here we want to have cover of 256x256 in 800x600 and scale it if the resolution is different ! int w = CScreenManager::getSingletonPtr()->getWidth()*256/800; ! int h = CScreenManager::getSingletonPtr()->getHeight()*256/600; ! tmp->coverSurf = zoomSurface(coverSurface,(double) w/coverSurface->w,(double) h/coverSurface->h,1); ! SDL_FreeSurface(coverSurface); } --- 326,347 ---- snprintf(buff,1024,"%s/%s/%s",songs_dir,dirEntry->d_name,tmp->cover); ! SDL_RWops *rwop = NULL; ! rwop = SDL_RWFromFile(buff, "rb"); SDL_Surface * coverSurface = NULL; if(strstr(tmp->cover, ".png")) ! coverSurface = IMG_LoadPNG_RW(rwop); else if(strstr(tmp->cover, ".jpg")) ! coverSurface = IMG_LoadJPG_RW(rwop); ! if( rwop != NULL ) ! SDL_RWclose(rwop); if( coverSurface == NULL ) ! tmp->coverSurf = surface_nocover; else { ! // Here we want to have cover of 256x256 in 800x600 and scale it if the resolution is different ! int w = CScreenManager::getSingletonPtr()->getWidth()*256/800; ! int h = CScreenManager::getSingletonPtr()->getHeight()*256/600; ! tmp->coverSurf = zoomSurface(coverSurface,(double) w/coverSurface->w,(double) h/coverSurface->h,1); ! SDL_FreeSurface(coverSurface); } *************** *** 347,359 **** if(strstr(tmp->background, ".png")) { snprintf(buff,1024,"%s/%s/%s",songs_dir,dirEntry->d_name,tmp->background); rwop = SDL_RWFromFile(buff, "rb"); backgroundSurface = IMG_LoadPNG_RW(rwop); ! SDL_FreeRW(rwop); } else if(strstr(tmp->background, ".jpg")) { snprintf(buff,1024,"%s/%s/%s",songs_dir,dirEntry->d_name,tmp->background); rwop = SDL_RWFromFile(buff, "rb"); backgroundSurface = IMG_LoadJPG_RW(rwop); ! SDL_FreeRW(rwop); } --- 351,367 ---- if(strstr(tmp->background, ".png")) { + rwop = NULL; snprintf(buff,1024,"%s/%s/%s",songs_dir,dirEntry->d_name,tmp->background); rwop = SDL_RWFromFile(buff, "rb"); backgroundSurface = IMG_LoadPNG_RW(rwop); ! if( rwop != NULL ) ! SDL_RWclose(rwop); } else if(strstr(tmp->background, ".jpg")) { + rwop = NULL; snprintf(buff,1024,"%s/%s/%s",songs_dir,dirEntry->d_name,tmp->background); rwop = SDL_RWFromFile(buff, "rb"); backgroundSurface = IMG_LoadJPG_RW(rwop); ! if( rwop != NULL ) ! SDL_RWclose(rwop); } |