Index: toc.cpp
===================================================================
--- toc.cpp	(revision 748542)
+++ toc.cpp	(working copy)
@@ -23,9 +23,13 @@
 #include "docentry.h"
 
 #include <kiconloader.h>
-#include <k3process.h>
+#include <kprocess.h>
 #include <kstandarddirs.h>
 #include <kdebug.h>
+#include <kxmlguiwindow.h>
+#include <KApplication>
+#include <KStatusBar>
+#include <klocale.h>
 
 #include <QDir>
 #include <QFileInfo>
@@ -134,26 +138,53 @@
 
 void TOC::buildCache()
 {
-	K3Process *meinproc = new K3Process;
-	connect( meinproc, SIGNAL( processExited( K3Process * ) ),
-	         this, SLOT( meinprocExited( K3Process * ) ) );
+	KXmlGuiWindow *mainWindow = dynamic_cast<KXmlGuiWindow *>( kapp->activeWindow() );
+	if (mainWindow) {
+		if (m_meinproc) {
+			mainWindow->statusBar()->showMessage( i18n( "Building table of content cache... already running" ) );
+			return;
+		}
+		else
+			mainWindow->statusBar()->showMessage( i18n( "Building table of content cache..." ) );
+	}
+	if (m_meinproc)
+		return;
 
-	*meinproc << KStandardDirs::locate( "exe", "meinproc4" );
-	*meinproc << "--stylesheet" << KStandardDirs::locate( "data", "khelpcenter/table-of-contents.xslt" );
-	*meinproc << "--output" << m_cacheFile;
-	*meinproc << m_sourceFile;
+	m_meinproc = new KProcess;
+	connect( m_meinproc, SIGNAL( finished( int, QProcess::ExitStatus) ),
+	         this, SLOT( meinprocExited( int, QProcess::ExitStatus) ) );
 
-	meinproc->start( K3Process::NotifyOnExit );
+	*m_meinproc << KStandardDirs::locate("exe", "meinproc4");
+	*m_meinproc << "--stylesheet" << KStandardDirs::locate( "data", "khelpcenter/table-of-contents.xslt" );
+	*m_meinproc << "--output" << m_cacheFile;
+	*m_meinproc << m_sourceFile;
+
+	m_meinproc->start();
+	if (m_meinproc->waitForStarted()) {
+		if (mainWindow)
+			mainWindow->statusBar()->showMessage( i18n( "Building table of content cache... failed" ), 2000 );
+		kDebug() << "could not start process" << m_meinproc->program();
+		delete m_meinproc;
+		m_meinproc = 0;
+	}
 }
 
-void TOC::meinprocExited( K3Process *meinproc )
+void TOC::meinprocExited( int exitCode, QProcess::ExitStatus exitStatus)
 {
-	if ( !meinproc->normalExit() || meinproc->exitStatus() != 0 ) {
-		delete meinproc;
+	KXmlGuiWindow *mainWindow = dynamic_cast<KXmlGuiWindow *>( kapp->activeWindow() );
+
+	if ( exitStatus == QProcess::CrashExit || exitCode != 0 ) {
+		if (mainWindow)
+			mainWindow->statusBar()->showMessage( i18n( "Building table of content cache... failed" ), 2000 );
+		kDebug() << "running" << m_meinproc->program() << "failed with exitCode" << exitCode;
+		kDebug() << "stderr output:" << m_meinproc->readAllStandardError(); 
+		delete m_meinproc;
+		m_meinproc = 0;
 		return;
 	}
 
-	delete meinproc;
+	delete m_meinproc;
+	m_meinproc = 0;
 
 	QFile f( m_cacheFile );
 	if ( !f.open( QIODevice::ReadWrite ) )
Index: toc.h
===================================================================
--- toc.h	(revision 748542)
+++ toc.h	(working copy)
@@ -26,7 +26,7 @@
 #include <Qt3Support/Q3CheckListItem>
 #include <QObject>
 
-class K3Process;
+#include <KProcess>
 
 namespace KHC {
 
@@ -47,7 +47,7 @@
 
 	private Q_SLOTS:
 		void slotItemSelected( Q3ListViewItem *item );
-		void meinprocExited( K3Process *meinproc );
+		void meinprocExited( int exitCode, QProcess::ExitStatus exitStatus);
 
 	private:
 		enum CacheStatus { NeedRebuild, CacheOk };
@@ -64,6 +64,7 @@
 		QString m_sourceFile;
 
 		NavigatorItem *m_parentItem;
+		KProcess *m_meinproc;
 };
 
 }
