Bug 92596 - Knotes doesn't save any notes.
Summary: Knotes doesn't save any notes.
Status: RESOLVED FIXED
Alias: None
Product: knotes
Classification: Applications
Component: general (show other bugs)
Version: 3.3
Platform: unspecified Linux
: NOR normal
Target Milestone: ---
Assignee: Michael Brade
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-11-02 18:45 UTC by David Lazanja
Modified: 2004-11-28 17:07 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description David Lazanja 2004-11-02 18:45:02 UTC
Version:           3.3 (using KDE 3.3.1, SuSE)
Compiler:          gcc version 3.3.3 (SuSE Linux)
OS:                Linux (i686) release 2.6.5-7.111-default

Knotes does not save any notes.
When I exit knotes and start it again, all of my notes are missing.

The behavior is the same in Kontact.  None of the notest that I create are saved.
Comment 1 jeff pitman 2004-11-03 02:57:33 UTC
This is Duplicate.  Please see http://bugs.kde.org/show_bug.cgi?id=90744.
Comment 2 Michael E. Stora, Ph.D. 2004-11-14 21:53:23 UTC
I have the same problem with a new SuSE 9,2 install and have found the reason for it.  There are other problems as well such as the instance of knotes running in the system tray hanging when restoring the session.  The issue and a work-around are described below:

Knotes is looking for notes in the file ~/.kde/share/apps/knotes/notes.ics (which I suspect is the correct location) but writting notes to ~/.kde/share/apps/knotesnotes.ics (I suspect a missing slash in the code).  Creating both files still leaves some bugs (can't delete notes, brings up new blank note on startup), but if you make ~/.kde/share/apps/knotes/notes.ics a symbolic link to ~/.kde/share/apps/knotesnotes.ics functionality is fully restored.

Miked
Comment 3 Tom Braun 2004-11-17 18:27:26 UTC
after creating the symlink, there is still one problem left.
steps to reproduce:
1. edit a note
2. _dont_ activate another window
3. quit knotes
4. start knotes
5. see, that changes were not saved :O(
Comment 4 Michael Brade 2004-11-17 19:32:26 UTC
> after creating the symlink, there is still one problem left.
> steps to reproduce:
> 1. edit a note
> 2. _dont_ activate another window
> 3. quit knotes
> 4. start knotes
> 5. see, that changes were not saved :O(
Well, yes, that was "intentional" in the first place. The reason is that I 
don't know of a way to quit knotes without deactivating the last note. I'll 
fix this for the next version.

Comment 5 Reiner Block 2004-11-22 12:36:20 UTC
I had the same problem and I solved it in the following way (here's my description from bugs.gentoo.org):

At my system, after installing version 3.3.1 of KDE, KNotes does not find its stored notes anymore.

I searched for it and found that at "~/.kde/shared/apps/" a file named "knotesnotes.ics" is stored. But KNotes loads "~/.kde/shared/apps/knotes/notes.ics".

This is because of a possible error inside of the KDE base services. In the header file "/usr/kde/3.3/include/kstandarddirs.h" is written for function "saveLocation(...)" that it will always return a trailing slash. But it seems does it not.

Inside the file "resourcelocal.cpp" you will found at the beginning two functions:

bool ResourceLocal::load()
{
    mCalendar.load( KGlobal::dirs()->saveLocation( "data" ) + "knotes/notes.ics" );
[...]
}

bool ResourceLocal::save()
{
    QString file = KGlobal::dirs()->saveLocation( "data", "knotes" ) + "notes.ics";
[...]
}
The unimportent lines are removed by me. Like you see it seems to be o.k. But if saveLocation does not returns a trailing slash the file name will be "knotesnotes.ics" and it will be stored in the base directory "~/.kde/shared/apps/".

I solved it for my PC with this work around:


QString file = KGlobal::dirs()->saveLocation( "data" ) + "knotes/notes.ics";

Another posibility would be
:
QString file = KGlobal::dirs()->saveLocation( "data", "knotes" ) + "/notes.ics";

But I think it would be better to check what's wrong with this saveLocation, isn't it? ;-)

At my computer KNotes works now correctly. :-) 
Comment 6 Michael Brade 2004-11-22 16:47:01 UTC
You guys seem to be truly creative :) BTW, may I assume that all of you were 
using SuSE packages? Because AFAIK all the official KDE releases were ok.

On Monday 22 November 2004 12:36, Reiner Block wrote:
> This is because of a possible error inside of the KDE base services. In the
> header file "/usr/kde/3.3/include/kstandarddirs.h" is written for function
> "saveLocation(...)" that it will always return a trailing slash. But it
> seems does it not.
Yes, and that was the problem, the one who changed the code did not remember 
this either...

> I solved it for my PC with this work around:
>
>
> QString file = KGlobal::dirs()->saveLocation( "data" ) +
> "knotes/notes.ics";
No, this was the original code, but if the directory knotes doesn't exist, 
you'll have a problem.

> Another posibility would be
>
> QString file = KGlobal::dirs()->saveLocation( "data", "knotes" ) +
> "/notes.ics";
No, this wouldn't be the 100% correct way either. The fix was to use
   KGlobal::dirs()->saveLocation( "data", "knotes/" ) + "notes.ics"
which will be in the next KDE release (3.3.2).

> But I think it would be better to check what's wrong with this
> saveLocation, isn't it? ;-)
Nothing obvious AFAIK, just the documentation :-}

Comment 7 Michael Brade 2004-11-28 17:07:16 UTC
CVS commit by brade: 

fixed #90744, #91702, #92596, #93499: save modified notes on quit, may
not have happened when the note still had focus. Also, the problem
with knotesnotes.ics should be gone now.

To #91702: I guess you were takling about modifying only one note, because
when changing to a second one the first one is saved immediately.

BUG: 90744, 91702, 92596, 93499

Will backport in a second.


  M +6 -0      ChangeLog   1.78.2.4
  M +5 -0      knote.cpp   1.120.2.4
  M +2 -0      knote.h   1.41.2.2
  M +6 -0      knotesapp.cpp   1.91.2.2


--- kdepim/knotes/ChangeLog  #1.78.2.3:1.78.2.4
@@ -2,4 +2,10 @@
 ====================
 
+2004/11/28  Michael Brade <brade@kde.org>
+
+    * fixed #90744, #91702, #92596, #93499: save modified notes on quit, may
+      not have happened when the note still had focus. Also, the problem
+      with knotesnotes.ics is gone now.
+
 2004/09/27  Michael Brade <brade@kde.org>
 

--- kdepim/knotes/knote.cpp  #1.120.2.3:1.120.2.4
@@ -408,4 +408,9 @@ void KNote::setText( const QString& text
 }
 
+bool KNote::isModified() const
+{
+    return m_editor->isModified();
+}
+
 // FIXME KDE 4.0: remove sync(), isNew() and isModified()
 void KNote::sync( const QString& app )

--- kdepim/knotes/knote.h  #1.41.2.1:1.41.2.2
@@ -66,4 +66,6 @@ public:
     void setText( const QString& text );
 
+    bool isModified() const;
+
     void sync( const QString& app );
     bool isNew( const QString& app ) const;

--- kdepim/knotes/knotesapp.cpp  #1.91.2.1:1.91.2.2
@@ -471,4 +471,10 @@ void KNotesApp::slotNoteKilled( KCal::Jo
 void KNotesApp::slotQuit()
 {
+    QDictIterator<KNote> it( m_noteList );
+
+    for ( ; *it; ++it )
+        if ( (*it)->isModified() )
+            (*it)->saveData();
+
     saveConfigs();
     kapp->quit();