No more segfaults when trying to spawn bullets of unknown type
[supertux.git] / src / main.cpp
index 6acd08c..ed1317e 100644 (file)
@@ -422,14 +422,20 @@ void init_video()
 #else
   const char* icon_fname = "images/engine/icons/supertux.xpm";
 #endif
-  SDL_Surface* icon = IMG_Load_RW(get_physfs_SDLRWops(icon_fname), true);
+  SDL_Surface* icon;
+  try {
+    icon = IMG_Load_RW(get_physfs_SDLRWops(icon_fname), true);
+  } catch (const std::runtime_error& err) {
+    icon = 0;
+    log_warning << "Couldn't load icon '" << icon_fname << "': " << err.what() << std::endl;
+  }
   if(icon != 0) {
     SDL_WM_SetIcon(icon, 0);
     SDL_FreeSurface(icon);
   }
 #ifdef DEBUG
   else {
-    log_warning << "Couldn't find icon '" << icon_fname << "'" << std::endl;
+    log_warning << "Couldn't load icon '" << icon_fname << "'" << std::endl;
   }
 #endif