Index: toc.cpp
===================================================================
--- toc.cpp	(revision 749421)
+++ 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>
@@ -71,6 +75,8 @@
 		QString m_name;
 };
 
+bool TOC::m_alreadyWarned = false;
+
 TOC::TOC( NavigatorItem *parentItem )
 {
 	m_parentItem = parentItem;
@@ -80,18 +86,21 @@
 {
 	QFileInfo fileInfo( file );
 	QString fileName = fileInfo.absoluteFilePath();
+	qDebug() << fileName;
 	const QStringList resourceDirs = KGlobal::dirs()->resourceDirs( "html" );
 	QStringList::ConstIterator it = resourceDirs.begin();
 	QStringList::ConstIterator end = resourceDirs.end();
 	for ( ; it != end; ++it ) {
+		qDebug() << *it;
 		if ( fileName.startsWith( *it ) ) {
 			fileName.remove( 0, ( *it ).length() );
 			break;
 		}
 	}
 
-	QString cacheFile = fileName.replace( QDir::separator(), "__" );
+	QString cacheFile = fileName.replace( '/', "__" );
 	m_cacheFile = KStandardDirs::locateLocal( "cache", "help/" + cacheFile );
+	qDebug() << m_cacheFile;
 	m_sourceFile = file;
 
 	if ( cacheStatus() == NeedRebuild )
@@ -134,21 +143,42 @@
 
 void TOC::buildCache()
 {
-	K3Process *meinproc = new K3Process;
-	connect( meinproc, SIGNAL( processExited( K3Process * ) ),
-	         this, SLOT( meinprocExited( K3Process * ) ) );
+	KXmlGuiWindow *mainWindow = dynamic_cast<KXmlGuiWindow *>( kapp->activeWindow() );
 
-	*meinproc << KStandardDirs::locate( "exe", "meinproc4" );
+	KProcess *meinproc = new KProcess;
+	connect( meinproc, SIGNAL( finished( int, QProcess::ExitStatus) ),
+	         this, SLOT( meinprocExited( int, QProcess::ExitStatus) ) );
+
+	*meinproc << KStandardDirs::locate("exe", "meinproc4");
 	*meinproc << "--stylesheet" << KStandardDirs::locate( "data", "khelpcenter/table-of-contents.xslt" );
 	*meinproc << "--output" << m_cacheFile;
 	*meinproc << m_sourceFile;
 
-	meinproc->start( K3Process::NotifyOnExit );
+	meinproc->start();
+	if (!meinproc->waitForStarted()) {
+		kDebug() << "could not start process" << meinproc->program();
+		if (mainWindow && !m_alreadyWarned) {
+            ; // add warning message box with don't display again option 
+			  // http://api.kde.org/4.0-api/kdelibs-apidocs/kdeui/html/classKDialog.html
+			m_alreadyWarned = true;
+		}
+		delete meinproc;
+	}
 }
 
-void TOC::meinprocExited( K3Process *meinproc )
+void TOC::meinprocExited( int exitCode, QProcess::ExitStatus exitStatus)
 {
-	if ( !meinproc->normalExit() || meinproc->exitStatus() != 0 ) {
+	KProcess *meinproc = static_cast<KProcess *>(sender());
+	KXmlGuiWindow *mainWindow = dynamic_cast<KXmlGuiWindow *>( kapp->activeWindow() );
+
+	if ( exitStatus == QProcess::CrashExit || exitCode != 0 ) {
+		kDebug() << "running" << meinproc->program() << "failed with exitCode" << exitCode;
+		kDebug() << "stderr output:" << meinproc->readAllStandardError(); 
+		if (mainWindow && !m_alreadyWarned) {
+            ; // add warning message box with don't display again option 
+			  // http://api.kde.org/4.0-api/kdelibs-apidocs/kdeui/html/classKDialog.html
+			m_alreadyWarned = true;
+		}
 		delete meinproc;
 		return;
 	}
@@ -156,15 +186,15 @@
 	delete meinproc;
 
 	QFile f( m_cacheFile );
-	if ( !f.open( QIODevice::ReadWrite ) )
+	if ( !f.open( QIODevice::ReadWrite  ) )
 		return;
 
 	QDomDocument doc;
 	if ( !doc.setContent( &f ) )
-		return;
+ 		return;
 
 	QDomComment timestamp = doc.createComment( QString::number( sourceFileCTime() ) );
-	doc.documentElement().appendChild( timestamp );
+  	doc.documentElement().appendChild( timestamp );
 
 	f.seek( 0 );
 	QTextStream stream( &f );
Index: toc.h
===================================================================
--- toc.h	(revision 749421)
+++ 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;
+		static bool m_alreadyWarned;
 };
 
 }
