Bug 95113

Summary: Project "has unsaved data" even if unchanged
Product: [Applications] k3b Reporter: Julian Foad <julianfoad>
Component: GUI/UsabilityAssignee: Sebastian Trueg <trueg>
Status: RESOLVED FIXED    
Severity: normal CC: mail
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: unspecified   
OS: Linux   
Latest Commit: Version Fixed In:

Description Julian Foad 2004-12-13 23:53:55 UTC
Version:           0.11.96 (using KDE 3.2.1, SuSE)
Compiler:          gcc version 3.3.3 (SuSE Linux)
OS:                Linux (i686) release 2.6.4-52-default

K3b CVS 2004-12-10: Audio CD project:

If I Save, Close, and re-Open a project, and then immediately request to Close it, K3b says "<project name> has unsaved data.  [Save/Discard/Cancel]"  It should not do this when no change has been made, it should just close the project without asking.
Comment 1 Maciej Pilichowski 2006-03-18 12:36:13 UTC
I confirm it. K3b 0.12.12 patched and also 0.12.14.
Comment 2 Christoph Burger-Scheidlin 2006-09-10 02:49:32 UTC
Cannot reproduce in 0.12.17 (Gentoo Packages), please try 0.12.17
Comment 3 Sebastian Trueg 2006-09-10 14:19:00 UTC
This bug still exists for audio projects.
Comment 4 Maciej Pilichowski 2006-09-13 13:55:38 UTC
Sebastian, this bug just still exists -- not only for audio projects. Checked audio and DVD (not iso). V. 0.12.17.
Comment 5 Sebastian Trueg 2006-09-13 14:34:04 UTC
I know. It's a design flaw. Hopefully I will find the time to fix that for 1.0
Comment 6 Sebastian Trueg 2006-11-24 11:25:53 UTC
SVN commit 607365 by trueg:

* Audio project not modified after loading anymore (this was caused by
  stupid QListViewItem::paintCell which actually calls setText,
  apperantly to initialize the column info.)
* Fixed K3bMixedDoc::isModified
* Made the konqueror service menus configurable (i.e. one can disable
  them)
* Added a first run dialog which asks if the konqi service menus should
  be anabled or not.

BUGS: 116423, 95113


 M  +0 -2      libk3b/projects/audiocd/k3baudiodoc.cpp  
 M  +1 -1      libk3b/projects/k3bdoc.h  
 M  +8 -2      libk3b/projects/mixedcd/k3bmixeddoc.cpp  
 M  +1 -0      libk3b/projects/mixedcd/k3bmixeddoc.h  
 M  +1 -1      src/Makefile.am  
 M  +3 -0      src/k3bapplication.cpp  
 A             src/k3bfirstrun.cpp   [License: GPL (v2+)]
 A             src/k3bfirstrun.h   [License: GPL (v2+)]
 M  +2 -0      src/k3bprojectmanager.cpp  
 A             src/k3bservicemenuinstaller.cpp   [License: GPL (v2+)]
 A             src/k3bservicemenuinstaller.h   [License: GPL (v2+)]
 M  +3 -2      src/k3bstatusbarmanager.cpp  
 M  +5 -4      src/konqi/Makefile.am  
 M  +19 -8     src/option/base_k3bmiscoptiontab.ui  
 M  +10 -0     src/option/k3bmiscoptiontab.cpp  
 M  +5 -1      src/projects/k3baudiodatasourceviewitem.cpp  
 M  +12 -3     src/projects/k3baudiotrackviewitem.cpp  


--- trunk/extragear/multimedia/k3b/libk3b/projects/audiocd/k3baudiodoc.cpp #607364:607365
@@ -37,7 +37,6 @@
 #include <qdir.h>
 #include <qdom.h>
 #include <qdatetime.h>
-#include <qtimer.h>
 #include <qtextstream.h>
 #include <qsemaphore.h>
 
