[Nepomuk] Review Request: ResourceWatcher: Do no create a new ResourceManager on quit

Simeon Bird bladud at gmail.com
Wed Dec 5 02:16:13 UTC 2012


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



libnepomukcore/datamanagement/resourcewatcher.cpp
<http://git.reviewboard.kde.org/r/107573/#comment17558>

    Spelling: ~ResourceManger -> ~ResourceManager



libnepomukcore/resource/resource.cpp
<http://git.reviewboard.kde.org/r/107573/#comment17559>

    Might it be better to simply return some empty resource, instead of asserting?
    
    In 292996 , we just figured out that a Resource can continue being accessed after QApplication has been destroyed, because QRunnable cannot be cancelled. If that thread, instead of accessing the Resource, had constructed a new Resource, with this code we would crash on exit in a release build. 
    
    Since we would likely only hit the race in a release build, we would get another difficult-to-debug crash on exit.


- Simeon Bird


On Dec. 4, 2012, 11:36 a.m., Vishesh Handa wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> http://git.reviewboard.kde.org/r/107573/
> -----------------------------------------------------------
> 
> (Updated Dec. 4, 2012, 11:36 a.m.)
> 
> 
> Review request for Nepomuk, Sebastian Trueg and Simeon Bird.
> 
> 
> Description
> -------
> 
>     ResourceWatcher: Do no create a new ResourceManager on quit
>     
>     The ResourceManager contains a ResourceWatcher. This ResourceWatcher is
>     initialized only when a Resource class requires it. On destruction it
>     calls ResourceWatcher::stop, which tries to disconnect it from
>     ResourceManager::nepomukSystemStarted signal.
>     
>     The problem arises when the application is exiting, and the
>     ResourceManager (being a child of QCoreApplication) is being destroyed.
>     It in turn destroys the ResourceWatcher, which calls
>     ResourceWatcher::stop, which calls ResourceManager::instance() which
>     results in the creation of a new ResourceManager whose parent is
>     QCoreApplication::instance, which is 0, cause the application is
>     shutting down.
>     
>     This whole extra ResourceManager being allocated is not required and can
>     be avoided by checking if QCoreApplication != 0, in
>     ResourceManager::instance.
>     
>     Also, since ResourceManager::instance() can now return 0. I've added an
>     assert check in the Resource class.
> 
> 
> Diffs
> -----
> 
>   libnepomukcore/datamanagement/resourcewatcher.cpp a09b646 
>   libnepomukcore/resource/resource.cpp 4601eba 
>   libnepomukcore/resource/resourcemanager.cpp 457c042 
> 
> Diff: http://git.reviewboard.kde.org/r/107573/diff/
> 
> 
> Testing
> -------
> 
> Added breakpoints in gdb, and wrote a simple application. The extra ResourceManager is no longer being created.
> 
> 
> Thanks,
> 
> Vishesh Handa
> 
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/nepomuk/attachments/20121205/b3ee86db/attachment-0001.html>


More information about the Nepomuk mailing list