Uploaded image for project: 'Qt for MCUs'
  1. Qt for MCUs
  2. QTMCU-223

Add mode to QUL Property so it manages the lifecycle

    XMLWordPrintable

Details

    • Suggestion
    • Resolution: Unresolved
    • Not Evaluated
    • None
    • Qt fo MCUs 2.5.2
    • QUL Team

    Description

      Add mode to QUL Property so it manages the lifecycle (creation, usage and destruction) of object value s as a black box. Ex, it can be used as a view for the std:string, but it does not manage the lifecycle of std:string.

      Example code:

      #ifndef MAIN_H
      #define MAIN_H
      
      #include <qul/object.h>
      #include <qul/property.h>
      #include <cstring>
      #include <string>
      
      struct MyObject : public Qul::Object {
      Qul::Property<std::string> variable;
      
      MyObject() {
      variable.setValue("Hello World!");
      const char *myString = variable.value().c_str();
      m_myString = foo(myString);
      
      Qul::PlatformInterface::log("string is %s: ", m_myString.data());
      }
      
      static std::string foo(const char* data) {
      return data;
      }
      
      std::string m_myString;;
      };
      
      #endif // MAIN_H
      

      This would be important for example in the use case where property is used for storing an IP address passed to the IP stack - you really don't know how long the pointer has to be alive, and when std::string is in property there is very little control over buffer. So, QML code accessing the property can cause buffer reallocation and hence a dangling pointer.

      Attachments

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

        Activity

          People

            Unassigned Unassigned
            foxxx Tuukka Kettunen
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes