Bug 255973 - Saving Tea List to KSharedConfig does not work properly
Summary: Saving Tea List to KSharedConfig does not work properly
Status: RESOLVED FIXED
Alias: None
Product: kteatime
Classification: Applications
Component: general (show other bugs)
Version: 1.2.1
Platform: Arch Linux Linux
: NOR minor
Target Milestone: ---
Assignee: Stefan Böhmann
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-11-03 16:14 UTC by dan.bugzilla
Modified: 2010-11-30 11:38 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In: 1.2.2
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description dan.bugzilla 2010-11-03 16:14:54 UTC
Version:           1.2.1 (using KDE 4.5.2) 
OS:                Linux

Once an item from Tea List is added, one is unable to remove it permanently.

Reproducible: Always

Steps to Reproduce:
Invoke "Configure Tea Cooker" dialog, remove an item from Tea List, close the dialog and quit the application. Start KTeaTime again and check Tea List. The removed item is present in context menu as well as "Configure Tea Cooker" dialog again.

Actual Results:  
The removed item persists in /home/dan/.kde4/share/config/kteatimerc .

Expected Results:  
"Tea%d Name" and "Tea%d Time" records should be removed from [Tealist] part of the config file.

The easiest way to solve the problem is to clean up tealistGroup in setTeaList(), toplevel.cpp before populating the list of items to be saved.

void TopLevel::setTeaList(const QList<Tea> &tealist) {
    m_tealist=tealist;

    // Save list...
    KSharedConfigPtr config = KSharedConfig::openConfig();
    KConfigGroup tealistGroup( config, "Tealist" );

    tealistGroup.deleteGroup(); // ********** ADDED **********
    
    for(int i=0; i<m_tealist.size(); ++i) {
        tealistGroup.writeEntry(QString( "Tea%1 Time" ).arg( i ), m_tealist.at( i ).time() );
        tealistGroup.writeEntry(QString( "Tea%1 Name" ).arg( i ), m_tealist.at( i ).name() );
    }
    tealistGroup.config()->sync();
Comment 1 Stefan Böhmann 2010-11-30 11:38:18 UTC
SVN commit 1202288 by sboehmann:

Delete removed teas from config file while writing the new list of teas.

BUG: 255973
FIXED-IN: 1.2.2



 M  +2 -0      toplevel.cpp  


WebSVN link: http://websvn.kde.org/?view=rev&revision=1202288