@@ -974,7 +973,6 @@
 {
   kdDebug() << "(K3bAudioDoc::slotTrackChanged " << track << endl;
   setModified( true );
-  emit changed();
   // if the track is empty now we simply delete it
   if( track->firstSource() )
     emit trackChanged(track);
--- trunk/extragear/multimedia/k3b/libk3b/projects/k3bdoc.h #607364:607365
@@ -99,7 +99,7 @@
   /** 
    * sets the modified flag for the document after a modifying action on the view connected to the document.
    */
-  void setModified( bool m = true );
+  virtual void setModified( bool m = true );
 
   /** 
    * returns if the document is modified or not. Use this to determine 
--- trunk/extragear/multimedia/k3b/libk3b/projects/mixedcd/k3bmixeddoc.cpp #607364:607365
@@ -72,6 +72,13 @@
 }
 
 
+void K3bMixedDoc::setModified( bool m )
+{
+  m_audioDoc->setModified( m );
+  m_dataDoc->setModified( m );
+}
+
+
 bool K3bMixedDoc::isModified() const
 {
   return ( m_audioDoc->isModified() || m_dataDoc->isModified() );
@@ -198,8 +205,7 @@
   }
   mixedElem.appendChild( mixedTypeElem );
 
-  m_audioDoc->setModified( false );
-  m_dataDoc->setModified( false );
+  setModified( false );
 
   return true;
 }
--- trunk/extragear/multimedia/k3b/libk3b/projects/mixedcd/k3bmixeddoc.h #607364:607365
@@ -42,6 +42,7 @@
 
   bool newDocument();
 
+  void setModified( bool m = true );
   bool isModified() const;
 
   KIO::filesize_t size() const;
--- trunk/extragear/multimedia/k3b/src/Makefile.am #607364:607365
@@ -23,7 +23,7 @@
 	k3bwidgetshoweffect.cpp k3bmediaselectiondialog.cpp k3bdiskinfoview.cpp \
 	k3bpassivepopup.cpp k3btimeoutwidget.cpp k3bminibutton.cpp \
 	k3bthemedheader.cpp k3bthemedlabel.cpp k3blsofwrapper.cpp \
-	k3blsofwrapperdialog.cpp
+	k3blsofwrapperdialog.cpp k3bservicemenuinstaller.cpp k3bfirstrun.cpp
 
 k3b_LDADD = ./option/liboption.la ./rip/librip.la \
 	./projects/libprojects.la ../libk3bdevice/libk3bdevice.la \
--- trunk/extragear/multimedia/k3b/src/k3bapplication.cpp #607364:607365
@@ -25,6 +25,7 @@
 #include "k3bmediacache.h"
 #include "k3bpassivepopup.h"
 #include "k3blsofwrapperdialog.h"
+#include "k3bfirstrun.h"
 
 #include <k3bcore.h>
 #include <k3bdevicemanager.h>
@@ -142,6 +143,8 @@
 
     emit initializationDone();
 
+    K3bFirstRun::run( m_mainWindow );
+
     if( K3bSystemProblemDialog::readCheckSystemConfig() ) {
       emit initializationInfo( i18n("Checking System") );
       K3bSystemProblemDialog::checkSystem( m_mainWindow );
--- trunk/extragear/multimedia/k3b/src/k3bprojectmanager.cpp #607364:607365
@@ -560,6 +560,8 @@
     // FIXME: find a better way to tell everyone (especially the projecttabwidget)
     //        that the doc is not changed
     emit projectSaved( newDoc );
+
+    kdDebug() << "(K3bProjectManager) loading project done." << endl;
   }
   else {
     delete newDoc;
--- trunk/extragear/multimedia/k3b/src/k3bstatusbarmanager.cpp #607364:607365
@@ -24,6 +24,7 @@
 #include <k3baudiodoc.h>
 #include <k3bdatadoc.h>
 #include <k3bmixeddoc.h>
+#include <k3bvcddoc.h>
 #include <k3bdiritem.h>
 
 #include <kiconloader.h>
@@ -193,8 +194,8 @@
     }
 
     case K3bDoc::VCD: {
-      K3bDataDoc* dataDoc = static_cast<K3bDataDoc*>( doc );
-      m_labelProjectInfo->setText( i18n("Video CD (%1)").arg(dataDocStats(dataDoc)) );
+      K3bVcdDoc* vcdDoc = static_cast<K3bVcdDoc*>( doc );
+      m_labelProjectInfo->setText( i18n("Video CD (1 track)", "Video CD (%n tracks)", vcdDoc->numOfTracks() ) );
       break;
     }
 
--- trunk/extragear/multimedia/k3b/src/konqi/Makefile.am #607364:607365
@@ -1,13 +1,14 @@
-
-konqservice_DATA = k3b_create_data_cd.desktop \
+k3bservice_DATA =  k3b_create_data_cd.desktop \
 		   k3b_create_data_dvd.desktop \
 	           k3b_create_audio_cd.desktop \
 	           k3b_create_video_cd.desktop \
                    k3b_write_bin_image.desktop \
-		   k3b_write_iso_image.desktop \
-		   k3b_audiocd_rip.desktop \
+		   k3b_write_iso_image.desktop
+
+konqservice_DATA = k3b_audiocd_rip.desktop \
 		   k3b_videodvd_rip.desktop \
 		   k3b_cd_copy.desktop \
 		   k3b_dvd_copy.desktop
 
+k3bservicedir = $(kde_datadir)/k3b/servicemenus
 konqservicedir = $(kde_datadir)/konqueror/servicemenus
--- trunk/extragear/multimedia/k3b/src/option/base_k3bmiscoptiontab.ui #607364:607365
@@ -4,13 +4,8 @@
     <property name="name">
         <cstring>base_K3bMiscOptionTab</cstring>
     </property>
-    <property name="geometry">
-        <rect>
-            <x>0</x>
-            <y>0</y>
-            <width>467</width>
-            <height>392</height>
-        </rect>
+    <property name="caption">
+        <string>base_K3bMiscOptionTab</string>
     </property>
     <vbox>
         <property name="name">
@@ -192,6 +187,22 @@
                         <string>&lt;p&gt;If this option is checked K3b will not close action dialogs such as the CD Copy dialog after the process has been finished. It will be kept open to start a new process like copying another CD.</string>
                     </property>
                 </widget>
+                <widget class="QCheckBox">
+                    <property name="name">
+                        <cstring>m_checkKonqiIntegration</cstring>
+                    </property>
+                    <property name="text">
+                        <string>Enable Konqueror integration</string>
+                    </property>
+                    <property name="toolTip" stdset="0">
+                        <string>Enable integration of K3b actions into Konqueror menus</string>
+                    </property>
+                    <property name="whatsThis" stdset="0">
+                        <string>&lt;p&gt;K3b can integrate itself into Konqueror. This integration allows to start K3b from the context menu in the file manager.
+&lt;p&gt;A typical example is: in order to burn a folder to a data CD one clicks on the folder using the right mouse button. In the appearing context menu one selects "Create Data CD with K3b..." and a new K3b project containing the folder is created.
+&lt;p&gt;&lt;em&gt;Konqueror integration is not enabled by default to prevent unwanted cluttering of the Konqueror menus.&lt;/em&gt;</string>
+                    </property>
+                </widget>
             </vbox>
         </widget>
         <spacer>
@@ -207,7 +218,7 @@
             <property name="sizeHint">
                 <size>
                     <width>31</width>
-                    <height>20</height>
+                    <height>0</height>
                 </size>
             </property>
         </spacer>
--- trunk/extragear/multimedia/k3b/src/option/k3bmiscoptiontab.cpp #607364:607365
@@ -20,6 +20,7 @@
 #include <k3baudiooutputplugin.h>
 #include <k3baudioserver.h>
 #include <k3bcore.h>
+#include <k3bservicemenuinstaller.h>
 
 #include <qcheckbox.h>
 #include <qfileinfo.h>
@@ -78,6 +79,9 @@
 
   m_comboAudioOutputSystem->setCurrentItem( c->readEntry( "Audio Output System", "arts" ), false );
   m_buttonConfigureAudioOutput->setEnabled( m_comboAudioOutputSystem->count() > 0 );
+
+  K3bServiceInstaller si;
+  m_checkKonqiIntegration->setChecked( si.allInstalled() );
 }
 
 
@@ -142,6 +146,12 @@
     K3bAudioServer::instance()->setOutputMethod( m_comboAudioOutputSystem->currentText().local8Bit() );
   }
 
+  K3bServiceInstaller si;
+  if( m_checkKonqiIntegration->isChecked() )
+    si.install( this );
+  else
+    si.remove( this );
+
   return true;
 }
 
--- trunk/extragear/multimedia/k3b/src/projects/k3baudiodatasourceviewitem.cpp #607364:607365
@@ -69,11 +69,15 @@
 
 void K3bAudioDataSourceViewItem::setText( int col, const QString& text )
 {
+  //
+  // See K3bAudioTrackViewItem::setText for an explanation why we have to check if
+  // the value really changed
+  //
   if( col == 4 ) {
     if( K3bAudioZeroData* zero = dynamic_cast<K3bAudioZeroData*>( source() ) ) {
       bool ok;
       K3b::Msf f = K3b::Msf::fromString( text, &ok );
-      if( ok )
+      if( ok && f != zero->length() )
 	zero->setLength( f );
     }
   }
--- trunk/extragear/multimedia/k3b/src/projects/k3baudiotrackviewitem.cpp #607364:607365
@@ -112,7 +112,7 @@
     case 0:
       return QString::number( m_track->trackNumber() ).rightJustify( 2, ' ' );
     case 1:
-      return m_track->artist();
+      return m_track->performer();
     case 2:
       return m_track->title();
     case 3:
@@ -134,13 +134,22 @@
 
 void K3bAudioTrackViewItem::setText( int col, const QString& text )
 {
+  //
+  // Stupid QListViewItem actually calls setText in paintCell. Thus, once a new item
+  // is created setText is called and in turn the doc is marked as modified since
+  // we call setArtist or setPerformer here! :(
+  //
+  // Quick fix: check if the field actually changed
+  //
   if( col == 1 ) {
     // this is the cd-text artist field
-    m_track->setArtist( text );
+    if( text != m_track->performer() )
+      m_track->setPerformer( text );
   }
   else if( col == 2 ) {
     // this is the cd-text title field
-    m_track->setTitle( text );
+    if( text != m_track->title() )
+      m_track->setTitle( text );
   }
 
   KListViewItem::setText( col, text );
Comment 7 Maciej Pilichowski 2006-12-31 18:10:55 UTC
Sebastian, it is still not fixed (rc3). DVD file project for example.
Comment 8 Sebastian Trueg 2007-01-01 16:31:21 UTC
works here.
Comment 9 Maciej Pilichowski 2007-01-01 16:57:42 UTC
I have project saved with 0.12.17. I open it (in RC3), burn the disc with verification, and I quit k3b. I am not closing the project, but just quit. K3b asks me about saving the project.
Comment 10 Sebastian Trueg 2007-01-01 18:21:34 UTC
hm... when you burn a project all the settings get reset which marks the 
project as changed.
Comment 11 Maciej Pilichowski 2007-01-01 21:18:57 UTC
...so I think it is a bug -- because I didn't change a thing in the project. It is like printing a document -- but document didn't change.
Comment 12 Maciej Pilichowski 2007-01-04 19:52:01 UTC
It is worse than I thought. Well, the settings should not change, that's the bug #1.
The bug #2 is they are changing constantly.
I opened a project -> burn dialog -> close the dialog -> project has changed. Ok, what the hell, I'll save it.
Save. Burn dialog -> close the dialog -> project has changed.

Sebastian, please, take a look at it.
Comment 13 Sebastian Trueg 2007-01-05 00:32:42 UTC
this is still the same issue and solving it right now it too much "if( 
oldsetting != newsetting )" hacking.
Comment 14 Maciej Pilichowski 2007-01-05 16:57:08 UTC
Hmm, yes and no.

What would you say for fake save into memory and then comparing two block memories -- old project and "new" version of it. The same -- no change.

Btw. if it is the same issue, then it is not fixed, right?
Comment 15 Sebastian Trueg 2007-01-05 17:33:43 UTC
lo. this is even more work.
Comment 16 Maciej Pilichowski 2007-01-06 10:03:59 UTC
Anyway, please reopen this report because it is not fixed.
Comment 17 Maciej Pilichowski 2007-01-06 14:56:34 UTC
#15
Just curiosity :-) The saving project file is already done, so two things would be missing -- saving to mem instead of file and calling memcmp. Hmm... is it really more work?
Comment 18 Sebastian Trueg 2007-01-06 15:02:14 UTC
On Saturday 06 January 2007 14:56, Maciej Pilichowski wrote:
> Just curiosity :-) The saving project file is already done, so two things
> would be missing -- saving to mem instead of file and calling memcmp.
> Hmm... is it really more work?


yes and way more hacky. I think it would be best to come up with a generic 
solution but I did not have a good idea yet. Once I do I will fix it. But in 
the end this is just annoying but not a real problem...
Comment 19 Maciej Pilichowski 2007-01-06 15:38:38 UTC
Yes, it is not very serious. Hacky -- maybe. But it has great advantage -- reusability.
If you assume that the "save project" is verified, checked, bug-free, etc. there is virtually no chance to introduce any bug.
But if you add completely new function to check if the project is changed it is risk it will introduce new bugs -- for example you miss some widget to check "if (old!=new...)".