]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Do not crash with the null pointer, this is a hack/workaround as we
authorHolger Freyther <holger+kde@freyther.de>
Wed, 29 Nov 2006 00:20:32 +0000 (00:20 +0000)
committerHolger Freyther <holger+kde@freyther.de>
Wed, 29 Nov 2006 00:20:32 +0000 (00:20 +0000)
will switch to KonqUndoManager anyway. The difficulty is we would
need one UndoManager for DolphinMainWindow which we won't do/have with
KonqUndoManager so I avoid wasting my time cleaning up this bit, so
progress information might be a bit wrong in regards to the amount of
total steps...

svn path=/trunk/playground/utils/dolphin/; revision=608947

src/undomanager.cpp
src/undomanager.h

index 7d21896e1ce121fe0913f058096f711f17c455d3..1a705f39586627783424cdea32173390e3a18c96 100644 (file)
@@ -128,12 +128,16 @@ void UndoManager::undo()
     int macroCount = 1;
     calcStepsCount(macroCount, progressCount);
 
-    m_progressIndicator = new ProgressIndicator(0, i18n("Executing undo operation..."),
-                                                i18n("Executed undo operation."),
-                                                progressCount);
 
     for (int i = 0; i < macroCount; ++i) {
         const DolphinCommand command = m_history[m_historyIndex];
+
+        /*
+         * KDE4, ### TODO Only here to avoid possible crash 
+         */
+        ProgressIndicator progressIndicator(command.mainWindow(), i18n("Executing undo operation..."),
+                                            i18n("Executed undo operation."),
+                                            progressCount);
         --m_historyIndex;
         if (m_historyIndex < 0) {
             emit undoAvailable(false);
@@ -198,7 +202,7 @@ void UndoManager::undo()
                     KIO::NetAccess::move(*it, newDestUrl);
                     ++it;
 
-                    m_progressIndicator->execOperation();
+                    progressIndicator.execOperation();
                 }
                 break;
             }
@@ -218,11 +222,8 @@ void UndoManager::undo()
             KIO::NetAccess::synchronousRun(job, command.mainWindow() );
         }
 
-        m_progressIndicator->execOperation();
+        progressIndicator.execOperation();
     }
-
-    delete m_progressIndicator;
-    m_progressIndicator = 0;
 }
 
 void UndoManager::redo()
@@ -241,13 +242,13 @@ void UndoManager::redo()
     int macroCount = 1;
     calcStepsCount(macroCount, progressCount);
 
-#warning "TOUGH"
-    m_progressIndicator = new ProgressIndicator(0, i18n("Executing redo operation..."),
-                                                i18n("Executed redo operation."),
-                                                progressCount);
 
     for (int i = 0; i < macroCount; ++i) {
         const DolphinCommand command = m_history[m_historyIndex];
+#warning "TOUGH"
+        ProgressIndicator progressIndicator(0, i18n("Executing redo operation..."),
+                                            i18n("Executed redo operation."),
+                                            progressCount);
         if (m_historyIndex >= maxHistoryIndex) {
             emit redoAvailable(false);
             emit redoTextChanged(i18n("Redo"));
@@ -292,7 +293,7 @@ void UndoManager::redo()
                     KIO::NetAccess::synchronousRun(moveToTrashJob, command.mainWindow() );
                     ++it;
 
-                    m_progressIndicator->execOperation();
+                    progressIndicator.execOperation();
                  }
                 break;
             }
@@ -303,7 +304,7 @@ void UndoManager::redo()
             }
 
             case DolphinCommand::CreateFile: {
-                m_progressIndicator->execOperation();
+                progressIndicator.execOperation();
                 KUrl::List::Iterator it = sourceUrls.begin();
                 assert(sourceUrls.count() == 1);
                 KIO::CopyJob* copyJob = KIO::copyAs(*it, command.destination(), false);
@@ -322,27 +323,22 @@ void UndoManager::redo()
         }
 
         ++m_historyIndex;
-        m_progressIndicator->execOperation();
+        progressIndicator.execOperation();
     }
 
     --m_historyIndex;
 
-    delete m_progressIndicator;
-    m_progressIndicator = 0;
 }
 
 UndoManager::UndoManager() :
     m_recordMacro(false),
     m_historyIndex(-1),
-    m_macroCounter(0),
-    m_progressIndicator(0)
+    m_macroCounter(0)
 {
 }
 
 UndoManager::~UndoManager()
 {
-    delete m_progressIndicator;
-    m_progressIndicator = 0;
 }
 
 QString UndoManager::commandText(const DolphinCommand& command) const
@@ -370,7 +366,10 @@ void UndoManager::slotPercent(KJob* /* job */, unsigned long /* percent */)
 
 void UndoManager::updateProgress()
 {
-    m_progressIndicator->execOperation();
+    /*
+     * ### XXX, TODO, KDE4 make this work when switchting to KonqUndoManager
+     */
+    //m_progressIndicator->execOperation();
 }
 
 void UndoManager::calcStepsCount(int& macroCount, int& progressCount)
index bf9a80c90da3633cbc0a63db9bb54c3c8f4968f2..9e2094fe386a2f2966c757070ba21e0dfe4181ab 100644 (file)
@@ -27,7 +27,6 @@
 #include <kurl.h>
 #include <kio/jobclasses.h>
 
-class ProgressIndicator;
 class DolphinMainWindow;
 
 /**
@@ -182,7 +181,6 @@ private:
     int m_historyIndex;
     int m_macroCounter;
     Q3ValueList<DolphinCommand> m_history;
-    ProgressIndicator* m_progressIndicator;
 
     /**
      * Dependent from the current history index \a m_historyIndex