Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-82726

RemoteObjects Model incorrect behaviour

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • None
    • 5.14.0
    • Remote Objects
    • None
    • Windows

    Description

      3 Problems:

      The second time a remote model is acquired, it doesn't seems to be initialized correctly.

      Remote access of the model through proxy doesn't seem to be initialized correctly.

      Enabling remote on a model make it loose the specific object user properties (or signal slots, i think)

      This is code showing this strange behaviour:

       

      #include <QCoreApplication>
      
      #include <QStringListModel>
      #include <QDebug>
      #include <QtRemoteObjects/QAbstractItemModelReplica>
      #include <QtRemoteObjects/QRemoteObjectRegistryHost>
      
      void logModel(const QString& message,QAbstractItemModelReplica* model)
      {
          qDebug() << "\n" << message << ": \n"
                   << "NbRows:" << model->rowCount() << "\n"
                   << "Available roles:" << model->availableRoles() << "\n"
                   << "First Element:" << model->data(model->index(0,0),Qt::DisplayRole)<< "\n"
                   << "customProperty:" << model->property("customProperty") << "\n";
      
      }
      
      int main(int argc, char *argv[])
      {
          // QLoggingCategory::setFilterRules(QStringLiteral("qt.remoteobjects* = true"));
      
          QCoreApplication a(argc, argv);
      
          QStringList list({"Item1","Item2"});
          QStringListModel model(list);
          QVector<int> roles({Qt::DisplayRole,Qt::EditRole});
          model.setProperty("customProperty",1234);
      
          QRemoteObjectRegistryHost registry(QUrl(QStringLiteral("local:registry")));
          registry.enableRemoting(&model,"model",roles);
      
          QRemoteObjectNode nodeInternal;
          nodeInternal.connectToNode(QUrl(QStringLiteral("local:registry")));
      
          QAbstractItemModelReplica* romodel1 = nodeInternal.acquireModel("model",QtRemoteObjects::PrefetchData,roles);
          QObject::connect(romodel1,&QAbstractItemModelReplica::initialized,romodel1,[&]()
          {
              logModel("Standard Remote initialized",romodel1);
      
              QAbstractItemModelReplica* romodel2 = nodeInternal.acquireModel("model",QtRemoteObjects::PrefetchData,roles);
              if (romodel2->isInitialized())
                  logModel("Remote copy already initialized",romodel2);
      
          });
      
          // New host for proxy
          QRemoteObjectHost host(QUrl("local:service"));
          host.proxy(QUrl(QStringLiteral("local:registry")));
      
          QRemoteObjectNode nodeExternal;
          nodeExternal.connectToNode(QUrl("local:service"));
          QAbstractItemModelReplica* romodelproxy = nodeExternal.acquireModel("model",QtRemoteObjects::PrefetchData,roles);
      
          QObject::connect(romodelproxy,&QAbstractItemModelReplica::initialized,romodelproxy,[=]()
          {
              logModel("RemoteModel through proxy",romodelproxy);
          });
      
      
          return a.exec();
      }
      
      

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            bstottle Brett Stottlemyer
            daes David Trancart
            Votes:
            6 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes