Removed all asserts from the code. Removed assert handling and the bomb box dialog.

Sun, 30 Aug 2015 04:21:44 +0300

author
Teemu Piippo <crimsondusk64@gmail.com>
date
Sun, 30 Aug 2015 04:21:44 +0300
changeset 958
1dc890c73e01
parent 957
429c7ed3cc54
child 959
737245eee433

Removed all asserts from the code. Removed assert handling and the bomb box dialog.

CMakeLists.txt file | annotate | diff | comparison | revisions
icons/bomb.png file | annotate | diff | comparison | revisions
ldforge.qrc file | annotate | diff | comparison | revisions
src/actionsEdit.cpp file | annotate | diff | comparison | revisions
src/addObjectDialog.cpp file | annotate | diff | comparison | revisions
src/basics.cpp file | annotate | diff | comparison | revisions
src/configDialog.cpp file | annotate | diff | comparison | revisions
src/crashCatcher.cpp file | annotate | diff | comparison | revisions
src/crashCatcher.h file | annotate | diff | comparison | revisions
src/dialogs.cpp file | annotate | diff | comparison | revisions
src/dialogs.h file | annotate | diff | comparison | revisions
src/editmodes/circleMode.cpp file | annotate | diff | comparison | revisions
src/editmodes/linePathMode.cpp file | annotate | diff | comparison | revisions
src/glRenderer.cpp file | annotate | diff | comparison | revisions
src/ldDocument.cpp file | annotate | diff | comparison | revisions
src/ldObject.cpp file | annotate | diff | comparison | revisions
src/macros.h file | annotate | diff | comparison | revisions
src/main.cpp file | annotate | diff | comparison | revisions
src/main.h file | annotate | diff | comparison | revisions
src/miscallenous.cpp file | annotate | diff | comparison | revisions
src/primitives.cpp file | annotate | diff | comparison | revisions
src/ringFinder.cpp file | annotate | diff | comparison | revisions
ui/bombbox.ui file | annotate | diff | comparison | revisions
--- a/CMakeLists.txt	Sun Aug 30 03:52:03 2015 +0300
+++ b/CMakeLists.txt	Sun Aug 30 04:21:44 2015 +0300
@@ -115,7 +115,6 @@
 set (LDFORGE_FORMS
 	ui/about.ui
 	ui/addhistoryline.ui
-	ui/bombbox.ui
 	ui/config.ui
 	ui/coverer.ui
 	ui/downloadfrom.ui
Binary file icons/bomb.png has changed
--- a/ldforge.qrc	Sun Aug 30 03:52:03 2015 +0300
+++ b/ldforge.qrc	Sun Aug 30 04:21:44 2015 +0300
@@ -18,7 +18,6 @@
 	<file>./icons/axes.png</file>
 	<file>./icons/bfc.png</file>
 	<file>./icons/bfc-view.png</file>
-	<file>./icons/bomb.png</file>
 	<file>./icons/brick-new.png</file>
 	<file>./icons/brick.png</file>
 	<file>./icons/camera-back.png</file>
--- a/src/actionsEdit.cpp	Sun Aug 30 03:52:03 2015 +0300
+++ b/src/actionsEdit.cpp	Sun Aug 30 04:21:44 2015 +0300
@@ -121,29 +121,29 @@
 //
 static void DoInline (bool deep)
 {
-	LDObjectList sel = Selection();
-
 	for (LDObjectIterator<LDSubfile> it (Selection()); it.isValid(); ++it)
 	{
 		// Get the index of the subfile so we know where to insert the
 		// inlined contents.
-		long idx = it->lineNumber();
+		int idx = it->lineNumber();
 
-		assert (idx != -1);
-		LDObjectList objs = it->inlineContents (deep, false);
-
-		// Merge in the inlined objects
-		for (LDObject* inlineobj : objs)
+		if (idx != -1)
 		{
-			QString line = inlineobj->asText();
-			inlineobj->destroy();
-			LDObject* newobj = ParseLine (line);
-			CurrentDocument()->insertObj (idx++, newobj);
-			newobj->select();
+			LDObjectList objs = it->inlineContents (deep, false);
+	
+			// Merge in the inlined objects
+			for (LDObject* inlineobj : objs)
+			{
+				QString line = inlineobj->asText();
+				inlineobj->destroy();
+				LDObject* newobj = ParseLine (line);
+				CurrentDocument()->insertObj (idx++, newobj);
+				newobj->select();
+			}
+	
+			// Delete the subfile now as it's been inlined.
+			it->destroy();
 		}
-
-		// Delete the subfile now as it's been inlined.
-		it->destroy();
 	}
 }
 
--- a/src/addObjectDialog.cpp	Sun Aug 30 03:52:03 2015 +0300
+++ b/src/addObjectDialog.cpp	Sun Aug 30 04:21:44 2015 +0300
@@ -301,7 +301,8 @@
 	Matrix transform = IdentityMatrix;
 	AddObjectDialog dlg (type, obj);
 
-	assert (obj == null or obj->type() == type);
+	if (obj and obj->type() != type)
+		return;
 
 	if (dlg.exec() == QDialog::Rejected)
 		return;
@@ -355,8 +356,8 @@
 		case OBJ_BFC:
 		{
 			LDBFC* bfc = InitObject<LDBFC> (obj);
-			assert (IsWithin (dlg.rb_bfcType->value(), 0, int (BFCStatement::NumValues) - 1));
-			bfc->setStatement (BFCStatement (dlg.rb_bfcType->value()));
+			if (IsWithin (dlg.rb_bfcType->value(), 0, int (BFCStatement::NumValues) - 1))
+				bfc->setStatement (BFCStatement (dlg.rb_bfcType->value()));
 		} break;
 
 		case OBJ_Vertex:
@@ -382,7 +383,6 @@
 			}
 
 			LDSubfile* ref = InitObject<LDSubfile> (obj);
