Explorar o código

Error instead of crash when love.graphics.newGeometry fails

Alex Szpakowski %!s(int64=12) %!d(string=hai) anos
pai
achega
f05e681b24
Modificáronse 1 ficheiros con 9 adicións e 1 borrados
  1. 9 1
      src/modules/graphics/opengl/wrap_Graphics.cpp

+ 9 - 1
src/modules/graphics/opengl/wrap_Graphics.cpp

@@ -418,7 +418,15 @@ int w_newGeometry(lua_State *L)
 		vertices.push_back(v);
 	}
 
-	Geometry *geom = instance->newGeometry(vertices);
+	Geometry *geom = 0;
+	try
+	{
+		geom = instance->newGeometry(vertices);
+	}
+	catch (love::Exception &e)
+	{
+		return luaL_error(L, "%s", e.what());
+	}
 
 	if (geom == 0)
 		return luaL_error(L, "Could not create geometry.");