ConnectionClassThread.Close (this is a method I added to the sub-class)
ssWired.Observers.GotConnectionClosedNotify NEW ssWired.GotConnectionClosedClass(me) // broadcast the closure
ssWired.Observers.GotConnectionClosedNotify
[code] // GotConnectionClosed
if (pData <> Nil) then
for each o as ssWired.Observers.GotConnectionClosedInterface in GotConnectionClosedObservers
o.GotConnectionClosed pData
next
end if[/code]
Private GotConnectionClosedObservers() As GotConnectionClosedInterface
Now the fun starts
Everything works fine, and all the other objects and windows that have that class interface get notified as they should, but I have one particular window sub-class that does not get called… In the for each o loop, the loop skips over the window… I modified the loop to the following:
[code] // GotConnectionClosed
if (pData <> Nil) then
for each o as Variant in GotConnectionClosedObservers
DIM tIsA As Boolean = (o IsA ssWired.Observers.GotConnectionClosedInterface)
break
next
end if[/code]
In the modified code the loop runs for the window and the variable tIsA returns TRUE… I even tried to type cast the variant, but it still does not fire off… All the other class interfaces on that window work, just not this one…
Does that window subclass actually implement the method? Is there a subclass of that class? Some method is being called, but since methods are virtual, it may not be the one you expect.
When you say “The window has the method” are you sure the method’s parameter is of the correct type (as I understand it from your code there is one parameter “pData”)?
yup, the class interface was created with the one method and then added to the window and the method was automatically populated… I even removed the method and the interface, restarted Xojo and re-did it, but still nothing…
You could filter out the problematic window in the loop and the cast it to its window type:
if (pData <> Nil) then
for each o as Variant in GotConnectionClosedObservers
If o IsA TheProblematicWindowClass Then
Dim win As TheProblematicWindowClass = TheProblematicWindowClass(o)
break
End
next
end if
(sorry, pressed the button by accident)
… and then further investigate the win variable with introspection to see if it implements the requested method.
No error, the inner code of the if statement does not run, same as the original unmodified code… I’m exploring the introspection idea, just taking a few minutes for me to figure out the sample code from the docs to what I need… Thanks for your help and ideas where to look
Good. But still, in your loop you must be able to cast the o variable to the variable of type “ProblematicWindow”
So in two steps:
can you filter out the window in the loop?
if (pData <> Nil) then
for each o as Variant in GotConnectionClosedObservers
If o IsA TheProblematicWindowClass Then
Break// Do you get here?
...
End
2. then try to cast
Dim win As TheProblematicWindowClass = TheProblematicWindowClass(o)