Xcode 8 and ofPath? or class syntax? or something else?

Hi there,

I had automatic updates on my macbook and apple has been super useful by updating to Xcode 8. yayyyyyyyyy… So the problem i have found myself in is that an app that worked perfectly in Xcode 7 is now crashing during runtime. It all sits around this class i have for drawing unfilled circles, i have been using it multiple times inside a few different classes and it has been working perfectly until now, i have tested this with 9.0 and 9.4 and i get the same results

Here’s the offending class:

#ifndef empty_Circle_h
#define empty_Circle_h

#include "ofMain.h"

class EmptyCircle{
public:
    void setup(ofPoint _pos, int _radius, int _thickness, ofColor _color, int _startAngle, int _endAngle);
    void changeArc(int _startAngle, int _endAngle, bool fwd);
    void changeRadius(int _newRad);
    void changeColour(ofColor _color);
    void draw(ofPoint _pos);
private:
    ofPoint pos;
    int radius;
    int thickness;
    int startAngle;
    int endAngle;
    ofColor color;
    ofPath circle;
    bool forward;
};

#endif /* empty_Circle_h */

and then:

#include "emptyCircle.h"

void EmptyCircle::setup(ofPoint _pos, int _radius, int _thickness, ofColor _color, int _startAngle, int _endAngle){
    pos=_pos;
    radius=_radius;
    thickness=_thickness;
    color=_color;
    startAngle=_startAngle-90;
    endAngle=_endAngle-90;
    forward=true;
    ofPoint centre;
    centre.set(0, 0);
    cout<<"circles"<<endl;
    circle.clear();
    cout<<"circles 1"<<endl;
    circle.arc(centre, radius, radius, startAngle, endAngle, forward);
    cout<<"circles 2"<<endl;
    circle.close();
    circle.arc(centre, radius+thickness, radius+thickness, startAngle, endAngle, forward);
    circle.setColor(color);
    circle.setCircleResolution(33);
    cout<<"circles complete"<<endl;
}

void EmptyCircle::draw(ofPoint _pos){
    if(radius<=0 || radius>10000)return;
    pos=_pos;
    ofPushMatrix();
    ofTranslate(pos.x, pos.y);
    ofSetColor(color);
    circle.draw();
    ofPopMatrix();
}
void EmptyCircle::changeColour(ofColor _color){
    color=_color;
    circle.setColor(color);
}
void EmptyCircle::changeArc(int _startAngle, int _endAngle, bool _fwd){
    forward=_fwd;
    startAngle = _startAngle;
    endAngle = _endAngle;
    circle.clear();
    circle.arc(ofPoint(0,0), radius, radius, startAngle, endAngle, forward);
    circle.close();
    circle.arc(ofPoint(0,0), radius+thickness, radius+thickness, startAngle, endAngle, forward);
}
void EmptyCircle::changeRadius(int _newRad){
    radius=_newRad;
    circle.clear();
    circle.arc(ofPoint(0,0), radius, radius, startAngle, endAngle, forward);
    circle.close();
    circle.arc(ofPoint(0,0), radius+thickness, radius+thickness, startAngle, endAngle, forward);
}

then using it like this:

EmptyCircle circle;
EmptyCircle centreCircle;

So what happens in classes that use more than one instance of this is that it will complete setup for the first instance and then crashes during the second instance setup at the first circle.arc(). So the console then looks like this:

circles
circles 1
circles 2
circles complete
circles
circles 1

Have I been using this class all this time in a way that shouldn’t have really worked and Xcode 8 has shown that by falling over, or is it something Xcode 8 is breaking for no good reason?

Many Thanks,
Miles

can you try changing lines 423 - 427 in ofPath from:

#elif HAS_TLS
    static thread_local ofTessellator tessellator;
#else
    ofTessellator tessellator;
#endif

to:

    ofTessellator tessellator;

and remove lines 6 - 10 in ofPath.cpp:

#if defined(TARGET_EMSCRIPTEN)
    ofTessellator ofPath::tessellator;
#elif HAS_TLS
    thread_local ofTessellator ofPath::tessellator;
#endif

Thanks Arturo,

Sorry but i should have said that I’m using the iOS release. I found these lines of code, although not quite at the same line numbers as you have said i assume because I’m using the iOS version. Unfortunately the edits you suggested haven’t worked for me.