-			assert (ref);
 
 			for_axes (ax)
 				ref->setCoordinate (ax, dlg.dsb_coords[ax]->value());
--- a/src/basics.cpp	Sun Aug 30 03:52:03 2015 +0300
+++ b/src/basics.cpp	Sun Aug 30 04:21:44 2015 +0300
@@ -72,7 +72,6 @@
 		case Z: return z();
 	}
 
-	assert (false);
 	return 0.0;
 }
 
@@ -122,8 +121,8 @@
 //
 Matrix::Matrix (const std::initializer_list<double>& vals)
 {
-	assert (vals.size() == 9);
-	memcpy (&m_vals[0], vals.begin(), sizeof m_vals);
+	if (vals.size() == 9)
+		memcpy (&m_vals[0], vals.begin(), sizeof m_vals);
 }
 
 // =============================================================================
--- a/src/configDialog.cpp	Sun Aug 30 03:52:03 2015 +0300
+++ b/src/configDialog.cpp	Sun Aug 30 04:21:44 2015 +0300
@@ -92,7 +92,6 @@
 ConfigDialog::ConfigDialog (ConfigDialog::Tab deftab, QWidget* parent, Qt::WindowFlags f) :
 	QDialog (parent, f)
 {
-	assert (g_win != null);
 	ui = new Ui_ConfigUI;
 	ui->setupUi (this);
 
@@ -138,10 +137,13 @@
 		}
 	});
 
-	g_win->applyToActions ([&](QAction* act)
+	if (g_win)
 	{
-		addShortcut (act);
-	});
+		g_win->applyToActions ([&](QAction* act)
+		{
+			addShortcut (act);
+		});
+	}
 
 	ui->shortcutsList->setSortingEnabled (true);
 	ui->shortcutsList->sortItems();
@@ -297,7 +299,9 @@
 	});
 
 	// Rebuild the quick color toolbar
-	g_win->setQuickColors (quickColors);
+	if (g_win)
+		g_win->setQuickColors (quickColors);
+
 	cfg::QuickColorToolbar = quickColorString();
 
 	// Ext program settings
@@ -319,9 +323,13 @@
 	Config::Save();
 	LDDocument::current()->reloadAllSubfiles();
 	LoadLogoStuds();
-	g_win->R()->setBackground();
-	g_win->doFullRefresh();
-	g_win->updateDocumentList();
+
+	if (g_win)
+	{
+		g_win->R()->setBackground();
+		g_win->doFullRefresh();
+		g_win->updateDocumentList();
+	}
 }
 
 //
