Learn what Felgo offers to help your business succeed. Start your free evaluation today! Felgo for Your Business

Forums

OverviewFelgo SDK Support › Felgo 4 – Hot reload not working for qml module library components

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #24962

    Omegapon

    Originally, I posted about my issues in this thread https://felgo.com/developers/forums/t/changing-the-folder-structure (please read second half for context)

    First stacktrace: https://imgur.com/a/Oo3SIKv
    Second stacktrace: https://imgur.com/YdDuoM1
    Third stacktrace: https://imgur.com/a/KvWV9OG (new, got this when trying Felgo 4.0.1 earlier)

    Since I really want to get the hot reload/full reload working, I tried to create a minimal reproduce project.

    While working on it I already ran into issues where I can’t get hot reload nor full reload in components from a QML module library to work.

    Please see the example project. Fixing this might already help getting closer to what’s causing the segfaults. If not, then at least then I can experiment a bit more. I hope I’m just making a silly mistake!

    Steps to reproduce:

    • Download example project https://drive.proton.me/urls/0WM7PJJSR0#wVcEQy0yB0fb  (.zip)
    • Open project in QtCreator with Felgo 4.0.1 kit
    • Start client & connect
    • Modify ProfileDelegate.qml and notice that changes are not getting applied without recompiling
    • Modifying the main.qml/a file imported from the App directory itself works fine
      • main.cpp contains this line engine.addImportPath(QStringLiteral(":/")); to make component imports from Core work
      • this could be related, and if so, how to fix this in the given project structure?

    Cheers!

    #24963

    Omegapon

    https://felgo.com/doc/qml-hot-reload-felgo-live/#felgo-live-reloader

    Using felgoLiveEngine.contentLoader seems to have fixed some of the segfaults I was getting after playing around for ~10 minutes. The only consistent segfault I’m still getting is https://imgur.com/a/Oo3SIKv when editing some components but I don’t see anything they have in common. Only happens when hot reload is enabled. Without it,  I don’t get any segfaults anymore (fingers crossed) but full reload is not working for the majority.

    But it is already somewhat more stable and predictable than before, so I can at least do some things when knowing which components to avoid.

    I.e. the majority of components in the main.qml is now inside a AppStack.qml that is loaded via a Loader component. My bad for not trying this earlier! Before the code was all more or less inline.

    // main.qml

    App {
      Component.onCompleted: {
        if(typeof felgoLiveEngine !== "undefined") {
          felgoLiveEngine.contentLoader = appLoader
        }
      }
    }

     

    Loader {
      id: appLoader
      source: "./contents/AppStack.qml"
    }
    // QML_ELEMENT from a QML module library
    Lib.StateLoader {
      id: stateLoader
      onStatusChanged: {
        if (status === StateLoader.Ready) {
            appLoader.item.toMainScreen();
        }
      }
    }

    // AppStack.qml

    StackView {
      id: root
    
      Component { id: loadingScreen }
      Component { id: mainScreen }
    
      initialItem: stateLoader.status === StateLoader.Ready ? mainScreen : loadingScreen // prevents blackscreen on full reload
    
      function toMainScreen() {
        replace(mainScreen);
      }
    
      // Loads other components from QML module library as well which
      // neither supports hot reload nor full reload
    }

     

    Alright, I feel like we are getting there! Now if we can somehow also fix hot reload for QML components from a custom qml module (see opening post) that would be great.

     

    #24984

    Alex
    Felgo Team

    Hi,

    thanks for your detailed report. We had a closer look and have a suggested solution that you could please try, and ideally report back if it works for you.

    We started based on your example project ZIP that you sent above, so any changes on your side in the meantime may need to be considered individually. So they following steps are based on the ZIP you sent:

    1. Comment engine.addImportPath(QStringLiteral(“:/”)); in your main.cpp, this will still be required for normal builds, but with the Live Client module we will use another import path

    2. Also in main.cpp, after FelgoLiveClient client(…), add this import path instead:

    engine.addImportPath(client.cacheDirectory() + "/felgo-4.01-broken-hotreload-module-components/source");

    This will allow the runtime to scan for you qml files in the Live Client cache directory. And felgo-4.01-broken-hotreload-module-components in this case is exactly the folder name / project name of the project, which will also be used internally by the Live Client to organize its cache.

    3. Copy the generated qmldir files to your project. So run CMake and then copy:

    <build folder>/source/com/yourcompany/App/com/yourcompany/App/qmldir
    
    to
    
    <project folder>/source/com/yourcompany/App/

    and

    <build folder>/source/com/yourcompany/Core/qmldir
    
    to
    
    <project folder>/source/com/yourcompany/Core/

    4. Finally, open both qmldir files and remove the prefer :/... lines, so they are resolved automatically.

    Then hot reload should work, without any crashes and without using the contentLoader approach.

    Note that you will have to repeat the qmldir copy step if you add new QML files.

    For reference, here is the modified project: https://drive.google.com/file/d/19xVHuDPDgcBXsJexUWumbYtssV-rwa4X/view?usp=share_link

    Best,
    Alex

Viewing 3 posts - 1 through 3 (of 3 total)

RSS feed for this thread

You must be logged in to reply to this topic.

Qt_Technology_Partner_RGB_475 Qt_Service_Partner_RGB_475_padded