# HG changeset patch # User Santeri Piippo # Date 1382108262 -10800 # Node ID ee90c55dfeef9e78fc129a21782d3a797e54005a # Parent dcacfd2cd81bf1a3229d46afae2a33c0123411b2 Fixed: LDForge would sometimes crash over unitialized data in the GL renderer. This crash sure eluded me for a while. Turned out zoomToFit(), which uses m_width and m_height is called before resizeGL() which initializes these variables. This data is used in an operator new[] call. diff -r dcacfd2cd81b -r ee90c55dfeef changelog.txt --- a/changelog.txt Fri Oct 18 17:47:05 2013 +0300 +++ b/changelog.txt Fri Oct 18 17:57:42 2013 +0300 @@ -34,6 +34,7 @@ and the algorithm can terminate early, hopefully this will save a few cycles on large parts. - The camera icons now draw real tooltips instead of emulated ones. - Color icon border now reflects the color's edge color. +- Fixed: LDForge would sometimes crash during startup over uninitialized data in the GL renderer. - Fixed: The message log was still written with black text with dark backgrounds. ================================================= diff -r dcacfd2cd81b -r ee90c55dfeef src/file.cpp --- a/src/file.cpp Fri Oct 18 17:47:05 2013 +0300 +++ b/src/file.cpp Fri Oct 18 17:57:42 2013 +0300 @@ -298,7 +298,7 @@ // Trim the trailing newline qchar c; - while (!line.isEmpty() && (c = line[line.length() - 1]) == '\n' || c == '\r') + while (!line.isEmpty() && ((c = line[line.length() - 1]) == '\n' || c == '\r')) line.chop (1); LDObject* obj = parseLine (line); diff -r dcacfd2cd81b -r ee90c55dfeef src/gldraw.cpp --- a/src/gldraw.cpp Fri Oct 18 17:47:05 2013 +0300 +++ b/src/gldraw.cpp Fri Oct 18 17:57:42 2013 +0300 @@ -107,9 +107,9 @@ m_editMode = Select; m_rectdraw = false; m_panning = false; + m_firstResize = true; setFile (null); setDrawOnly (false); - resetAngles(); setMessageLog (null); m_toolTipTimer = new QTimer (this); @@ -351,6 +351,14 @@ { m_width = w; m_height = h; + // If this is the first call to resizeGL, reset the angles. We cannot call + // resetAngles() in the initializer because it does not know m_width or m_height, + // which zoomToFit() must know. + if (m_firstResize) + { m_firstResize = false; + resetAngles(); + } + calcCameraIcons(); glViewport (0, 0, w, h); diff -r dcacfd2cd81b -r ee90c55dfeef src/gldraw.h --- a/src/gldraw.h Fri Oct 18 17:47:05 2013 +0300 +++ b/src/gldraw.h Fri Oct 18 17:57:42 2013 +0300 @@ -159,14 +159,15 @@ int m_width, m_height, m_totalmove; - QList m_drawedVerts; + QList m_drawedVerts; bool m_rectdraw; vertex m_rectverts[4]; QColor m_bgcolor; double m_depthValues[6]; LDGLOverlay m_overlays[6]; - QList m_knownVerts; + QList m_knownVerts; bool m_panning; + bool m_firstResize; void addDrawnVertex (vertex m_hoverpos); void calcCameraIcons(); // Compute geometry for camera icons