[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    kdenonbeta/kttsd
From:       Gary Cramblitt <garycramblitt () comcast ! net>
Date:       2004-03-19 3:34:29
Message-ID: 20040319033429.E6B909990 () office ! kde ! org
[Download RAW message or body]

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 <kstandarddirs.h>
 #include <qthread.h>
+#include <kprocio.h>
 
 // #include <festival.h>
@@ -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;


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic