From: cilix42 Date: Tue, 28 Aug 2007 10:40:42 +0000 (+0000) Subject: Remove some warnings and fix crash in 3D box tool X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=492de225e9b11f35d98b6b75efa58e115ee688fa;p=inkscape.git Remove some warnings and fix crash in 3D box tool --- diff --git a/src/box3d-context.cpp b/src/box3d-context.cpp index f5a76655c..8b8b1ca99 100644 --- a/src/box3d-context.cpp +++ b/src/box3d-context.cpp @@ -360,12 +360,11 @@ static gint sp_3dbox_context_root_handler(SPEventContext *event_context, GdkEven bc->ctrl_dragged = event->motion.state & GDK_CONTROL_MASK; - if (event->motion.state & GDK_SHIFT_MASK && !bc->extruded) { + if (event->motion.state & GDK_SHIFT_MASK && !bc->extruded && bc->item) { /* once shift is pressed, set bc->extruded (no need to create further faces; all of them are already created in sp_3dbox_init); since we made the rear face invisible in the beginning to avoid "flashing", we must set its correct style now */ bc->extruded = true; - g_assert (bc->item); SP_3DBOX (bc->item)->faces[5]->set_style (NULL, true); } diff --git a/src/box3d-face.cpp b/src/box3d-face.cpp index de52031da..a1b7ae863 100644 --- a/src/box3d-face.cpp +++ b/src/box3d-face.cpp @@ -236,7 +236,6 @@ void Box3DFace::set_path_repr() void Box3DFace::set_curve() { if (this->path == NULL) { - g_warning("this->path is NULL! \n"); return; } NR::Matrix const i2d (sp_item_i2d_affine (SP_ITEM (this->parent_box3d))); diff --git a/src/box3d.cpp b/src/box3d.cpp index 8df5c3b52..0cf0743db 100644 --- a/src/box3d.cpp +++ b/src/box3d.cpp @@ -242,8 +242,6 @@ sp_3dbox_update(SPObject *object, SPCtx *ctx, guint flags) ((SPObjectClass *) (parent_class))->update(object, ctx, flags); } - - static Inkscape::XML::Node *sp_3dbox_write(SPObject *object, Inkscape::XML::Node *repr, guint flags) { SP3DBox *box = SP_3DBOX(object); @@ -666,24 +664,24 @@ static bool sp_3dbox_recompute_z_orders_by_corner_configuration (SP3DBox *box) guint visible_front_corner = (((c_cmp & front_rear_axis) == (c1 & front_rear_axis)) ? c1 : c2); visible_faces = sp_3dbox_faces_meeting_in_corner (visible_front_corner); } else { - g_print ("Warning: Unhandled case. Current z-orders remain unchanged.\n"); + /* Under what conditions do we end up here? Can we safely ignore this case? */ return false; } break; } default: - g_print ("Warning: Unhandled case. Current z-orders are not changed.\n"); + /* Under what conditions do we end up here? Can we safely ignore this case? */ return false; } - // check for weird corner configurations that cannot be handled by the above code + /* catch weird corner configurations; these should be theoretically impossible, but maybe + occur in (almost) degenerate cases due to rounding errors, for example */ if (std::find (visible_faces.begin(), visible_faces.end(), -1) != visible_faces.end()) { - g_warning ("Theoretically impossible corner configuration\n"); return false; } - // sort the list of visible faces for later use (although it may be already sorted anyway) + /* sort the list of visible faces for later use (although it may be already sorted anyway) */ std::sort (visible_faces.begin(), visible_faces.end()); std::vector invisible_faces; @@ -695,9 +693,8 @@ static bool sp_3dbox_recompute_z_orders_by_corner_configuration (SP3DBox *box) std::swap (visible_faces, invisible_faces); if (!sp_3dbox_is_subset_or_superset (visible_faces, box->currently_visible_faces) && !sp_3dbox_differ_by_opposite_faces (visible_faces, box->currently_visible_faces)) { - // FIXME: Hopefully this case is only caused by rounding errors or something similar; - // does it need further investigation? - g_warning ("Can't find out which faces are visible and which aren't ...\n"); + /* Hopefully this case is only caused by rounding errors or something similar; + does it need further investigation? */ return false; } } diff --git a/src/line-geometry.cpp b/src/line-geometry.cpp index 549defb2e..5d8eca8a1 100644 --- a/src/line-geometry.cpp +++ b/src/line-geometry.cpp @@ -55,7 +55,8 @@ Line &Line::operator=(Line const &line) { NR::Maybe Line::intersect(Line const &line) { NR::Coord denom = NR::dot(v_dir, line.normal); NR::Maybe no_point = NR::Nothing(); - g_return_val_if_fail(fabs(denom) > 1e-6, no_point ); + if (fabs(denom) < 1e-6) + return no_point; NR::Coord lambda = (line.d0 - NR::dot(pt, line.normal)) / denom; return pt + lambda * v_dir;