Skip to content
New issue

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

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Null pointer on connecting nodes in certain examples #441

Open
chateauferret opened this issue Sep 19, 2024 · 3 comments
Open

Null pointer on connecting nodes in certain examples #441

chateauferret opened this issue Sep 19, 2024 · 3 comments

Comments

@chateauferret
Copy link

In some of the examples, e.g. the calculator, there is a crash because of a null ProxyWidget pointer in places like this in NodeGraphicsObject.cpp line 81:

void NodeGraphicsObject::updateQWidgetEmbedPos()
{
_proxyWidget->setPos(nodeScene()->nodeGeometry().widgetPosition(_nodeId));
}

I might try and fix that by simply testing the pointer for NULL before it is dereferenced, but thought it wise to consult you first.

@chateauferret
Copy link
Author

That's on Qt 6.7.2 in Microsoft Windows (and seen on two different computers btw).

@chateauferret
Copy link
Author

OK, so it seems to behave if I just make sure the ProxyWidget pointer isn't NULL before I try to dereference it. There are a few other places where I think this is a risk, because some of the other examples are crashing at similar but different places. So I'll go through and look for them then see if I can put down a pull request.

Root cause seems to be line 91, in the method embedQWidget where _graphModel.nodeData must be returning NULL.

Think we can fix this without too much bother then.

@chateauferret
Copy link
Author

Slightly better, let's suggest this embedQWidget - always assign a value to the pointer.

void NodeGraphicsObject::embedQWidget()
{
    AbstractNodeGeometry &geometry = nodeScene()->nodeGeometry();
    geometry.recomputeSize(_nodeId);
    _proxyWidget = new QGraphicsProxyWidget(this);
    if (auto w = _graphModel.nodeData(_nodeId, NodeRole::Widget).value<QWidget *>()) {
        _proxyWidget->setWidget(w);
        ....

chateauferret added a commit to chateauferret/calenhad_dataflow that referenced this issue Sep 19, 2024
Fixed NULL pointer exception on connecting nodes (paceholder#441)
chateauferret added a commit to chateauferret/calenhad_dataflow that referenced this issue Sep 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant