Review Request: Move directory related code to DirectoryProvider singleton

Arjen Hiemstra djfreestyler at gmail.com
Wed Jun 22 23:12:37 CEST 2011


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
http://git.reviewboard.kde.org/r/101727/#review4080
-----------------------------------------------------------



core/directoryprovider.cpp
<http://git.reviewboard.kde.org/r/101727/#comment3325>

    This one should be const & for the argument. In addition, its probably better to name it "name" since we decided that it does not necessarily need to be a subdir.



core/directoryprovider.cpp
<http://git.reviewboard.kde.org/r/101727/#comment3324>

    Bit of a nitpick, but you're still not caching the final result. If you change the constructor to first get the m_userDataPath, you can then store the absolute path in the hash, which will also make it easier later on to completely change the paths.
    
    In the userDir method you can then do the following:
    
    if(!m_userDirs.contains(subDir))
    {
         QString path = QDir::fromNativeSeparators(m_userDataPath + subdir);
    
         m_userDirs.insert(subDir, path);
         QDir dir;
         dir.mkdir(path);
    }
    
    return m_userDirs.value(subDir)
    
    Which means it will only be an extra call to m_userDirs.contains() when stuff is cached.
    
    In addition, you're using the wrong code style - Gluon uses braces on newline. ;)


- Arjen


On June 22, 2011, 8:50 p.m., Shantanu Tushar Jha wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> http://git.reviewboard.kde.org/r/101727/
> -----------------------------------------------------------
> 
> (Updated June 22, 2011, 8:50 p.m.)
> 
> 
> Review request for Gluon.
> 
> 
> Summary
> -------
> 
> When we were adding userDir functions to GluonCore::Global, for caching and flexibility purposes it was needed to add two variables. Keeping these static was quite a mess, and I and Arjen concluded that a Singleton is more suited for this kind of stuff.
> As agreed on IRC, added a new class DirectoryProvider which has all the functions from GluonCore::Global except version because its not a directory function. Also, except the userDir function, other functions don't require an instance and can be called directly.
> 
> 
> Diffs
> -----
> 
>   core/CMakeLists.txt 8fd1dd0 
>   core/directoryprovider.h PRE-CREATION 
>   core/directoryprovider.cpp PRE-CREATION 
>   core/gluon_global.h.in 792d65e 
>   core/gluonobjectfactory.cpp 4501bed 
>   creator/plugins/docks/projectdock/projectdock.cpp e02ce53 
>   graphics/engine.cpp c4094b0 
>   graphics/examples/loadtexture/main.cpp 229f9a4 
>   player/kde/mainwindow.cpp 7071249 
>   player/lib/models/gameitemsmodel.cpp 63075ed 
>   player/lib/ocsprovider.cpp 1d5daa4 
>   player/qt/mainwindow.cpp 0470e33 
> 
> Diff: http://git.reviewboard.kde.org/r/101727/diff
> 
> 
> Testing
> -------
> 
> Overall Gluon's players seem to function properly. The userData function returns correct paths for me, request everyone to check once for their configuration.
> 
> 
> Thanks,
> 
> Shantanu Tushar
> 
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.kde.org/pipermail/gluon/attachments/20110622/7ce82099/attachment.htm 


More information about the Gluon mailing list