]> git.lyx.org Git - lyx.git/blobdiff - src/sp_spell.C
gross hack to set layout
[lyx.git] / src / sp_spell.C
index ce6323cfaa8b0bff415c390cdd6bb5742770d401..3563c32cbe3aa96d642d80643bb56b3b29417d5e 100644 (file)
@@ -17,6 +17,8 @@
 #pragma implementation
 #endif
 
+#include <sys/types.h>
+#include <sys/wait.h>
 #include <unistd.h>
 #include <fcntl.h>
 #include <stdio.h>
@@ -46,6 +48,7 @@
 #include "LString.h"
 #include "support/lstrings.h"
 #include "lyxrc.h"
+#include "language.h"
 #include "debug.h"
 #include "encoding.h"
 #include "sp_ispell.h"
@@ -57,9 +60,6 @@ namespace {
        pid_t isp_pid = -1; 
 }
 
-/// can be found in src/insets/figinset.C
-extern void sigchldchecker(pid_t pid, int * status);
-
 ///
 // ------------------- start special pspell code/class --------------------
 ///
@@ -74,13 +74,15 @@ extern void sigchldchecker(pid_t pid, int * status);
 
 
 PSpell::PSpell() 
-       : sc(0), els(0), spell_error_object(0), flag(ISP_UNKNOWN)
+       : sc(0), els(0), spell_error_object(0), flag(ISP_UNKNOWN),
+         alive_(false)
 {
 }
 
 
 PSpell::PSpell(BufferParams const & params, string const & lang)
-       : sc(0), els(0), spell_error_object(0), flag(ISP_UNKNOWN)
+       : sc(0), els(0), spell_error_object(0), flag(ISP_UNKNOWN),
+         alive_(false)
 {
        initialize(params, lang);
 }
@@ -106,6 +108,7 @@ void PSpell::initialize(BufferParams const &, string const & lang)
                error_ = 0;
                sc = to_pspell_manager(spell_error_object);
                spell_error_object = 0;
+               alive_ = true;
        }
 }
 
@@ -185,11 +188,6 @@ char const * PSpell::error()
 }
 
 
-void PSpell::sigchldhandler(pid_t pid, int * status)
-{
-       sigchldchecker(pid, status);
-}
-
 #endif
 
 ///
@@ -409,17 +407,31 @@ void ISpell::initialize(BufferParams const & params, string const & lang)
        if (isp_pid == -1) {
                error_ = 
                        "\n\n"
-                       "The ispell-process has died for some reason. *One* possible reason\n"
-                       "could be that you do not have a dictionary file\n"
-                       "for the language of this document installed.\n"
-                       "Check /usr/lib/ispell or set another\n"
-                       "dictionary in the Spellchecker Options menu.";
+                       "The spellcheck-process has died for some reason.\n"
+                       "*One* possible reason could be that you do not have\n"
+                       "a dictionary file for the language of this document\n"
+                       "installed.\n"
+                       "Check your spellchecker or set another dictionary\n"
+                       "in the Spellchecker Options menu.\n\n";
        } else {
                error_ = 0;
        }
 }
 
 
+/* FIXME: this is a minimalist solution until the above
+ * code is able to work with forkedcall.h. We only need
+ * to reap the zombies here.
+ */
+void reapSpellchecker(void)
+{
+       if (isp_pid == -1) 
+               return;
+
+       waitpid(isp_pid, 0, WNOHANG);
+}
+
 bool ISpell::alive()
 {
        return isp_pid != -1;
@@ -526,20 +538,6 @@ void ISpell::store(string const & mis, string const & cor)
 }
 
 
-void ISpell::sigchldhandler(pid_t pid, int * status)
-{
-       if (isp_pid > 0) {
-               if (pid == isp_pid) {
-                       isp_pid = -1;
-                       // set the file descriptor to nonblocking so we can
-                       // continue 
-                       fcntl(isp_fd, F_SETFL, O_NONBLOCK);
-               }
-       }
-       sigchldchecker(pid, status);
-}
-
-
 char const * ISpell::error()
 {
        return error_;