GithubHelp home page GithubHelp logo

Comments (5)

wwmayer avatar wwmayer commented on September 22, 2024

when calling the "Involute Gear" command from PartDesign

Does this only happen with this command or with others too that load a task dialog (e.g. Pad, Pocket, ...)?

from freecad.

wwmayer avatar wwmayer commented on September 22, 2024

I wonder whether the two toEnum() functions really have to be that complicated and that we can't simply write:

qsizetype PythonWrapper::toEnum(PyObject* pyPtr)
{
    try {
        Py::Long longObj(PyNumber_Long(pyPtr), true);
        return longObj.as_long();
    }
    catch (Py::Exception&) {
        Base::PyException e;
        e.ReportException();
        return 0;
    }
}

qsizetype PythonWrapper::toEnum(const Py::Object& pyobject)
{
    return toEnum(pyobject.ptr());
}

This will have the same effect like the casts to an int on Python side:
return int(QtGui.QDialogButtonBox.Ok | QtGui.QDialogButtonBox.Cancel)

In #13611 it was claimed that this cast caused various problems but when looking at the mentioned issues all of them had other reasons and thus I doubt that Shiboken::Enum::getValue is needed at all.

from freecad.

wwmayer avatar wwmayer commented on September 22, 2024

I haven't figured out who really caused this. It could be libshiboken

For some reason the passed value to Shiboken::Enum::getValue is not of the expected type in your case and that's why check() causes the assert to fail:

long Shiboken::Enum::getValue(PyObject *enumItem)
{
    assert(Shiboken::Enum::check(enumItem));
...
}

from freecad.

NomAnor avatar NomAnor commented on September 22, 2024

when calling the "Involute Gear" command from PartDesign

Does this only happen with this command or with others too that load a task dialog (e.g. Pad, Pocket, ...)?

From the code I think this will happen with any dialog that is created in python, but I haven't checked.

Using PyNumber_Long will fixed it. There are multiple helper functions to convert from python to c++. I a sense, using toEnum in getStandardButtons is just wrong because it returns a QFlags not an enum so it should call a toFlags function. On the other hand toEnum returns an int not an enum which should probably a template function with a static_cast<T>() in it.

I haven't figured out who really caused this. It could be libshiboken

For some reason the passed value to Shiboken::Enum::getValue is not of the expected type in your case and that's why check() causes the assert to fail:

That was clear, but it worked before and I supect some weired interactions with package updates. But It could also be just the PR that changed the int casts.

I can test with your simplified function, I'm sure that will work.

from freecad.

NomAnor avatar NomAnor commented on September 22, 2024

@wwmayer I tested the simplified functions you posted and the crash is gone.

from freecad.

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.