Fix assets loading in QML on windows #258

Manually merged
sarah merged 1 commits from windows_build into master 2020-01-23 22:14:55 +00:00
2 changed files with 12 additions and 7 deletions

View File

@ -79,8 +79,8 @@ pipeline:
commands: commands:
- export PATH=$PATH:/home/user/work/bin:/media/sf_GOPATH1/bin - export PATH=$PATH:/home/user/work/bin:/media/sf_GOPATH1/bin
- apt-get -qq update && apt-get --no-install-recommends -qq -y install ca-certificates curl git zip - apt-get -qq update && apt-get --no-install-recommends -qq -y install ca-certificates curl git zip
- rm -r vendor - rm -r vendor || true
- make clean - make clean || true
- go mod download - go mod download
- export VERSION=`git describe --tags` - export VERSION=`git describe --tags`
- export BUILDDATE=`date +%G-%m-%d-%H-%M` - export BUILDDATE=`date +%G-%m-%d-%H-%M`
@ -126,9 +126,10 @@ pipeline:
- echo $BUILDFILES_KEY > ~/id_rsab64 - echo $BUILDFILES_KEY > ~/id_rsab64
- base64 -d ~/id_rsab64 > ~/id_rsa - base64 -d ~/id_rsab64 > ~/id_rsa
- chmod 400 ~/id_rsa - chmod 400 ~/id_rsa
- git fetch --tags
- export DIR=`date +%G.%m.%d-%H.%M`-`git describe --tags` - export DIR=`date +%G.%m.%d-%H.%M`-`git describe --tags`
- cd deploy - cd deploy
- mkdir windows_build/$DIR - mkdir -p windows_build/$DIR
- mv cwtch* windows_build/$DIR/ - mv cwtch* windows_build/$DIR/
- scp -r -o StrictHostKeyChecking=no -i ~/id_rsa windows_build buildfiles@openprivacy.ca:/home/buildfiles/buildfiles/ - scp -r -o StrictHostKeyChecking=no -i ~/id_rsa windows_build buildfiles@openprivacy.ca:/home/buildfiles/buildfiles/
notify-email: notify-email:

12
main.go
View File

@ -129,13 +129,17 @@ func mainUi(flagLocal bool, flagClientUI bool) {
// our globals // our globals
gcd := ui.NewGrandCentralDispatcher(nil) gcd := ui.NewGrandCentralDispatcher(nil)
gcd.SetOs(runtime.GOOS) gcd.SetOs(runtime.GOOS)
ex, err := os.Executable() dir := core.QCoreApplication_ApplicationDirPath()
if err != nil { log.Errorf("error getting path: %v", err) } log.Infof("core.QCoreApplication_ApplicationDirPath(): %v\n", dir)
dir := path.Dir(ex)
if runtime.GOOS == "android" { if runtime.GOOS == "android" {
gcd.SetAssetPath("assets:/") gcd.SetAssetPath("assets:/")
} else { } else {
gcd.SetAssetPath("file://" + path.Join(dir, "assets") + string(os.PathSeparator)) // all of these access are QML based, and QML takes URIs which use forward slashes and translates them to local OS sperators
// also windows paths need to be like /c:/PATH
if runtime.GOOS == "windows" {
dir = "/" + dir
}
gcd.SetAssetPath("file://" + path.Join(dir, "assets") + "/")
} }
if buildVer != "" { if buildVer != "" {