-
-
Notifications
You must be signed in to change notification settings - Fork 42
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
Signal connection does not work as expected with generics #69
Comments
Thanks for the report! |
Did you use QtJambi native binaries from Maven or did you compile it yourself? |
I checked your code. The reason for the crash is not the use of generics. It is the line |
I use |
Yes, it would be correct. All other type-checking is compiler's job. |
Try to rename method elementModified in ReceiverObject. The name must be different from the signal name. Then try again. |
Yes, I was renaming signal in ReceiverObject just now. You are right. Everything starts working after that. But it's not obvious! I will consider PR-ing some docs about signal usage subtleties in qtjambi, if you don't mind. Thanks for your response! |
The only unexplained yet is test |
I'm currently checking it. |
Unfortunately, it is not possible to calculate recursive signal connections in Java. Well, even native Qt doen't check it. I Also don't want to add a test if you are connecting a signal to itself. That costs additional runtime for something programmers normally wouldn't do. Here, we have the misinterpretation caused by Java allowing methods and fields to have the same name. What I have done now is to treat a method handle as lambda expression if the Java method points to a signal. |
QtJambi simply does not support variable generic types like |
Great! Thank you! |
Resolved in QtJambi 6.3.3 / 6.2.6 / 5.15.8 |
Describe the bug
Connecting method call to signal has unexpected and erroneous behavior with generics. For example, connection with method reference does not work, but connection with equivalent lambda does. Problem arises when you emit signal with such connection. And wise versa, in some cases exception appears at once I try to connect lambda.
I suspect method
private synchronized <Slot extends Serializable> QMetaObject.Connection addConnectionToSlotObject(SlotConnectionFactory<Slot> factory, Slot slotObject, Qt.ConnectionType[] connectionType)
inQtJambiSignals
class.To Reproduce
I've simplified my cases to unit-test class. It's runnable with
junit 5.8.2
(jupiter). Here it is entirely:Expected behavior
I expect that in all aforementioned cases connection is functional. And there should not be any difference between using method reference and lambda as slot. And the most uncomfortable was
SIGSEGV
results.System:
Additional context
SIGSEGV
may be specific to linux, and on windows or on mac it may sound different. But I tried it on linux only.testSignalToSignal
).The text was updated successfully, but these errors were encountered: