Giter VIP home page Giter VIP logo

Comments (5)

thomthom avatar thomthom commented on August 10, 2024

Sounds like it's accessing deleted data. I think it stems from AttributeDictionary::get_attribute

https://github.com/jimfoltz/Sketchup-API-C-Wrapper/blob/28c8523905832c84ab77802a49c6bb904a170a01/src/SUAPI-CppWrapper/model/AttributeDictionary.cpp#L137-L153

I creates a TypedValue value_out; on the stack - and then return this as a copy. But the deconstructor for value_out will release the Ref once the function exits;

https://github.com/jimfoltz/Sketchup-API-C-Wrapper/blob/28c8523905832c84ab77802a49c6bb904a170a01/src/SUAPI-CppWrapper/model/TypedValue.cpp#L156

The temporary TypedValue in AttributeDictionary::get_attribute needs to be non-owning.

This also means that the wrapper objects needs to generally be passed as refs (C++ refs) as parameters to other functions.

Side node, I think owned is a more precise term than attached;
https://github.com/jimfoltz/Sketchup-API-C-Wrapper/blob/28c8523905832c84ab77802a49c6bb904a170a01/include/SUAPI-CppWrapper/model/Entity.hpp#L59-L62

from sketchup-api-c-wrapper.

TommyKaneko avatar TommyKaneko commented on August 10, 2024

I have a feeling that this commit will fix the issue:
4c1837f

...but needs testing.

I am beginning to think that casting wrapper objects to Ref* pointers may be a bad idea. I thought it might be useful once, now I think it makes it more likely that mistakes are made with its use.

Side node, I think owned is a more precise term than attached;

I disagree - 'owned' could suggest that the wrapper object owns the Ref that it is wrapping, or that the Ref is owned by another parent Ref. Besides, general users tend not to have to deal with this variable - it is only for the developers really.

from sketchup-api-c-wrapper.

thomthom avatar thomthom commented on August 10, 2024

I am beginning to think that casting wrapper objects to Ref* pointers may be a bad idea. I thought it might be useful once, now I think it makes it more likely that mistakes are made with its use.

Agree - one should be careful with implicit casts.

from sketchup-api-c-wrapper.

thomthom avatar thomthom commented on August 10, 2024

...but needs testing.

Did you try with Jim's unit tests?

from sketchup-api-c-wrapper.

TommyKaneko avatar TommyKaneko commented on August 10, 2024

So it doesn't solve the problem, according to Jim here: 4c1837f

I'll take a look at it once I have my testing environment set up.

from sketchup-api-c-wrapper.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.