Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Bugfix dynamictag fixes #1339 #1341

Merged
merged 1 commit into from Jun 19, 2012

Conversation

Projects
None yet
4 participants
Contributor

gameoverhack commented Jun 18, 2012

Would be good to double check that this is doing the right thing in regards dynamic tag casting...at least it lets me compile :-)

Contributor

kylemcdonald commented Jun 18, 2012

great! does anyone have an example where they need to use this?

i'm actually kind of inclined to just remove it completely unless someone can show how they would use it -- since so far it's caused more problems than it has done anything to help :)

Member

tgfrerer commented Jun 18, 2012

Agreed, it's probably safer to take dynamic_pointer_cast out for now.

We use c-style reference downcasts with ofPtr at some locations, e.g. in ofGetGLRenderer():

ofPtr<ofGLRenderer> ofGetGLRenderer(){
    if(ofGetCurrentRenderer()->getType()=="GL"){
        return (ofPtr<ofGLRenderer>&)ofGetCurrentRenderer();
    }else if(ofGetCurrentRenderer()->getType()=="collection"){
        return ((ofPtr<ofRendererCollection>&)ofGetCurrentRenderer())->getGLRenderer();
    }else{
        return ofPtr<ofGLRenderer>();
    }
}

Where

(ofPtr<ofGLRenderer>&)ofGetCurrentRenderer() 

is a c-style reference downcast from

ofPtr<ofBaseRenderer> renderer;

which could be written:

dynamic_pointer_cast<ofGLRenderer>(ofGetCurrentRenderer())

I was hoping for a more explicit method of downcasting ofPtr, but I fear I over-complicated things :/

Contributor

elliotwoods commented Jun 18, 2012

I would kinda like this to work as it'd have made ofxCvGui2 cleaner. but it wasn't necessary

to comment. i've just tested this on VS2010 and it solves the dynamic tag compile errors for me (not tested the actual dynamic cast functionality)

Contributor

kylemcdonald commented Jun 19, 2012

i just read up some more on exactly what this is doing, and it is pretty essential. i'm going to test the behavior right now. since this is pretty critical (keeping things from building on vs2010 at the moment) if it works i'll merge it.

Member

tgfrerer commented Jun 19, 2012

Sweet! Cheers =)

@kylemcdonald kylemcdonald merged commit 56d2c6c into openframeworks:develop Jun 19, 2012

Contributor

kylemcdonald commented Jun 19, 2012

i had to add one more #ifdef case, which was for ofPtr<_Tp> dynamic_pointer_cast(const ofPtr<_Tp1>& __r)

then i tested it by modifying an object cast to its inherited class from the base class, and it works.

to summarize: vs2010 works again, and hopefully this makes your life a little easier @elliotwoods :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment