-
Notifications
You must be signed in to change notification settings - Fork 761
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
qtcollider: QcSignalSpy prevent creating QVariant<QVariant> #5216
qtcollider: QcSignalSpy prevent creating QVariant<QVariant> #5216
Conversation
10c9bef
to
e95df8e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks! would you mind also undoing the change you made in #4883 to get around this?
args << QVariant(type, argData[i + 1]); | ||
if (type == QMetaType::QVariant) { | ||
// avoid creating a QVariant<QVariant> | ||
args << QVariant(type, argData[i + 1]).value<QVariant>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think this is exactly the same, just fewer steps :)
args << QVariant(type, argData[i + 1]).value<QVariant>(); | |
args << argData[i + 1]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is also what I would think, but then it complains that QVariant(void*) is a deleted function.
QcSignalSpy.h:96:40: error: use of deleted function ‘QVariant::QVariant(void*)’
96 | args << argData[i+1];
/usr/include/qt/QtCore/qvariant.h:499:12: note: declared here
499 | inline QVariant(void *) = delete;
Does this mean that Qt explicitly forbids "casting" a (void*) to QVariant?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ohh i missed that was the type of argData (void**
). yeah, this is fine the way it is, i think this would also work:
args << QVariant(type, argData[i + 1]).value<QVariant>(); | |
args << *static_cast<const QVariant*>(argData[i + 1]); |
but that's just a hunch.
inline QVariant(void *) = delete;
is a constructor for QVariant, when marked with "delete" it means the compiler will forbid calling it.
thanks for looking at this @brianlheim! And with this PR we still can't pass a QMap back to sclang. Thinking about the use-case with javascript, I would suggest that the user serializes a map into a JSON string, which can then be deserialized in sclang. Just thought we could add this to WebView::-runJavascript documentation, and then we are good to go for me. |
e95df8e
to
fb29fda
Compare
ok.. by "JSON string" do you just mean a string that holds a JSON object? this was a bug before and after #4883 right? if so, don't try to fix it here. |
Before #4883 return values from javascript were completely broken (IIRC): we couldn't even return strings. I wouldn't fix this in any way here, definitely needs more thinking, for now I would just update documentation about it. |
ok, sounds good! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks!
Purpose and Motivation
I encountered a problem while working on #4883 : when sclang calls
WebView::runJavascript
, it would fail to get back return values. I digged into it and this is how it works:The problem is that the callback for runJavascript returns a QVariant already, that when wrapped becomes a QVariant, which QtCollider::runLang doesn't know how to translate into an object sclang can use.
So, in this PR, I'm just checking in QcSignalSpy if an argument is already a QVariant, preventing it then to being made into a QVariant
Types of changes