CVS commit by cramblitt: Crash proofing. M +1 -0 kttsd/kttsd.cpp 1.14 M +29 -5 plugins/festivalint/festivalintproc.cpp 1.6 --- kdenonbeta/kttsd/kttsd/kttsd.cpp #1.13:1.14 @@ -370,4 +370,5 @@ void KTTSD::closeSelected(){ void KTTSD::quitSelected(){ + stopText(); kapp->quit(); } --- kdenonbeta/kttsd/plugins/festivalint/festivalintproc.cpp #1.5:1.6 @@ -26,4 +26,5 @@ #include #include +#include // #include @@ -47,5 +48,9 @@ FestivalIntProc::FestivalIntProc( QObjec FestivalIntProc::~FestivalIntProc(){ kdDebug() << "Running: FestivalIntProc::~FestivalIntProc()" << endl; - if (initialized) delete festProc; + if (initialized) + { + stopText(); + if (festProc) delete festProc; + } } @@ -159,7 +164,26 @@ void FestivalIntProc::stopText(){ if (initialized) { - festProc->writeStdin(QString("(audio_mode 'shutup)"), true); + if (ready) + { festProc->writeStdin(QString("(quit)"), true); - festProc->kill(); + if (festProc) festProc->wait(1); + } + else + { + // This is an ugly hack, but it seems to be the only way to kill + // a running KProcess without causing a crash. + pid_t pid = festProc->pid(); + if (pid) + { + int status; + kill(pid, SIGTERM); + waitpid(pid, &status, 0); + } + } + if (festProc) festProc->closeAll(); + initialized = false; + ready = true; + if (festProc) delete festProc; + festProc = 0; } kdDebug() << "Festival stopped." << endl;