Index: searchengine.cpp
===================================================================
--- searchengine.cpp	(revision 749421)
+++ searchengine.cpp	(working copy)
@@ -7,7 +7,7 @@
 #include <KConfig>
 #include <KDebug>
 #include <KStandardDirs>
-#include <K3Process>
+#include <KProcess>
 #include <KLocale>
 #include <KMessageBox>
 
@@ -202,7 +202,7 @@
 
 SearchEngine::SearchEngine( View *destination )
   : QObject(),
-    mProc( 0 ), mSearchRunning( false ), mView( destination ),
+    mSearchRunning( false ), mView( destination ),
     mRootTraverser( 0 )
 {
   mLang = KGlobal::locale()->language().left( 2 );
@@ -246,32 +246,14 @@
   return true;
 }
 
-void SearchEngine::searchStdout(K3Process *, char *buffer, int len)
+void SearchEngine::searchStdout()
 {
-  if ( !buffer || len == 0 )
-    return;
-
-  QString bufferStr;
-  char *p;
-  p = (char*) malloc( sizeof(char) * (len+1) );
-  p = strncpy( p, buffer, len );
-  p[len] = '\0';
-
-  mSearchResult += bufferStr.fromUtf8(p);
-
-  free(p);
+  KProcess *proc = static_cast<KProcess *>(sender());
+  mSearchResult += proc->readAllStandardOutput();
 }
 
-void SearchEngine::searchStderr(K3Process *, char *buffer, int len)
+void SearchEngine::searchExited(int exitCode, QProcess::ExitStatus exitStatus)
 {
-  if ( !buffer || len == 0 )
-    return;
-
-  mStderr.append( QString::fromUtf8( buffer, len ) );
-}
-
-void SearchEngine::searchExited(K3Process *)
-{
   kDebug() << "Search terminated";
   mSearchRunning = false;
 }
@@ -339,8 +321,7 @@
 
     kDebug() << "Common Search: " << commonSearchProgram;
 
-    mProc = new K3Process();
-
+    KProcess *proc = new KProcess();
     QStringList cmd = commonSearchProgram.split( " ");
     QStringList::ConstIterator it;
     for( it = cmd.begin(); it != cmd.end(); ++it ) {
@@ -349,37 +330,38 @@
            arg.endsWith(QLatin1Char('\"'))) {
         arg = arg.mid( 1, arg.length() - 2 );
       }
-      *mProc << arg.toUtf8();
+      proc << arg.toUtf8();
     }
 
-    connect( mProc, SIGNAL( receivedStdout( K3Process *, char *, int ) ),
-             SLOT( searchStdout( K3Process *, char *, int ) ) );
-    connect( mProc, SIGNAL( receivedStderr( K3Process *, char *, int ) ),
-             SLOT( searchStderr( K3Process *, char *, int ) ) );
-    connect( mProc, SIGNAL( processExited( K3Process * ) ),
-             SLOT( searchExited( K3Process * ) ) );
+    connect( proc, SIGNAL( readyReadStandardOutput() ),
+             this, SLOT( searchStdout() ) );
+    connect( proc, SIGNAL( finished(int, QProcess::ExitStatus) ),
+             this, SLOT( searchExited(int, QProcess::ExitStatus) ) );
 
     mSearchRunning = true;
     mSearchResult = "";
     mStderr = "<b>" + commonSearchProgram + "</b>\n\n";
 
-    mProc->start(K3Process::NotifyOnExit, K3Process::All);
+    proc->start();
 
-    while (mSearchRunning && mProc->isRunning())
+    while (mSearchRunning && proc->state() == QProcess::Running)
       kapp->processEvents();
 
-    if ( !mProc->normalExit() || mProc->exitStatus() != 0 ) {
+    // no need to use stderr signal/slot
+    mStderr += proc->readAllStandardError();
+
+    if ( proc->exitStatus() == KProcess::CrashExit || proc->exitCode() != 0 ) {
       kError() << "Unable to run search program '" << commonSearchProgram
                 << "'" << endl;
-      delete mProc;
+      delete proc;
       
       return false;
     }
 
-    delete mProc;
+    delete proc;
 
     // modify the search result
-    mSearchResult = mSearchResult.replace(QLatin1String("http://localhost/"), QLatin1String("file:/"));
+    mSearchResult = mSearchResult.replace("http://localhost/", "file:/");
     mSearchResult = mSearchResult.mid( mSearchResult.indexOf( '<' ) );
 
     mView->beginSearchResult();
Index: searchengine.h
===================================================================
--- searchengine.h	(revision 749421)
+++ searchengine.h	(working copy)
@@ -4,11 +4,11 @@
 #include <QObject>
 
 
+#include <KProcess>
 #include <kio/job.h>
 
 #include "docentrytraverser.h"
 
-class K3Process;
 
 namespace KHC {
 
@@ -109,17 +109,15 @@
     void searchFinished();
 
   protected Q_SLOTS:
-    void searchStdout(K3Process *proc, char *buffer, int buflen);
-    void searchStderr(K3Process *proc, char *buffer, int buflen);
-    void searchExited(K3Process *proc);
+    void searchStdout();
+    void searchExited(int, QProcess::ExitStatus);
 
   protected:
     void processSearchQueue();
     
   private:
-    K3Process *mProc;
     bool mSearchRunning;
-    QString mSearchResult;
+    QByteArray mSearchResult;
 
     QString mStderr;
 