@@ -627,13 +635,16 @@
 		}
 	}
 
-	assert (info != null);
-	QString fpath = QFileDialog::getOpenFileName (this, format ("Path to %1", info->name), *info->path, g_extProgPathFilter);
-
-	if (fpath.isEmpty())
-		return;
-
-	info->input->setText (fpath);
+	if (info != null)
+	{
+		QString filepath = QFileDialog::getOpenFileName (this,
+			format ("Path to %1", info->name), *info->path, g_extProgPathFilter);
+	
+		if (filepath.isEmpty())
+			return;
+	
+		info->input->setText (filepath);
+	}
 }
 
 //
--- a/src/crashCatcher.cpp	Sun Aug 30 03:52:03 2015 +0300
+++ b/src/crashCatcher.cpp	Sun Aug 30 04:21:44 2015 +0300
@@ -16,37 +16,22 @@
  *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-#include <QProcess>
-#include <QTemporaryFile>
-#include <unistd.h>
-#include <signal.h>
-#include "crashCatcher.h"
-#include "dialogs.h"
- 
-#ifdef __unix__
+#include <QtGlobal>
+
+#ifdef Q_OS_UNIX
+# include <QProcess>
+# include <QTemporaryFile>
+# include <unistd.h>
+# include <signal.h>
+# include "crashCatcher.h"
+# include "dialogs.h"
+
 # ifdef Q_OS_LINUX
 #  include <sys/prctl.h>
 # endif
 
-// Is the crash catcher active now?
-static bool IsCrashCatcherActive = false;
-
-// If an assertion failed, what was it?
-static QString AssertionFailureText;
-
-// List of signals to catch and crash on
-static QList<int> SignalsToCatch ({
-	SIGSEGV, // segmentation fault
-	SIGABRT, // abort() calls
-	SIGFPE, // floating point exceptions (e.g. division by zero)
-	SIGILL, // illegal instructions
-});
-
-// -------------------------------------------------------------------------------------------------
-//
-//	Removes the signal handler from SIGABRT and then aborts.
-//
-static void FinalAbort()
+// Removes the signal handler from SIGABRT and then aborts.
+static void finalAbort()
 {
 	struct sigaction sighandler;
 	sighandler.sa_handler = SIG_DFL;
@@ -55,23 +40,21 @@
 	abort();
 }
 
