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. RemoteObject stops working after wrapping the replicanode
Forum Updated to NodeBB v4.3 + New Features

RemoteObject stops working after wrapping the replicanode

Scheduled Pinned Locked Moved Solved General and Desktop
2 Posts 2 Posters 189 Views
  • 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.
  • R Offline
    R Offline
    Redman
    wrote on last edited by Redman
    #1

    Hello

    I used the simple switch remote object example with a registry from the docs.

    main.cpp replica

       QRemoteObjectNode repNode;
       repNode.setRegistryUrl(QUrl(QStringLiteral("local:registry")));
    
       QSharedPointer<SimpleSwitchReplica> ptr;
       ptr.reset(repNode.acquire<SimpleSwitchReplica>());  // acquire replica of
                                                           // source from host
    
       R_SimpleSwitch rSwitch(ptr);
    

    works perfect.

    After wrapping that node into my own ROReceiverclass like this:

    #ifndef RORECEIVER_H
    #define RORECEIVER_H
    
    #include <QRemoteObjectNode>
    
    #include "r_simpleswitch.h"
    
    class ROReceiver {
     public:
       ROReceiver(QUrl registryUrl);
     private:
       QRemoteObjectNode m_repNode;
    };
    
    #endif  // RORECEIVER_H
    
    
    ROReceiver::ROReceiver(QUrl registryUrl) {
       m_repNode.setRegistryUrl(registryUrl);
    
       QSharedPointer<SimpleSwitchReplica> ptr;
       ptr.reset(
           m_repNode.acquire<SimpleSwitchReplica>());  // acquire replica of
                                                       // source from host node
    
       R_SimpleSwitch rSwitch(ptr);
    }
    

    and adjusting the main.cpp replica like followed

    ROReceiver r(QUrl(QStringLiteral("local:registry")));
    

    The example does not work anymore.

    In the ctor of ROReceiver the replica is successfully aquired and the R_SimpleSwitch is initialized. In spite of all that the SimpleSwitchReplica::currStateChanged event does not fire anymore, so the slot which output the replica state never executes.

    To me the code looks identical, except my ROReceiver wrapping that functionality.

    Any ideas?

    Christian EhrlicherC 1 Reply Last reply
    0
    • R Redman

      Hello

      I used the simple switch remote object example with a registry from the docs.

      main.cpp replica

         QRemoteObjectNode repNode;
         repNode.setRegistryUrl(QUrl(QStringLiteral("local:registry")));
      
         QSharedPointer<SimpleSwitchReplica> ptr;
         ptr.reset(repNode.acquire<SimpleSwitchReplica>());  // acquire replica of
                                                             // source from host
      
         R_SimpleSwitch rSwitch(ptr);
      

      works perfect.

      After wrapping that node into my own ROReceiverclass like this:

      #ifndef RORECEIVER_H
      #define RORECEIVER_H
      
      #include <QRemoteObjectNode>
      
      #include "r_simpleswitch.h"
      
      class ROReceiver {
       public:
         ROReceiver(QUrl registryUrl);
       private:
         QRemoteObjectNode m_repNode;
      };
      
      #endif  // RORECEIVER_H
      
      
      ROReceiver::ROReceiver(QUrl registryUrl) {
         m_repNode.setRegistryUrl(registryUrl);
      
         QSharedPointer<SimpleSwitchReplica> ptr;
         ptr.reset(
             m_repNode.acquire<SimpleSwitchReplica>());  // acquire replica of
                                                         // source from host node
      
         R_SimpleSwitch rSwitch(ptr);
      }
      

      and adjusting the main.cpp replica like followed

      ROReceiver r(QUrl(QStringLiteral("local:registry")));
      

      The example does not work anymore.

      In the ctor of ROReceiver the replica is successfully aquired and the R_SimpleSwitch is initialized. In spite of all that the SimpleSwitchReplica::currStateChanged event does not fire anymore, so the slot which output the replica state never executes.

      To me the code looks identical, except my ROReceiver wrapping that functionality.

      Any ideas?

      Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @Redman said in RemoteObject stops working after wrapping the replicanode:

      ROReceiver::ROReceiver(QUrl registryUrl) {
      m_repNode.setRegistryUrl(registryUrl);

      QSharedPointer<SimpleSwitchReplica> ptr;
      ptr.reset(
      m_repNode.acquire<SimpleSwitchReplica>()); // acquire replica of
      // source from host node

      R_SimpleSwitch rSwitch(ptr);
      }

      C++ basics - how long does R_SimpleSwitch rSwitch(ptr); live?

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      1 Reply Last reply
      4
      • R Redman has marked this topic as solved on

      • Login

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