Hey guys,
While trying to build a little app to show the issue, I understood what I was 
doing wrong:
I was calling QStandardPaths::writableLocation(QStandardPaths::CacheLocation) 
in the constructor of my c++ class and storing the result.
And in the main(), I was instantiating this c++ class before calling 
SailfishApp::application(argc, argv);
So the app name was not yet set, thus I was storing a bad path.

Vesku, you are right, QStandardPaths use applicationName and organizationName
      when constructing paths.

The only thing that I don't understand is why it was working from the Terminal, 
but that's not that important :)

Thanks for your answers!!
Sylvain.

Date: Mon, 20 Jan 2014 11:19:38 +0200
From: vesa-matti.hartikai...@jolla.com
To: devel@lists.sailfishos.org
Subject: Re: [SailfishDevel] QStandardPaths not working when app is run from 
Launcher


  
    
  
  
    Hi,

      

       I think QStandardPaths use applicationName and organizationName
      when constructing paths.

      

       So solution would be something like 

          app->setApplicationName("harbour-yourapp");

          app->setOrganizationName("harbour-yourapp");

      

       And then QStandardPaths will start giving paths that follow
      harbour guidance.

      

      BR,

       Vesku

      

      

      On 01/19/2014 05:32 PM, Robin Burchell wrote:

    
    
      
      Hi,
      

      
      Can you please provide a small sample demonstrating this? As
        I’m quite sure it works for our own uses.
      

      
      BR,
      Robin
      

        
          On 19 Jan 2014, at 14:34, Sylvain B. <sth...@hotmail.com>
            wrote:
          
          
            
              Hey,

                My app did not want to read the some cached content it
                was supposed to have written in QStandardPaths::CacheLocation.

                To understand why, I tried to run it from the terminal,
                and... everything is working fine.

                Since we don't have logs when we run the app directly
                from Launcher, I updated it to display some logs
                directly in the UI and I figured out that, when the app
                is run from the Launcher on the actual device (it's ok
                on the emulator), QStandardPaths does not work
                correctly:

                

                QStandardPaths::CacheLocation returns
                
/home/nemo/.cache/mdeclarativecache_pre_initialized_qapplication-XXXXX

                

                XXXXX is a random number, so each time I run my app, it
                creates a new one.

                When run from terminal, QStandardPaths::CacheLocation correctly
                returns /home/nemo/.cache/

                

                I tried with QStandardPaths::DataLocation but it's
                the same, I get
/home/nemo/.local/share/AppName/mdeclarativecache_pre_initialized_qapplication-XXXXX

                

                So for the moment, I temporarily hardcoded
                /home/nemo/.cache/

                

                Thanks!

                Sylvain.

              
              _______________________________________________

              SailfishOS.org Devel mailing list
          
        
        

      
      

      
      

      _______________________________________________
SailfishOS.org Devel mailing list
    
    

    

    -- 
Vesa-Matti Hartikainen
Jolla Oy
http://jolla.com
p. +358 50 487 6067
  


_______________________________________________
SailfishOS.org Devel mailing list                                         
_______________________________________________
SailfishOS.org Devel mailing list

Reply via email to