-// -------------------------------------------------------------------------------------------------
-//
 static void HandleCrash (int sig)
 {
+	static bool isActive = false;
 	printf ("!! Caught signal %d, launching gdb\n", sig);
 
-	if (IsCrashCatcherActive)
+	if (isActive)
 	{
 		printf ("Caught signal while crash catcher is active! Execution cannot continue.\n");
-		FinalAbort();
+		finalAbort();
 	}
 
 	pid_t const pid (getpid());
 	QProcess proc;
 	QTemporaryFile commandsFile;
-
-	IsCrashCatcherActive = true;
+	isActive = true;
 
 	if (commandsFile.open())
 	{
@@ -98,64 +81,38 @@
 
 	if (f.open (QIODevice::WriteOnly))
 	{
-		fprint (f, format ("=== Program crashed with signal %1 ===\n\n%2"
+		fprint (f, format ("=== Program crashed with signal %1 ===\n\n"
 			"GDB stdout:\n%3\nGDB stderr:\n%4\n", sig,
-			(not AssertionFailureText.isEmpty()) ? AssertionFailureText + "\n\n" : "",
 			output, err));
 		f.close();
 	}
 
-	if (not AssertionFailureText.isEmpty())
-		printf ("Assertion failed: \"%s\".\n", qPrintable (AssertionFailureText));
-
 	printf ("Backtrace written to " UNIXNAME "-crash.log. Aborting.\n");
-	FinalAbort();
+	finalAbort();
 }
 
-// -------------------------------------------------------------------------------------------------
-//
-//	Initializes the crash catcher.
-//
-void InitCrashCatcher()
+void initCrashCatcher()
 {
+	// List of signals to catch and crash on
+	static const int signalsToCatch[] = {
+		SIGSEGV, // segmentation fault
+		SIGABRT, // abort() calls
+		SIGFPE, // floating point exceptions (e.g. division by zero)
+		SIGILL, // illegal instructions
+	};
+
 	struct sigaction sighandler;
 	sighandler.sa_handler = &HandleCrash;
 	sighandler.sa_flags = 0;
 	sigemptyset (&sighandler.sa_mask);
 
-	for (int sig : SignalsToCatch)
+	for (int sig : signalsToCatch)
 	{
 		if (sigaction (sig, &sighandler, null) == -1)
-		{
 			fprint (stderr, "Couldn't set signal handler %1: %2", sig, strerror (errno));
-			SignalsToCatch.removeOne (sig);
-		}
 	}
 
-	print ("Crash catcher hooked to signals: %1\n", SignalsToCatch);
+	print ("Crash catcher hooked to signals: %1\n", signalsToCatch);
 }
 
-#endif // #ifdef __unix__
-
-// -------------------------------------------------------------------------------------------------
-//
-// This function catches an assertion failure. It must be readily available in both Windows and
-// Linux. We display the bomb box straight in Windows while in Linux we let abort() trigger
-// the signal handler, which will cause the usual bomb box with GDB diagnostics. Said prompt will
-// embed the assertion failure information.
-//
-void HandleAssertFailure (const char* file, int line, const char* funcname, const char* expr)
-{
-#ifdef __unix__
-	AssertionFailureText = format ("%1:%2: %3: %4", file, line, funcname, expr);
-#else
-	DisplayBombBox (format (
-		"<p><b>File</b>: <tt>%1</tt><br />"
-		"<b>Line</b>: <tt>%2</tt><br />"
-		"<b>Function:</b> <tt>%3</tt></p>"
-		"<p>Assertion <b><tt>`%4'</tt></b> failed.</p>",
-		file, line, funcname, expr));
-#endif
-
-	abort();
-}
\ No newline at end of file
+#endif // Q_OS_UNIX
\ No newline at end of file
--- a/src/crashCatcher.h	Sun Aug 30 03:52:03 2015 +0300
+++ b/src/crashCatcher.h	Sun Aug 30 04:21:44 2015 +0300
@@ -19,8 +19,8 @@
 #pragma once
 #include "main.h"
 
-#ifdef __unix__
-void InitCrashCatcher();
-#else // ifdef __unix__
-# define InitCrashCatcher()
-#endif // ifdef __unix__
+#ifdef Q_OS_UNIX
+void initCrashCatcher();
+#else
+void initCrashCatcher() {}
+#endif
--- a/src/dialogs.cpp	Sun Aug 30 03:52:03 2015 +0300
+++ b/src/dialogs.cpp	Sun Aug 30 04:21:44 2015 +0300
@@ -40,7 +40,6 @@
 #include "ui_overlay.h"
 #include "ui_extprogpath.h"
 #include "ui_about.h"
-#include "ui_bombbox.h"
 
 extern const char* g_extProgPathFilter;
 EXTERN_CFGENTRY (String, LDrawPath)
@@ -217,16 +216,3 @@
 {
 	QDesktopServices::openUrl (QUrl ("mailto:Teemu Piippo <arezey@gmail.com>?subject=LDForge"));
 }
-
-// =============================================================================
-// =============================================================================
-void DisplayBombBox (const QString& message)
-{
-	QDialog dlg (g_win);
-	Ui_BombBox ui;
-
-	ui.setupUi (&dlg);
-	ui.m_text->setText (message);
-	ui.buttonBox->button (QDialogButtonBox::Close)->setText (QObject::tr ("Damn it"));
-	dlg.exec();
-}
--- a/src/dialogs.h	Sun Aug 30 03:52:03 2015 +0300
+++ b/src/dialogs.h	Sun Aug 30 04:21:44 2015 +0300
@@ -92,5 +92,3 @@
 private slots:
 	void slot_mail();
 };
-
-void DisplayBombBox (const QString& message);
--- a/src/editmodes/circleMode.cpp	Sun Aug 30 03:52:03 2015 +0300
+++ b/src/editmodes/circleMode.cpp	Sun Aug 30 04:21:44 2015 +0300
@@ -37,14 +37,18 @@
 
 double CircleMode::getCircleDrawDist (int pos) const
 {
-	assert (m_drawedVerts.size() >= pos + 1);
-	Vertex v1 = (m_drawedVerts.size() >= pos + 2) ? m_drawedVerts[pos + 1] :
-		renderer()->coordconv2_3 (renderer()->mousePosition(), false);
-	Axis localx, localy;
-	renderer()->getRelativeAxes (localx, localy);
-	double dx = m_drawedVerts[0][localx] - v1[localx];
-	double dy = m_drawedVerts[0][localy] - v1[localy];
-	return Grid::Snap (sqrt ((dx * dx) + (dy * dy)), Grid::Coordinate);
+	if (m_drawedVerts.size() >= pos + 1)
+	{
+		Vertex v1 = (m_drawedVerts.size() >= pos + 2) ? m_drawedVerts[pos + 1] :
+			renderer()->coordconv2_3 (renderer()->mousePosition(), false);
+		Axis localx, localy;
+		renderer()->getRelativeAxes (localx, localy);
+		double dx = m_drawedVerts[0][localx] - v1[localx];
+		double dy = m_drawedVerts[0][localy] - v1[localy];
+		return Grid::Snap (sqrt ((dx * dx) + (dy * dy)), Grid::Coordinate);
+	}
+
+	return 0.0;
 }
 
 Matrix CircleMode::getCircleDrawMatrix (double scale)
--- a/src/editmodes/linePathMode.cpp	Sun Aug 30 03:52:03 2015 +0300
+++ b/src/editmodes/linePathMode.cpp	Sun Aug 30 04:21:44 2015 +0300
@@ -16,16 +16,18 @@
 		points << renderer()->coordconv3_2 (vrt);
 
 	painter.setPen (renderer()->textPen());
-	assert (points.size() == points3d.size());
 
-	for (int i = 0; i < points.size() - 1; ++i)
+	if (points.size() == points3d.size())
 	{
-		painter.drawLine (QLineF (points[i], points[i + 1]));
-		drawLength (painter, points3d[i], points3d[i + 1], points[i], points[i + 1]);
+		for (int i = 0; i < points.size() - 1; ++i)
+		{
+			painter.drawLine (QLineF (points[i], points[i + 1]));
+			drawLength (painter, points3d[i], points3d[i + 1], points[i], points[i + 1]);
+		}
+	
+		for (QPointF const& point : points)
+			renderer()->drawBlip (painter, point);
 	}
-
-	for (QPointF const& point : points)
-		renderer()->drawBlip (painter, point);
 }
 
 bool LinePathMode::mouseReleased (MouseEventData const& data)
--- a/src/glRenderer.cpp	Sun Aug 30 03:52:03 2015 +0300
+++ b/src/glRenderer.cpp	Sun Aug 30 04:21:44 2015 +0300
@@ -519,7 +519,8 @@
 //
 Vertex GLRenderer::coordconv2_3 (const QPoint& pos2d, bool snap) const
 {
-	assert (camera() != EFreeCamera);
+	if (camera() == EFreeCamera)
+		return Origin;
 
 	Vertex pos3d;
 	const LDFixedCamera* cam = &g_FixedCameras[camera()];
@@ -973,7 +974,9 @@
 	for (qint32 idx : indices)
 	{
 		LDObject* obj = LDObject::fromID (idx);
-		assert (obj != null);
+
+		if (obj == null)
+			continue;
 
 		// If this is an additive single pick and the object is currently selected,
 		// we remove it from selection instead.
@@ -1264,16 +1267,18 @@
 //
 void GLRenderer::setDepthValue (double depth)
 {
-	assert (camera() < EFreeCamera);
-	currentDocumentData().depthValues[camera()] = depth;
+	if (camera() < EFreeCamera)
+		currentDocumentData().depthValues[camera()] = depth;
 }
 
 // =============================================================================
 //
 double GLRenderer::getDepthValue() const
 {
-	assert (camera() < EFreeCamera);
-	return currentDocumentData().depthValues[camera()];
+	if (camera() < EFreeCamera)
+		return currentDocumentData().depthValues[camera()];
+	else
+		return 0.0;
 }
 
 // =============================================================================
@@ -1635,6 +1640,8 @@
 
 LDFixedCamera const& GetFixedCamera (ECamera cam)
 {
-	assert (cam != EFreeCamera);
-	return g_FixedCameras[cam];
+	if (cam != EFreeCamera)
+		return g_FixedCameras[cam];
+	else
+		return g_FixedCameras[0];
 }
--- a/src/ldDocument.cpp	Sun Aug 30 03:52:03 2015 +0300
+++ b/src/ldDocument.cpp	Sun Aug 30 04:21:44 2015 +0300
@@ -1151,7 +1151,8 @@
 //
 void LDDocument::setObject (int idx, LDObject* obj)
 {
-	assert (idx >= 0 and idx < m_objects.size());
+	if (idx < 0 or idx >= m_objects.size())
+		return;
 
 	// Mark this change to history
 	if (not m_history->isIgnoring())
@@ -1389,26 +1390,24 @@
 //
 void LDDocument::addToSelection (LDObject* obj) // [protected]
 {
-	if (obj->isSelected())
-		return;
-
-	assert (obj->document() == this);
-	m_sel << obj;
-	g_win->R()->compileObject (obj);
-	obj->setSelected (true);
+	if (not obj->isSelected() and obj->document() == this)
+	{
+		m_sel << obj;
+		g_win->R()->compileObject (obj);
+		obj->setSelected (true);
+	}
 }
 
 // =============================================================================
 //
 void LDDocument::removeFromSelection (LDObject* obj) // [protected]
 {
-	if (not obj->isSelected())
-		return;
-
-	assert (obj->document() == this);
-	m_sel.removeOne (obj);
-	g_win->R()->compileObject (obj);
-	obj->setSelected (false);
+	if (obj->isSelected() and obj->document() == this)
+	{
+		m_sel.removeOne (obj);
+		g_win->R()->compileObject (obj);
+		obj->setSelected (false);
+	}
 }
 
 // =============================================================================
@@ -1416,9 +1415,12 @@
 void LDDocument::clearSelection()
 {
 	for (LDObject* obj : m_sel)
-		removeFromSelection (obj);
+	{
+		g_win->R()->compileObject (obj);
+		obj->setSelected (false);
+	}
 
-	assert (m_sel.isEmpty());
+	m_sel.clear();
 }
 
 // =============================================================================
@@ -1434,10 +1436,13 @@
 {
 	int a = m_objects.indexOf (one);
 	int b = m_objects.indexOf (other);
-	assert (a != b and a != -1 and b != -1);
-	m_objects[b] = one;
-	m_objects[a] = other;
-	addToHistory (new SwapHistory (one->id(), other->id()));
+
+	if (a != b and a != -1 and b != -1)
+	{
+		m_objects[b] = one;
+		m_objects[a] = other;
+		addToHistory (new SwapHistory (one->id(), other->id()));
+	}
 }
 
 // =============================================================================
--- a/src/ldObject.cpp	Sun Aug 30 03:52:03 2015 +0300
+++ b/src/ldObject.cpp	Sun Aug 30 04:21:44 2015 +0300
@@ -252,8 +252,8 @@
 //
 void LDObject::swap (LDObject* other)
 {
-	assert (document() == other->document());
-	document()->swapObjects (this, other);
+	if (document() == other->document())
+		document()->swapObjects (this, other);
 }
 
 // =============================================================================
@@ -379,7 +379,6 @@
 	// Transform the objects
 	for (LDObject* obj : objs)
 	{
-		// assert (obj->type() != OBJ_Subfile);
 		// Set the parent now so we know what inlined the object.
 		obj->setParent (this);
 		TransformObject (obj, transform(), position(), color());
@@ -470,7 +469,6 @@
 			// One of the objects hit the extrema. If this happens, this should be the first
 			// object to be iterated on. Thus, nothing has changed yet and it's safe to just
 			// abort the entire operation.
-			assert (i == start);
 			return;
 		}
 
@@ -549,9 +547,8 @@
 LDObject* LDObject::next() const
 {
 	int idx = lineNumber();
-	assert (idx != -1);
 
-	if (idx == document()->getObjectCount() - 1)
+	if (idx == -1 or idx == document()->getObjectCount() - 1)
 		return nullptr;
 
 	return document()->getObject (idx + 1);
@@ -562,9 +559,8 @@
 LDObject* LDObject::previous() const
 {
 	int idx = lineNumber();
-	assert (idx != -1);
 
-	if (idx == 0)
+	if (idx <= 0)
 		return nullptr;
 
 	return document()->getObject (idx - 1);
@@ -623,7 +619,7 @@
 		case OBJ_Error:			return LDSpawn<LDError>();
 		case OBJ_Vertex:		return LDSpawn<LDVertex>();
 		case OBJ_Overlay:		return LDSpawn<LDOverlay>();
-		case OBJ_NumTypes:		assert (false);
+		case OBJ_NumTypes:		break;
 	}
 	return nullptr;
 }
--- a/src/macros.h	Sun Aug 30 03:52:03 2015 +0300
+++ b/src/macros.h	Sun Aug 30 04:21:44 2015 +0300
@@ -92,23 +92,7 @@
 #define FUNCNAME __func__
 #endif // __GNUC__
 
-// =============================================================================
-//
 #define dvalof(A) dprint ("value of '%1' = %2\n", #A, A)
-
-// =============================================================================
-//
-// Replace assert with a version that shows a GUI dialog if possible.
-// On Windows I just can't get the actual error messages otherwise.
-//
-#undef assert
-
-#ifdef DEBUG
-# define assert(N) { ((N) ? (void) 0 : HandleAssertFailure (__FILE__, __LINE__, FUNCNAME, #N)); }
-#else
-# define assert(N) {}
-#endif // DEBUG
-
 #define for_axes(AX) for (const Axis AX : std::initializer_list<const Axis> ({X, Y, Z}))
 
 #define NUMERIC_ENUM_OPERATORS(T) \
@@ -121,7 +105,6 @@
 # define USE_QT5
 #endif
 
-
 #define FOR_ENUM_NAME_HELPER(LINE) enum_iterator_ ## LINE
 #define FOR_ENUM_NAME(LINE) FOR_ENUM_NAME_HELPER(LINE)
 
--- a/src/main.cpp	Sun Aug 30 03:52:03 2015 +0300
+++ b/src/main.cpp	Sun Aug 30 04:21:44 2015 +0300
@@ -51,7 +51,7 @@
 	QApplication app (argc, argv);
 	app.setOrganizationName (APPNAME);
 	app.setApplicationName (APPNAME);
-	InitCrashCatcher();
+	initCrashCatcher();
 	Config::Initialize();
 
 	// Load or create the configuration
--- a/src/main.h	Sun Aug 30 03:52:03 2015 +0300
+++ b/src/main.h	Sun Aug 30 04:21:44 2015 +0300
@@ -35,6 +35,5 @@
 // Null pointer
 static const std::nullptr_t null = nullptr;
 
-void HandleAssertFailure (const char* file, int line, const char* funcname, const char* expr);
 bool IsExiting();
 void Exit();
--- a/src/miscallenous.cpp	Sun Aug 30 03:52:03 2015 +0300
+++ b/src/miscallenous.cpp	Sun Aug 30 04:21:44 2015 +0300
@@ -81,20 +81,6 @@
 	3517, 3527, 3529, 3533, 3539, 3541, 3547, 3557, 3559, 3571,
 };
 
-static const long E10[] =
-{
-	1l,
-	10l,
-	100l,
-	1000l,
-	10000l,
-	100000l,
-	1000000l,
-	10000000l,
-	100000000l,
-	1000000000l,
-};
-
 // =============================================================================
 //
 // Grid stuff
@@ -255,8 +241,22 @@
 //
 void RoundToDecimals (double& a, int decimals)
 {
-	assert (decimals >= 0 and decimals < countof (E10));
-	a = round (a * E10[decimals]) / E10[decimals];
+	static const long e10[] =
+	{
+		1l,
+		10l,
+		100l,
+		1000l,
+		10000l,
+		100000l,
+		1000000l,
+		10000000l,
+		100000000l,
+		1000000000l,
+	};
+
+	if (decimals >= 0 and decimals < countof (e10))
+		a = round (a * e10[decimals]) / e10[decimals];
 }
 
 // =============================================================================
@@ -286,7 +286,6 @@
 		case Z: return a.z();
 	}
 
-	assert (false);
 	return 0.0;
 }
 
--- a/src/primitives.cpp	Sun Aug 30 03:52:03 2015 +0300
+++ b/src/primitives.cpp	Sun Aug 30 04:21:44 2015 +0300
@@ -114,7 +114,6 @@
 {
 	g_activeScanner = this;
 	QDir dir = LDPaths::primitivesDir();
-	assert (dir.exists());
 	m_baselen = dir.absolutePath().length();
 	GetRecursiveFilenames (dir, m_files);
 	emit starting (m_files.size());
--- a/src/ringFinder.cpp	Sun Aug 30 03:52:03 2015 +0300
+++ b/src/ringFinder.cpp	Sun Aug 30 04:21:44 2015 +0300
@@ -28,11 +28,10 @@
 bool RingFinder::findRingsRecursor (double r0, double r1, Solution& currentSolution)
 {
 	// Don't recurse too deep.
-	if (m_stack >= 5)
+	if (m_stack >= 5 or r1 < r0)
 		return false;
 
 	// Find the scale and number of a ring between r1 and r0.
-	assert (r1 >= r0);
 	double scale = r1 - r0;
 	double num = r0 / scale;
 
--- a/ui/bombbox.ui	Sun Aug 30 03:52:03 2015 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,104 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<ui version="4.0">
- <class>BombBox</class>
- <widget class="QDialog" name="BombBox">
-  <property name="geometry">
-   <rect>
-    <x>0</x>
-    <y>0</y>
-    <width>676</width>
-    <height>569</height>
-   </rect>
-  </property>
-  <property name="windowTitle">
-   <string>Fatal Error</string>
-  </property>
-  <layout class="QVBoxLayout" name="verticalLayout_2">
-   <item>
-    <layout class="QHBoxLayout" name="horizontalLayout">
-     <item>
-      <layout class="QVBoxLayout" name="verticalLayout">
-       <item>
-        <widget class="QLabel" name="label">
-         <property name="text">
-          <string/>
-         </property>
-         <property name="pixmap">
-          <pixmap resource="../ldforge.qrc">:/icons/bomb.png</pixmap>
-         </property>
-        </widget>
-       </item>
-       <item>
-        <spacer name="verticalSpacer">
-         <property name="orientation">
-          <enum>Qt::Vertical</enum>
-         </property>
-         <property name="sizeHint" stdset="0">
-          <size>
-           <width>20</width>
-           <height>138</height>
-          </size>
-         </property>
-        </spacer>
-       </item>
-      </layout>
-     </item>
-     <item>
-      <widget class="QTextEdit" name="m_text">
-       <property name="readOnly">
-        <bool>true</bool>
-       </property>
-      </widget>
-     </item>
-    </layout>
-   </item>
-   <item>
-    <widget class="QDialogButtonBox" name="buttonBox">
-     <property name="orientation">
-      <enum>Qt::Horizontal</enum>
-     </property>
-     <property name="standardButtons">
-      <set>QDialogButtonBox::Close</set>
-     </property>
-    </widget>
-   </item>
-  </layout>
- </widget>
- <resources>
-  <include location="../ldforge.qrc"/>
- </resources>
- <connections>
-  <connection>
-   <sender>buttonBox</sender>
-   <signal>accepted()</signal>
-   <receiver>BombBox</receiver>
-   <slot>accept()</slot>
-   <hints>
-    <hint type="sourcelabel">
-     <x>248</x>
-     <y>254</y>
-    </hint>
-    <hint type="destinationlabel">
-     <x>157</x>
-     <y>274</y>
-    </hint>
-   </hints>
-  </connection>
-  <connection>
-   <sender>buttonBox</sender>
-   <signal>rejected()</signal>
-   <receiver>BombBox</receiver>
-   <slot>reject()</slot>
-   <hints>
-    <hint type="sourcelabel">
-     <x>316</x>
-     <y>260</y>
-    </hint>
-    <hint type="destinationlabel">
-     <x>286</x>
-     <y>274</y>
-    </hint>
-   </hints>
-  </connection>
- </connections>
-</ui>

mercurial