[rough-patches] crash recovery

Alexander Kellett kelletta at eidetica.com
Sun Apr 7 00:37:37 BST 2002


Over the last hour or so I started on a 
crash recovery system for Konqi, and well
it turned out to be quite a bit easier
to make a working version that i'd thought
it might :)

It's currently in the form of a konqueror
patch (konq_view.cpp), a simple konqi wrapper
and a ruby script.

0: make sure you've got ruby and kde debug build

1: Use "konq" to run Konqueror.

2: Intentionaly crash it, or if your really just 
   a plain unlucky person, go browsing for 5 minutes.

3: Run the ruby script (you'll need to change the ruby path)

Run "keditbookmarks /tmp/crash.xml", and notice the
crashed urls popup in the bookmark editor.

Simple, hé? ;-)

mvg,
Alex
-------------- next part --------------
#!/bin/zsh
konqueror >& /tmp/konqi-recovery-$$
-------------- next part --------------
Index: konq_view.cc
===================================================================
RCS file: /home/kde/kdebase/konqueror/konq_view.cc,v
retrieving revision 1.288
diff -u -p -r1.288 konq_view.cc
--- konq_view.cc	2002/03/28 00:57:45	1.288
+++ konq_view.cc	2002/04/06 23:23:20
@@ -92,6 +92,8 @@ KonqView::~KonqView()
 {
   //kdDebug(1202) << "KonqView::~KonqView : part = " << m_pPart << endl;
 
+   kdWarning() << "--- close(" << this << ") == " << ((m_pPart)?m_pPart->url().url():"") << endl;
+
   // We did so ourselves for passive views
   if ( isPassiveMode() && m_pPart )
       disconnect( m_pPart, SIGNAL( destroyed() ), m_pMainWindow->viewManager(), SLOT( slotObjectDestroyed() ) );
@@ -103,6 +105,10 @@ KonqView::~KonqView()
 
 void KonqView::openURL( const KURL &url, const QString & locationBarURL, const QString & nameFilter )
 {
+   //AK-
+   kdWarning() << "--- closed(" << this << ") == " << ((m_pPart)?m_pPart->url().url():"") << endl;
+   kdWarning() << "--- opened(" << this << ") == " << url.url() << endl;
+
   kdDebug(1202) << "KonqView::openURL url=" << url.url() << " locationBarURL=" << locationBarURL << endl;
   setServiceTypeInExtension();
 
-------------- next part --------------
#!/home/kelletta/install/ruby/bin/ruby

logdir = "/tmp"
logprefix = "konqi-recovery-";

sessions = []

Dir.foreach(logdir) {
   |fname|
   sessions << "#{logdir}/#{$1}" if fname =~ /^(#{logprefix}.*)$/
}

crashxbel = File.open("/tmp/crash.xml","w")

crashxbel.print "<!DOCTYPE xbel>\n"
crashxbel.print "<xbel>\n"

sessions.each {

   |session|

   id = /^.*?\/#{logprefix}([^\/]*)$/.match(session)[1];

   map = {}

   IO.foreach(session) {
      |line|
      if line =~ /^konqueror: WARNING: \-\-\- (.*?)\((.*?)\) == (.*)$/
         if $1 == "opened"
            map[$2] = $3
         elsif $1 == "close"
            map.delete($2)
         end
      end
   }

   crashxbel.print "  <folder>\n"
   crashxbel.print "    <title>#{id}</title>\n"

   map.each {
      |viewid, url|
      crashxbel.print "      <bookmark icon=\"html\" href=\"#{url}\">\n"
      crashxbel.print "        <title>#{url}</title>\n"
      crashxbel.print "      </bookmark>\n"
   }

   crashxbel.print "  </folder>\n"

   $stderr.print "would unlink(#{session})\n";

}

crashxbel.print "</xbel>\n"

crashxbel.close


More information about the kfm-devel mailing list