error handling fixes

This commit is contained in:
Glenn Maynard
2004-06-14 01:12:22 +00:00
parent 40c9749d54
commit 87823229c5
6 changed files with 15 additions and 15 deletions
+3 -2
View File
@@ -301,10 +301,11 @@ void BannerCache::CacheBanner( CString BannerPath )
void BannerCache::CacheBannerInternal( CString BannerPath ) void BannerCache::CacheBannerInternal( CString BannerPath )
{ {
RageSurface *img = RageSurfaceUtils::LoadFile( BannerPath ); CString error;
RageSurface *img = RageSurfaceUtils::LoadFile( BannerPath, error );
if( img == NULL ) if( img == NULL )
{ {
LOG->Warn( "BannerCache::CacheBanner: Couldn't load %s: %s", BannerPath.c_str(), SDL_GetError() ); LOG->Warn( "BannerCache::CacheBanner: Couldn't load %s: %s", BannerPath.c_str(), error.c_str() );
return; return;
} }
+3 -4
View File
@@ -11,9 +11,7 @@
#include "RageSurface.h" #include "RageSurface.h"
#include "RageSurfaceUtils.h" #include "RageSurfaceUtils.h"
#include "SDL.h"
#include "SDL_rotozoom.h" #include "SDL_rotozoom.h"
#include "SDL_utils.h"
#include "SDL_dither.h" #include "SDL_dither.h"
#include "RageSurface_Load.h" #include "RageSurface_Load.h"
@@ -69,12 +67,13 @@ void RageBitmapTexture::Create()
/* Create (and return) a surface ready to be loaded to OpenGL */ /* Create (and return) a surface ready to be loaded to OpenGL */
/* Load the image into an SDL surface. */ /* Load the image into an SDL surface. */
RageSurface *img = RageSurfaceUtils::LoadFile( actualID.filename ); CString error;
RageSurface *img = RageSurfaceUtils::LoadFile( actualID.filename, error );
/* Tolerate corrupt/unknown images. */ /* Tolerate corrupt/unknown images. */
if( img == NULL ) if( img == NULL )
{ {
LOG->Warn( "RageBitmapTexture: Couldn't load %s: %s", actualID.filename.c_str(), SDL_GetError() ); LOG->Warn( "RageBitmapTexture: Couldn't load %s: %s", actualID.filename.c_str(), error.c_str() );
img = RageSurfaceUtils::MakeDummySurface( 64, 64 ); img = RageSurfaceUtils::MakeDummySurface( 64, 64 );
ASSERT( img != NULL ); ASSERT( img != NULL );
} }
+2 -5
View File
@@ -97,13 +97,13 @@ static RageSurface *TryOpenFile( CString sPath, bool bHeaderOnly, CString &error
return NULL; return NULL;
} }
RageSurface *RageSurfaceUtils::LoadFile( const CString &sPath, bool bHeaderOnly ) RageSurface *RageSurfaceUtils::LoadFile( const CString &sPath, CString &error, bool bHeaderOnly )
{ {
{ {
RageFile TestOpen; RageFile TestOpen;
if( !TestOpen.Open( sPath ) ) if( !TestOpen.Open( sPath ) )
{ {
SDL_SetError( "%s", TestOpen.GetError().c_str() ); error = TestOpen.GetError();
return NULL; return NULL;
} }
} }
@@ -117,8 +117,6 @@ RageSurface *RageSurfaceUtils::LoadFile( const CString &sPath, bool bHeaderOnly
CString format = GetExtension(sPath); CString format = GetExtension(sPath);
format.MakeLower(); format.MakeLower();
CString error = "";
bool bKeepTrying = true; bool bKeepTrying = true;
/* If the extension matches a format, try that first. */ /* If the extension matches a format, try that first. */
@@ -140,7 +138,6 @@ RageSurface *RageSurfaceUtils::LoadFile( const CString &sPath, bool bHeaderOnly
} }
} }
SDL_SetError( "%s", error.c_str() );
return NULL; return NULL;
} }
+1 -1
View File
@@ -13,7 +13,7 @@ namespace RageSurfaceUtils
/* If bHeaderOnly is true, the loader is only required to return a surface /* If bHeaderOnly is true, the loader is only required to return a surface
* with the width and height set (but may return a complete surface). */ * with the width and height set (but may return a complete surface). */
RageSurface *LoadFile( const CString &sPath, bool bHeaderOnly=false ); RageSurface *LoadFile( const CString &sPath, CString &error, bool bHeaderOnly=false );
} }
#endif #endif
+4 -2
View File
@@ -697,11 +697,13 @@ void Song::TidyUpData()
continue; // skip continue; // skip
CString sPath = m_sSongDir + arrayImages[i]; CString sPath = m_sSongDir + arrayImages[i];
/* We only care about the dimensions. */ /* We only care about the dimensions. */
RageSurface *img = RageSurfaceUtils::LoadFile( sPath, true ); CString error;
RageSurface *img = RageSurfaceUtils::LoadFile( sPath, error, true );
if( !img ) if( !img )
{ {
LOG->Trace("Couldn't load '%s': %s", sPath.c_str(), SDL_GetError()); LOG->Trace( "Couldn't load '%s': %s", sPath.c_str(), error.c_str() );
continue; continue;
} }
@@ -14,7 +14,8 @@ static HBITMAP g_hBitmap = NULL;
/* Load a file into a GDI surface. */ /* Load a file into a GDI surface. */
HBITMAP LoadWin32Surface( CString fn ) HBITMAP LoadWin32Surface( CString fn )
{ {
RageSurface *s = RageSurfaceUtils::LoadFile( fn ); CString error;
RageSurface *s = RageSurfaceUtils::LoadFile( fn, error );
if( s == NULL ) if( s == NULL )
return NULL; return NULL;