[PATCH] konqueror crash recovery

Alexander Kellett kelletta at eidetica.com
Thu May 16 00:12:30 BST 2002


This is a first version of a patch for adding
crash recovery to konqueror. Currently other
than keditbookmarks there is no interface
to the crash recovery.

The patch works by logging urls opens/closes
with view id's (the pointers).

Further doubtfull improvements:
   open the file 'raw' to stop possible buffering problems?
   shorten the written strings
   optimize by replacing iostream use with sprintf
   write the urls in a alternate way, are how are url's encoded anyway?

Anyway, this code path is so infrequently followed 
that other than the first and last I can't see any 
real speed related need to improve the current 
level of simplicity.

Any other comments?
Alex
-------------- next part --------------
Index: KonquerorIface.cc
===================================================================
RCS file: /home/kde/kdebase/konqueror/KonquerorIface.cc,v
retrieving revision 1.27
diff -u -p -r1.27 KonquerorIface.cc
--- KonquerorIface.cc	2002/02/22 13:55:34	1.27
+++ KonquerorIface.cc	2002/05/15 22:41:53
@@ -173,6 +173,11 @@ void KonquerorIface::updateProfileList()
     it.current()->viewManager()->profileListDirty( false );
 }
 
+QString KonquerorIface::crashLogFile()
+{
+  return KonqMainWindow::s_crashlog_file->name();
+}
+
 QValueList<DCOPRef> KonquerorIface::getWindows()
 {
     QValueList<DCOPRef> lst;
Index: KonquerorIface.h
===================================================================
RCS file: /home/kde/kdebase/konqueror/KonquerorIface.h,v
retrieving revision 1.24
diff -u -p -r1.24 KonquerorIface.h
--- KonquerorIface.h	2002/02/22 13:55:34	1.24
+++ KonquerorIface.h	2002/05/15 22:41:53
@@ -37,6 +37,7 @@ public:
   ~KonquerorIface();
 
 k_dcop:
+
   /**
    * Opens a new window for the given @p url (using createSimpleWindow, i.e. a single view)
    */
@@ -130,6 +131,11 @@ k_dcop:
    * Called by kcontrol when the global configuration changes
    */
   ASYNC reparseConfiguration();
+
+  /**
+   * @return the name of the instance's crash log file
+   */
+  QString crashLogFile();
 
   /**
    * @return a list of references to all the windows
Index: konq_main.cc
===================================================================
RCS file: /home/kde/kdebase/konqueror/konq_main.cc,v
retrieving revision 1.112
diff -u -p -r1.112 konq_main.cc
--- konq_main.cc	2002/05/09 06:47:21	1.112
+++ konq_main.cc	2002/05/15 22:41:53
@@ -23,6 +23,7 @@
 #include "konq_mainwindow.h"
 #include "KonquerorIface.h"
 
+#include <ktempfile.h>
 #include <klocale.h>
 #include <kstandarddirs.h>
 #include <kdebug.h>
@@ -59,6 +60,13 @@ int main( int argc, char **argv )
 
   KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
 
+  KTempFile crashlog_file(locateLocal("tmp", "konqueror-crashlog"), ".xml");
+
+  KonqMainWindow::s_crashlog_file = new QFile( crashlog_file.name() );
+  KonqMainWindow::s_crashlog_file->open( IO_WriteOnly );
+
+  KonqMainWindow::s_crashlog = new QTextStream( KonqMainWindow::s_crashlog_file );
+
   if ( kapp->isRestored() )
   {
     int n = 1;
@@ -135,6 +143,8 @@ int main( int argc, char **argv )
      if ( w->testWFlags( Qt::WDestructiveClose ) )
           delete w;
   }  
+
+  KonqMainWindow::s_crashlog_file->remove();
 
   return 0;
 }
Index: konq_mainwindow.cc
===================================================================
RCS file: /home/kde/kdebase/konqueror/konq_mainwindow.cc,v
retrieving revision 1.998
diff -u -p -r1.998 konq_mainwindow.cc
--- konq_mainwindow.cc	2002/05/08 22:29:48	1.998
+++ konq_mainwindow.cc	2002/05/15 22:41:55
@@ -93,6 +93,8 @@ template class QPtrList<KToggleAction>;
 QPtrList<KonqMainWindow> *KonqMainWindow::s_lstViews = 0;
 KConfig * KonqMainWindow::s_comboConfig = 0;
 KCompletion * KonqMainWindow::s_pCompletion = 0;
+QFile * KonqMainWindow::s_crashlog_file = 0;
+QTextStream * KonqMainWindow::s_crashlog = 0;
 
 KonqMainWindow::KonqMainWindow( const KURL &initialURL, bool openInitialURL, const char *name )
  : KParts::MainWindow( name, WDestructiveClose | WStyle_ContextHelp )
Index: konq_mainwindow.h
===================================================================
RCS file: /home/kde/kdebase/konqueror/konq_mainwindow.h,v
retrieving revision 1.356
diff -u -p -r1.356 konq_mainwindow.h
--- konq_mainwindow.h	2002/05/07 14:25:17	1.356
+++ konq_mainwindow.h	2002/05/15 22:41:55
@@ -25,6 +25,9 @@
 #include <qtimer.h>
 #include <qguardedptr.h>
 
+#include <qfile.h>
+#include <qtextstream.h>
+
 #include <kfileitem.h>
 #include <konq_openurlrequest.h>
 
@@ -636,6 +639,11 @@ private:
   bool m_urlCompletionStarted;
 
   bool m_bBackRightClick;
+
+public:
+
+  static QFile *s_crashlog_file;
+  static QTextStream *s_crashlog;
 };
 
 #endif
Index: konq_view.cc
===================================================================
RCS file: /home/kde/kdebase/konqueror/konq_view.cc,v
retrieving revision 1.295
diff -u -p -r1.295 konq_view.cc
--- konq_view.cc	2002/05/07 15:13:59	1.295
+++ konq_view.cc	2002/05/15 22:41:56
@@ -91,6 +91,9 @@ KonqView::~KonqView()
 {
   kdDebug(1202) << "KonqView::~KonqView : part = " << m_pPart << endl;
 
+  Q_ASSERT(KonqMainWindow::s_crashlog); // should never happen
+  (*KonqMainWindow::s_crashlog) << "close(" << this << ") == " << ((m_pPart)?m_pPart->url().url(): "") << "\n";
+
   // We did so ourselves for passive views
   if (m_pPart != 0L)
   {
@@ -108,6 +111,10 @@ void KonqView::openURL( const KURL &url,
 {
   kdDebug(1202) << "KonqView::openURL url=" << url.url() << " locationBarURL=" << locationBarURL << endl;
   setServiceTypeInExtension();
+
+  Q_ASSERT(KonqMainWindow::s_crashlog); // should never happen
+  (*KonqMainWindow::s_crashlog) << "closed(" << this << ") == " << ((m_pPart)?m_pPart->url().url():"") << "\n";
+  (*KonqMainWindow::s_crashlog) << "opened(" << this << ") == " << url.url() << "\n";
 
   KParts::BrowserExtension *ext = browserExtension();
   KParts::URLArgs args;


More information about the kfm-devel mailing list