[GH-ISSUE #14] Support for detecting if an object is "connected" to Qml in some way. #8

Closed
opened 2026-05-05 10:58:47 -06:00 by gitea-mirror · 3 comments
Owner

Originally created by @pauldotknopf on GitHub (Jul 17, 2018).
Original GitHub issue: https://github.com/qmlnet/qmlnet/issues/14

public static class Qml
{
    static bool IsConnected(this object instance)
    {
        // Return true if the Qml is currently alive in Qml in any way, otherwise false.
    }
}
Originally created by @pauldotknopf on GitHub (Jul 17, 2018). Original GitHub issue: https://github.com/qmlnet/qmlnet/issues/14 ```c# public static class Qml { static bool IsConnected(this object instance) { // Return true if the Qml is currently alive in Qml in any way, otherwise false. } } ```
Author
Owner

@pauldotknopf commented on GitHub (Jul 17, 2018):

This should be done before #7.

This will require us to track .NET instances that are currently alive in the Qml world.

This is the rough idea:

We store the instances in .NET with a Dictionary<object, NetInstance>. When sending an object to Qml, we need to check if an existing NetInstance already exists in the dictionary and use it, otherwise create one. Within the deconstructor of NetInstance, we need to reach out to the .NET world and remove the instance from our global dictionary.

IsConnected will simple do a instance.ContainsKey to determine if object is currently wrapped in Qml/V8 somewhere.

<!-- gh-comment-id:405653029 --> @pauldotknopf commented on GitHub (Jul 17, 2018): This should be done before #7. This will require us to track .NET instances that are currently alive in the Qml world. This is the rough idea: We store the instances in .NET with a ```Dictionary<object, NetInstance>```. When sending an object to Qml, we need to check if an existing ```NetInstance``` already exists in the dictionary and use it, otherwise create one. Within the deconstructor of ```NetInstance```, we need to reach out to the .NET world and remove the instance from our global dictionary. ```IsConnected``` will simple do a ```instance.ContainsKey``` to determine if object is currently wrapped in Qml/V8 somewhere.
Author
Owner

@devmil commented on GitHub (Jul 19, 2018):

no longer needed?

<!-- gh-comment-id:406409018 --> @devmil commented on GitHub (Jul 19, 2018): no longer needed?
Author
Owner

@pauldotknopf commented on GitHub (Jul 20, 2018):

Yeah, not sure the use case anymore. I was initially only doing to do this to ensure the underlying facilities were in place for doing signals, but that was solved on your end.

<!-- gh-comment-id:406499316 --> @pauldotknopf commented on GitHub (Jul 20, 2018): Yeah, not sure the use case anymore. I was initially only doing to do this to ensure the underlying facilities were in place for doing signals, but that was solved on your end.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: github-starred/qmlnet#8
No description provided.