From 9fcca6580d61b0796a1325f81ed60d0f1dd635c1 Mon Sep 17 00:00:00 2001 From: Dan Ballard Date: Wed, 22 Jan 2020 18:48:12 -0500 Subject: [PATCH] Fix assets loading in QML on windows also fix drone windows_build branch pipeline --- .drone.yml | 7 ++++--- main.go | 12 ++++++++---- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/.drone.yml b/.drone.yml index 0b65f262..5c8ffa32 100644 --- a/.drone.yml +++ b/.drone.yml @@ -79,8 +79,8 @@ pipeline: commands: - 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 - - rm -r vendor - - make clean + - rm -r vendor || true + - make clean || true - go mod download - export VERSION=`git describe --tags` - export BUILDDATE=`date +%G-%m-%d-%H-%M` @@ -126,9 +126,10 @@ pipeline: - echo $BUILDFILES_KEY > ~/id_rsab64 - base64 -d ~/id_rsab64 > ~/id_rsa - chmod 400 ~/id_rsa + - git fetch --tags - export DIR=`date +%G.%m.%d-%H.%M`-`git describe --tags` - cd deploy - - mkdir windows_build/$DIR + - mkdir -p windows_build/$DIR - mv cwtch* windows_build/$DIR/ - scp -r -o StrictHostKeyChecking=no -i ~/id_rsa windows_build buildfiles@openprivacy.ca:/home/buildfiles/buildfiles/ notify-email: diff --git a/main.go b/main.go index 94c6a99c..4054c072 100644 --- a/main.go +++ b/main.go @@ -129,13 +129,17 @@ func mainUi(flagLocal bool, flagClientUI bool) { // our globals gcd := ui.NewGrandCentralDispatcher(nil) gcd.SetOs(runtime.GOOS) - ex, err := os.Executable() - if err != nil { log.Errorf("error getting path: %v", err) } - dir := path.Dir(ex) + dir := core.QCoreApplication_ApplicationDirPath() + log.Infof("core.QCoreApplication_ApplicationDirPath(): %v\n", dir) if runtime.GOOS == "android" { gcd.SetAssetPath("assets:/") } 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 != "" { -- 2.25.1