Coder Social home page Coder Social logo

Comments (11)

zeffii avatar zeffii commented on July 30, 2024

I don't understand this code well enough to make a fix yet.

from sverchok.

ly29 avatar ly29 commented on July 30, 2024

This is in the category of non important errors, still an error.
What happens is that every time you create a socket by calling self.inputs.new() in def init(self, context)
the update function is called.
To fix add check that the 'matrix' key is in self.inputs, like:
if 'Float' in self.inputs and self.inputs['Float'].links:

The update function is furthermore called on every editor change...
Long term we should change sverchok to handle, this and the pynodes interface is also evolving.

from sverchok.

zeffii avatar zeffii commented on July 30, 2024

the update function is quite difficult to read.

from sverchok.

nortikin avatar nortikin commented on July 30, 2024

i didn't even looket to update function, to my shame. This difficult part for me

from sverchok.

ly29 avatar ly29 commented on July 30, 2024

Some notes on the general problem of the update function:

Note that this error is due to general problem with how blender calls the update function on editor changes, also before the init functon finishes. So update should be able to handle a state where, for example, only half the sockets that are created in init are created...

Once the node is created update is called on every node update, either from the general update function in node_s or from the updateNode function that we attach to changing number fields for example.

In conclusion, this should be fixed so the update function verifies that the socket exist before trying to access it. However this error is non critical in the way that once the node is created it does not happen again and nothing actually breakes because of this error.

If you want some further pointers on how the update system works I can try explain it better.

from sverchok.

zeffii avatar zeffii commented on July 30, 2024

thank you nortikin and ly29 getting sverchok this far, and acknowledging + explaining the scenario.of the error. It's good to document these things concretely..I've noticed other non critical errors cascade from them.

from sverchok.

zeffii avatar zeffii commented on July 30, 2024

can't we stick a

if not all([x in self.inputs for x in ['vertices', 'edg_pol', 'matrix']]):
      return

in the update, before checking the link presence. This way also the various separate checks on self.inputs for vertices edg_pol and matrix can be skipped.

like snippet:

    def update(self):
        global cache_viewer_baker
        cache_viewer_baker[self.name+'v'] = []
        cache_viewer_baker[self.name+'ep'] = []
        cache_viewer_baker[self.name+'m'] = []

        if not all([x in self.inputs for x in ['vertices', 'edg_pol', 'matrix']]):
            return

        if self.activate and (self.inputs['vertices'].links or self.inputs['matrix'].links):
            callback_disable(self.name)

            if self.inputs['vertices'].links and \
                type(self.inputs['vertices'].links[0].from_socket) == VerticesSocket:

                propv = SvGetSocketAnyType(self, self.inputs['vertices'])
                cache_viewer_baker[self.name+'v'] = dataCorrect(propv)
            else:
                cache_viewer_baker[self.name+'v'] = []

            if self.inputs['edg_pol'].links and \
                type(self.inputs['edg_pol'].links[0].from_socket) == StringsSocket:
                prope = SvGetSocketAnyType(self, self.inputs['edg_pol'])
                cache_viewer_baker[self.name+'ep'] = dataCorrect(prope)
                #print (prope)
            else:
                cache_viewer_baker[self.name+'ep'] = []

            if self.inputs['matrix'].links and \
               type(self.inputs['matrix'].links[0].from_socket) == MatrixSocket:
                    propm = SvGetSocketAnyType(self, self.inputs['matrix'])
                    cache_viewer_baker[self.name+'m'] = dataCorrect(propm)
            else:
                cache_viewer_baker[self.name+'m'] = []

   (.....)

from sverchok.

ly29 avatar ly29 commented on July 30, 2024

Yes something like that would work.

11 apr 2014 kl. 12:01 skrev "Dealga McArdle" [email protected]:

can't we stick a

if not all([x in self.inputs for x in ['vertices', 'edg_pol', 'matrix']]):
return
in the update, before checking the link presence. This way also the various separate checks on self.inputs for vertices edg_pol and matrix can be skipped.

like snippet:

def update(self):
    global cache_viewer_baker
    cache_viewer_baker[self.name+'v'] = []
    cache_viewer_baker[self.name+'ep'] = []
    cache_viewer_baker[self.name+'m'] = []

    if not all([x in self.inputs for x in ['vertices', 'edg_pol', 'matrix']]):
        return

    if self.activate and (self.inputs['vertices'].links or self.inputs['matrix'].links):
        callback_disable(self.name)

        if self.inputs['vertices'].links and \
            type(self.inputs['vertices'].links[0].from_socket) == VerticesSocket:

            propv = SvGetSocketAnyType(self, self.inputs['vertices'])
            cache_viewer_baker[self.name+'v'] = dataCorrect(propv)
        else:
            cache_viewer_baker[self.name+'v'] = []

        if self.inputs['edg_pol'].links and \
            type(self.inputs['edg_pol'].links[0].from_socket) == StringsSocket:
            prope = SvGetSocketAnyType(self, self.inputs['edg_pol'])
            cache_viewer_baker[self.name+'ep'] = dataCorrect(prope)
            #print (prope)
        else:
            cache_viewer_baker[self.name+'ep'] = []

        if self.inputs['matrix'].links and \
           type(self.inputs['matrix'].links[0].from_socket) == MatrixSocket:
                propm = SvGetSocketAnyType(self, self.inputs['matrix'])
                cache_viewer_baker[self.name+'m'] = dataCorrect(propm)
        else:
            cache_viewer_baker[self.name+'m'] = []

(.....)

Reply to this email directly or view it on GitHub.

from sverchok.

zeffii avatar zeffii commented on July 30, 2024

maybe: https://gist.github.com/zeffii/10456412

from sverchok.

ly29 avatar ly29 commented on July 30, 2024

Yes it should work fine here.
A potential problem with this as a general solution is that socket.name is not a guaranteed to be unique.

from sverchok.

zeffii avatar zeffii commented on July 30, 2024

OK, i'll stick to smaller changes for the time being. Thanks for the review, I understand the reservation.

from sverchok.

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.