Method: QObject#unwrapQObject

Defined in:
lib/QWebChannel/QObject.rb

#unwrapQObject(response) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/QWebChannel/QObject.rb', line 7

def unwrapQObject(response)
    puts "response class: #{response.class}" #debug
    if (response.is_a?(Array))
        ret = []
        
        response.each do |responseI|
            ret << @object.unwrapQObject(responseI)
        end
        
        return ret
    end #if (response.is_a?(Array))
    
    
    if (!response || response.is_a?(Fixnum) || response.is_a?(TrueClass) || !response["__QObject*__"] || response.id == nil)
        return response
    end
    
    objectId=response.id
    
    if (@webChannel.objects[objectId])
        return @webChannel.objects[objectId]
    end


    qObject=QObject.new(objectId, response.data, @webChannel)
    
    qObject.destroyed.connect() do 
        if (@webChannel.objects[objectId]==qObject)
            @webChannel.objects.delete(objectId)
            
            propertyNames=[]
            
            qObject.each do |propertyName|
                propertyNames << propertyName
            end
            
            propertyNames.each do |propertyName|
                qObject.delete(propertyName)
            end
        end #if (@webChannel.objects[objectId]==qObject)
    end #qObject.destroyed.connect() do 
    
    qObject.unwrapProperties()
    
    return qObject
end