Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for WebAssembly
  4. Opening File Dialog crashes App using Qt for web assembly and emsdk with upstream backend

Opening File Dialog crashes App using Qt for web assembly and emsdk with upstream backend

Scheduled Pinned Locked Moved Solved Qt for WebAssembly
6 Posts 3 Posters 1.5k 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.
  • D Offline
    D Offline
    DamienL
    wrote on 28 Oct 2019, 15:57 last edited by DamienL
    #1

    Hi everyone,

    I already asked this from here

    Following the whole install process described here (thanks Lorn), I successully managed to get things to build fast...

    I'm currently trying to access my local files from my application, as I saw it can be done using (cf "Slate" example, which I can build from QtCreator).

    import Qt.labs.platform 1.0 as Platform
    (...)
    
    Platform.FileDialog {
            id: openProjectDialog
            objectName: "openProjectDialog"
            nameFilters: ["All files (*)", "JSON files (*.json)"]
            defaultSuffix: "json"
    }
    

    But I can't access my file/folder system, same when I build the Slate app. Both app crash, and the mozilla firefox console gives me this:
    Screen Shot 2019-10-28 at 16.41.39.png

    When I build simply the Qt source without the upstream backend (following Qt for web assembly wiki), even though it takes almost 15minutes to build and link, I manage to access my files from the browser with the Slate app.

    (But my custom app only gives me this with the qt wiki build, but that's another post... or a quick answer, up to you ;) )
    Screen Shot 2019-10-28 at 16.45.28.png

    My config:

    Qt 5.13.1
    latest emsdk with upstream 1.39.0
    macOS X Sierra 10.12.6
    XCode clang :
    Apple LLVM version 8.0.0 (clang-800.0.42.1)
    Target: x86_64-apple-darwin16.7.0
    Thread model: posix
    InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

    The wasm-emscripten works fine during the Qt sources build, as it builds beautifully with em++/emcc.

    Is it my setup limitation (llvm 8.00 ) ? I thought you didn't have to an up-to-date (or custom-built) version of llvm with the upstream build...

    Thank you all.

    1 Reply Last reply
    0
    • K Offline
      K Offline
      kuersat
      wrote on 29 Oct 2019, 15:15 last edited by
      #2

      Having the same Problem here.
      Could never access my own filesys. Theres got to be a solution to avoid the sandbox.

      1 Reply Last reply
      0
      • D Offline
        D Offline
        DamienL
        wrote on 29 Oct 2019, 15:41 last edited by
        #3

        Hello @kuersat , which problem ? Does it crash when you try to open a dialog with same config as me ?

        Or do you have the same "lame" display in the dialog as shown in my post ?

        1 Reply Last reply
        0
        • L Offline
          L Offline
          lorn.potter
          wrote on 31 Oct 2019, 02:22 last edited by lorn.potter
          #4

          What you want is QFileDialog::getOpenFileContent
          https://doc.qt.io/qt-5/qfiledialog.html#getOpenFileContent

          All other QFileDialog functions will only access the sandbox filesystem.

          Also you need to use this fork of slate:
          https://github.com/msorvig/slate/tree/91114315b078680a7d40e41e805e8bb3a98c5815

          Freelance Software Engineer, Platform Maintainer QtWebAssembly, Maintainer QtSensors
          Author, Hands-On Mobile and Embedded Development with Qt 5 http://bit.ly/HandsOnMobileEmbedded

          1 Reply Last reply
          0
          • D Offline
            D Offline
            DamienL
            wrote on 4 Nov 2019, 11:20 last edited by
            #5

            @lorn-potter

            Thanks for the answer. I can now access my files but QFile can't open the json files I'm looking to process.

            When using the getOpenFilenContent, I have this in the web browser console:

            RuntimeError: unreachable executed qtloader.js line 270 > WebAssembly.compile:10489242:1
            
            

            There is something I don't understand. Why could I build the Slate example, open files with the Qt Labs FileDialog and use QFile API, but now that I use emscripten I just can't... pretty frustrating.

            Is there a work around to QFile to be able to parse/use local files in the browser ?

            Thanks a lot.

            L 1 Reply Last reply 4 Nov 2019, 21:50
            0
            • D DamienL
              4 Nov 2019, 11:20

              @lorn-potter

              Thanks for the answer. I can now access my files but QFile can't open the json files I'm looking to process.

              When using the getOpenFilenContent, I have this in the web browser console:

              RuntimeError: unreachable executed qtloader.js line 270 > WebAssembly.compile:10489242:1
              
              

              There is something I don't understand. Why could I build the Slate example, open files with the Qt Labs FileDialog and use QFile API, but now that I use emscripten I just can't... pretty frustrating.

              Is there a work around to QFile to be able to parse/use local files in the browser ?

              Thanks a lot.

              L Offline
              L Offline
              lorn.potter
              wrote on 4 Nov 2019, 21:50 last edited by
              #6

              @DamienL
              QFileDialog::getOpenFileContent is the workaround for accessing system/local files due to the javascript sandbox that webassembly lives in.

              Freelance Software Engineer, Platform Maintainer QtWebAssembly, Maintainer QtSensors
              Author, Hands-On Mobile and Embedded Development with Qt 5 http://bit.ly/HandsOnMobileEmbedded

              1 Reply Last reply
              1

              1/6

              28 Oct 2019, 15:57

              • Login

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