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

RemoteObjects Model incorrect behaviour

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Reported
    • Priority: P2: Important
    • Resolution: Unresolved
    • Affects Version/s: 5.14.0
    • Fix Version/s: None
    • Component/s: Remote Objects
    • Labels:
      None
    • Platform/s:
      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

            Assignee:
            bstottle Brett Stottlemyer
            Reporter:
            daes David Trancart
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:

                Gerrit Reviews

                There are no open Gerrit changes