Review Request 118686: libkdeedu / parley : fix Bug 240552 - Second parley process cancels out changes in language file when closing
Inge Wallin
inge at lysator.liu.se
Wed Jun 18 03:54:45 UTC 2014
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://git.reviewboard.kde.org/r/118686/#review60347
-----------------------------------------------------------
The code looks very nice and clean so kudos for that. I only found very minor things which I commented on below. I also love the approach that you are using.
However I don't think it's reasonable to force the user to rename files. Many times they will be using downloaded files from GHNS and they won't even know where they are. Before we apply this patch (which I would like to do very much!) we have to implement an option to steal the lock.
As a side note, this patch overlaps with jpwhiting's one where he changes KUrl to QUrl. If he merges his patch before, you will have to adapt your patch to his but that should be reasonably simple.
keduvocdocument/keduvocdocument.cpp
<https://git.reviewboard.kde.org/r/118686/#comment42062>
If you are immediately creating one in the constructor then why not have it as a real member instead of a pointer? A pointer only makes sense if the pointer doesn't point to anything at some times, thereby saving memory.
keduvocdocument/tests/keduvocdocumentfilelockingtest.cpp
<https://git.reviewboard.kde.org/r/118686/#comment42063>
Really? I don't think so... :)
- Inge Wallin
On June 12, 2014, 5:05 a.m., Andreas Xavier wrote:
>
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://git.reviewboard.kde.org/r/118686/
> -----------------------------------------------------------
>
> (Updated June 12, 2014, 5:05 a.m.)
>
>
> Review request for KDE Edu.
>
>
> Bugs: 240552
> http://bugs.kde.org/show_bug.cgi?id=240552
>
>
> Repository: libkdeedu
>
>
> Description
> -------
>
> Implement a lock on the language file.
>
> The problem: When 2 or more instances of parley open that same language file,
> the last instance to exit overwrites all of the previous changes.
>
> This patch implements unit-tests that demonstrate the problem, and file locking
> on the language file to fix the problem.
>
> The unit tests are straight forward with different combinations of open, editing and saving
> language files. The conditions that I anticipated would replicate the problem.
>
> As a solution this patch uses KAutoSaveFile to implement file locking. m_autosave replaces m_url to track the file.
> Second and subsequent instances of KEduVocDocument can't get a lock for the file. From a programmer perspective
> it returns FileCannotWrite when file access fails. From a user perspective it says that it
> can't read collection from <file name>.
>
> I added KEduVocDocument::close() to the public interface for symmetry with open(). It is not necessary and if interface changes are inconvenient at this time, it can be removed. Destroying the KEduVocDocument, changing the Url with setUrl or saveAs, or opening another file all close the currently open file and eliminate the lock.
>
> One foreseeable problem is that the current parley interface doesn't offer a way to remove the lock if parley crashes.
> The vocabulary file would have to be renamed by hand. However, this is an improvement from data loss to data inaccessible.
> The obvious solution is to add a value to the error enumeration that means the file is locked, and then offer the user to option to steal the lock. That would require changes to the KEduVocDocument interface.
>
>
> Diffs
> -----
>
> keduvocdocument/keduvocdocument.h dfd45c3
> keduvocdocument/keduvocdocument.cpp b73fc69
> keduvocdocument/tests/CMakeLists.txt f05b787
> keduvocdocument/tests/keduvocdocumentfilelockingtest.cpp PRE-CREATION
> keduvocdocument/tests/keduvocdocumentvalidatortest.cpp 834564c
>
> Diff: https://git.reviewboard.kde.org/r/118686/diff/
>
>
> Testing
> -------
>
> 1. Unit tests
> 2. Opened 2 instances of parley and verified that only one could use the file and then after exiting
> that the other could then use the file and then that both successive sets of results had been saved.
>
>
> Thanks,
>
> Andreas Xavier
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kde-edu/attachments/20140618/0f65f7ab/attachment.html>
More information about the kde-edu
mailing list