From 9438460039f077f67afb398b0623992fe6a6f0e2 Mon Sep 17 00:00:00 2001 From: "Eduardo M. Fleury" Date: Tue, 14 Jul 2009 17:53:52 -0300 Subject: QGraphicsAnchorLayout: Use Q_ASSERT instead of "if" tests Replacing two IF tests for Q_ASSERT statements instead. These tests are sanity checks that should never be false. Signed-off-by: Eduardo M. Fleury Reviewed-by: Anselmo Lacerda S. de Melo --- src/gui/graphicsview/qgraph_p.h | 14 +++++++------- src/gui/graphicsview/qgraphicsanchorlayout_p.cpp | 6 +++--- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/gui/graphicsview/qgraph_p.h b/src/gui/graphicsview/qgraph_p.h index 9128df8..053114b 100644 --- a/src/gui/graphicsview/qgraph_p.h +++ b/src/gui/graphicsview/qgraph_p.h @@ -174,13 +174,13 @@ protected: void removeDirectedEdge(Vertex *from, Vertex *to) { QHash *adjacentToFirst = m_graph.value(from); - if (adjacentToFirst) { - adjacentToFirst->remove(to); - if (adjacentToFirst->isEmpty()) { - //nobody point to 'from' so we can remove it from the graph - m_graph.remove(from); - delete adjacentToFirst; - } + Q_ASSERT(adjacentToFirst); + + adjacentToFirst->remove(to); + if (adjacentToFirst->isEmpty()) { + //nobody point to 'from' so we can remove it from the graph + m_graph.remove(from); + delete adjacentToFirst; } } diff --git a/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp b/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp index e969e40..c83f939 100644 --- a/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp +++ b/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp @@ -701,10 +701,10 @@ void QGraphicsAnchorLayoutPrivate::removeAnchor(QGraphicsLayoutItem *firstItem, AnchorVertex *v1 = internalVertex(firstItem, firstEdge); AnchorVertex *v2 = internalVertex(secondItem, secondEdge); + Q_ASSERT(v1 && v2); + // Remove edge from graph - if (v1 && v2) { - graph[edgeOrientation(firstEdge)].removeEdge(v1, v2); - } + graph[edgeOrientation(firstEdge)].removeEdge(v1, v2); // Decrease vertices reference count (may trigger a deletion) removeInternalVertex(firstItem, firstEdge); -- cgit v0.12