Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Is it possible to acquire multiple instances of the same remote object class
Forum Updated to NodeBB v4.3 + New Features

Is it possible to acquire multiple instances of the same remote object class

Scheduled Pinned Locked Moved Unsolved General and Desktop
1 Posts 1 Posters 109 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Suli Sahne
    wrote on last edited by Suli Sahne
    #1

    Hi there,

    I have a problem with aquiring multiple instances of a nested remote object class.

    Let's say I have the following rep file:

    // xyz.rep
    class Foo {
      ...
    }
    
    class Bar {
      CLASS foo(Foo)
    }
    

    I have now two instances of my BarSource implementation:

    class Foo: public FooSource {
        Q_OBJECT
        ...
    };
    
    class Bar : public BarSource {
        Q_OBJECT
        ...
    };
    
    // Somewhere else in the server
    auto* foo1 = new Foo();
    foo1->setObjectName("Foo1");
    m_host->enableRemoting(foo1, foo1->objectName()); // m_host is of type QRemoteObjectHostBase*
    
    auto* bar1 = new Bar();
    bar1->setObjectName("Bar1");
    bar1->setFoo(foo1 );
    m_host->enableRemoting(bar1, bar1->objectName());
    
    auto* foo2 = new Foo();
    foo2->setObjectName("Foo2");
    m_host->enableRemoting(foo2, foo2->objectName());
    
    auto* bar2 = new Bar();
    bar2->setObjectName("Bar2");
    bar2->setFoo(foo2);
    m_host->enableRemoting(bar2, bar2->objectName());
    
    // Somewhere else in the client
    auto* bar1Replica = m_remoteObjectNode.acquire<Bar>("Bar1");
    auto* bar2Replica = m_remoteObjectNode.acquire<Bar>("Bar2"); // causes the assert below
    

    assert.png

    When i look at the generated header file, a hard coded string is passed when calling aquire in the generated BarReplica class:

    QRemoteObjectStringLiterals::CLASS().arg("foo") // "Class::foo"
    

    Am i correct in assuming that this string is causing the problem and that it cannot be dynamically customized?

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved