# HG changeset patch # User Santeri Piippo # Date 1363372769 -7200 # Node ID 2b78cf8634c3fdafb58b4f83b5af024852d8fec2 # Parent d71faa0a6133dfa56b61065e88bcc98379bb89cd don't crash if g_CurrentFile is null diff -r d71faa0a6133 -r 2b78cf8634c3 bbox.cpp --- a/bbox.cpp Fri Mar 15 20:35:47 2013 +0200 +++ b/bbox.cpp Fri Mar 15 20:39:29 2013 +0200 @@ -3,6 +3,9 @@ #include "ldtypes.h" void bbox::calculate () { + if (!g_CurrentFile) + return; + // The bounding box, bbox for short, is the // box that encompasses the model we have open. // v0 is the minimum vertex, v1 is the maximum vertex. diff -r d71faa0a6133 -r 2b78cf8634c3 gui.cpp --- a/gui.cpp Fri Mar 15 20:35:47 2013 +0200 +++ b/gui.cpp Fri Mar 15 20:39:29 2013 +0200 @@ -279,7 +279,13 @@ } void LDForgeWindow::buildObjList () { + if (!g_CurrentFile) + return; + QList qaItems; + + qObjList->clear (); + for (ushort i = 0; i < g_CurrentFile->objects.size(); ++i) { LDObject* obj = g_CurrentFile->objects[i]; diff -r d71faa0a6133 -r 2b78cf8634c3 main.cpp --- a/main.cpp Fri Mar 15 20:35:47 2013 +0200 +++ b/main.cpp Fri Mar 15 20:39:29 2013 +0200 @@ -12,9 +12,11 @@ g_CurrentFile = IO_ParseLDFile ("55966.dat"); g_BBox.calculate(); - printf ("bbox: (%.3f, %.3f, %.3f), (%.3f, %.3f, %.3f)\n", - FVERTEX (g_BBox.v0), FVERTEX (g_BBox.v1)); - printf ("%u objects\n", g_CurrentFile->objects.size()); + if (g_CurrentFile) { + printf ("bbox: (%.3f, %.3f, %.3f), (%.3f, %.3f, %.3f)\n", + FVERTEX (g_BBox.v0), FVERTEX (g_BBox.v1)); + printf ("%u objects\n", g_CurrentFile->objects.size()); + } QApplication app (argc, argv); LDForgeWindow* win = new LDForgeWindow;