View Issue Details

IDProjectCategoryView StatusLast Update
0000130FreeCADBugpublic2011-01-06 21:20
Reporterwmayer Assigned ToJriegel 
PrioritynormalSeveritymajorReproducibilityrandom
Status closedResolutionfixed 
Target Version0.11 
Summary0000130: Bugs and issues in sketcher
DescriptionFor me the sketcher crashes quite often but the problem is not reproducible. But it almost happens when leaving the edit mode inside ViewProviderSketch::unsetEdit() at the line EditRoot->removeAllChildren().

The stack trace reports about a heap corruption deep inside one of the SoMaterial nodes in the diffuseColor field. Since there is no double deletion of a wild pointer in the ViewProviderSketch class or an error with reference counting there must something happen with the diffuseColor field at runtime.

Today I realized a possible problem in the method createEditInventorNodes():
For the last line set EditCurvesMaterials there is defined an own SoMaterial node but not a new SoMaterialBinding for it. The behavior then is that the material binding of CurvesMaterials above is used which is set to PER_FACE.

Since EditCurvesMaterials doesn't set more than one color the binding of PER_FACE is of course wrong. I think there must be added a further material binding node which is set to OVERALL.

A second strange behavior is when dragging points and moving them. If you have a polyline and drag vertex XY then edge XY is highlighted during the movement.
TagsNo tags attached.
FreeCAD Information

Activities

wmayer

2010-08-04 17:41

administrator   ~0000284

I found the error of the funny behavior with the colors. Inside the method ViewProviderSketch::draw(bool) there are the lines:

    if (PreselectPoint >= 0 && PreselectPoint < (int) Points.size())
        color[PreselectPoint]=PreselectColor;

which is definitely wrong because it ses the color of the lines. This very likely also responsible for the crash. The lines must be:

    if (PreselectPoint >= 0 && PreselectPoint < (int) Points.size())
        pcolor[PreselectPoint]=PreselectColor;

I have already checked-in the fix.

There is also another bug I encountered. If you create a polyline and move very fast, click to create a point but do not stop moving and click again you'll produce two lines which are disconnected.

Jriegel

2010-08-04 19:48

administrator   ~0000285

I experienced the same crashes (seldom but steady) and located it to the
unsetEdit() methode, when all children of the EditRoot get deleted..

But maybe you fixed it already with pcolor (which has the potential to
overwrite the stack...).

I will look into the polyline!

wmayer

2010-08-05 06:56

administrator   ~0000287

Another thing I noticed with the polyline command. It would be good if it could create a wire instead of a compound because otherwise commands like padding don't work.

Jriegel

2010-08-05 12:58

administrator   ~0000288

Yupp,
at the moment I do it the lazy way by fuse(), which create a compound!??

Its in:
Sketcher::Sketch::toShape()

At the end what I would like to do is create with the geos and the constraints
the vertexes and edges one by one, to ensure the the same position after
a change. Which is very important for later linking to faces or edges.

Jriegel

2010-08-05 14:05

administrator   ~0000289

The crash after edit has vanished after you fix. The same for you?

wmayer

2010-08-06 05:48

administrator   ~0000290

I'm not sure. When leaving edit mode I don't have a crash anymore but right now it crashed when moving one of the vertices directly after picking.

It's good possible that this results from a further bug.

wmayer

2010-08-06 06:04

administrator   ~0000291

To the compound: Yes, the boolean fuse produces compounds but for a polyline it's just a container with a single wire inside.

Since for a general sketch there can be several wires or free edges inside the compound one can count the wires, count the edges and if there is only one wire count the edges of this wire. So, if there is only one wire and number of edges in the wire is equal to the number of edges inside the compound we can be sure that there is exactly one wire inside and nothing else.

> At the end what I would like to do is create with the geos and the constraints
> the vertexes and edges one by one, to ensure the the same position after
> a change. Which is very important for later linking to faces or edges.
I'm not sure if the fuse() can guarantee this. At least if it's allowed to insert a line afterwards somewhere I guess the fuse() will fail.

Maybe this algorithm can be useful for you:

    void connectEdges (const std::list<TopoDS_Edge>& edges, std::list<TopoDS_Wire>& wires) const
    {
        std::list<TopoDS_Edge> edge_list = edges;
        while (edge_list.size() > 0) {
            BRepBuilderAPI_MakeWire mkWire;
            // add and erase first edge
            mkWire.Add(edge_list.front());
            edge_list.erase(edge_list.begin());

            TopoDS_Wire new_wire = mkWire.Wire(); // current new wire

            // try to connect each edge to the wire, the wire is complete if no more egdes are connectible
            bool found = false;
            do {
                found = false;
                for (std::list<TopoDS_Edge>::iterator pE = edge_list.begin(); pE != edge_list.end();++pE) {
                    mkWire.Add(*pE);
                    if (mkWire.Error() != BRepBuilderAPI_DisconnectedWire) {
                        // edge added ==> remove it from list
                        found = true;
                        edge_list.erase(pE);
                        new_wire = mkWire.Wire();
                        break;
                    }
                }
            }
            while (found);
            wires.push_back(new_wire);
        }
    }

Jriegel

2010-08-07 07:23

administrator   ~0000292

delivers now wires, but have still an issue with closing a polyline not at
the beginning....

wmayer

2010-08-30 12:56

administrator   ~0000310

Sketcher crashes when forcing with the Close button in the task panel to exit edit mode and reenter edit mode if the last operation wasn't completed. This is because no SketchHandler instance is created anymore.

BTW, it seems there is also a memory leak when leaving edit mode because the sketch handler instance isn't destroyed.

Jriegel

2011-01-06 21:20

administrator   ~0000485

This are a very unspecific error report. Close this in favour for new ones which are more specific....

Issue History

Date Modified Username Field Change
2010-08-04 15:18 wmayer New Issue
2010-08-04 15:18 wmayer Status new => assigned
2010-08-04 15:18 wmayer Assigned To => Jriegel
2010-08-04 17:41 wmayer Note Added: 0000284
2010-08-04 19:48 Jriegel Note Added: 0000285
2010-08-05 06:56 wmayer Note Added: 0000287
2010-08-05 12:58 Jriegel Note Added: 0000288
2010-08-05 14:05 Jriegel Note Added: 0000289
2010-08-06 05:48 wmayer Note Added: 0000290
2010-08-06 06:04 wmayer Note Added: 0000291
2010-08-07 07:23 Jriegel Note Added: 0000292
2010-08-30 12:56 wmayer Note Added: 0000310
2011-01-06 21:20 Jriegel Note Added: 0000485
2011-01-06 21:20 Jriegel Status assigned => closed
2011-01-06 21:20 Jriegel Resolution open => fixed