]> git.lyx.org Git - features.git/commitdiff
Revert qprocess code. Revisions reverted: 22026, 22030, 22044, 22048,
authorEnrico Forestieri <forenr@lyx.org>
Wed, 12 Dec 2007 18:25:53 +0000 (18:25 +0000)
committerEnrico Forestieri <forenr@lyx.org>
Wed, 12 Dec 2007 18:25:53 +0000 (18:25 +0000)
22077, 22078, 22079, 22080, 22081.

Sorry Peter, but this was breaking too many things, see discussions
on lyx-devel.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@22101 a592a061-630c-0410-9148-cb99ea01b6c8

15 files changed:
development/scons/SConstruct
development/scons/scons_manifest.py
lib/ui/stdmenus.inc
src/Buffer.cpp
src/LaTeX.cpp
src/frontends/qt4/GuiProgress.cpp [deleted file]
src/frontends/qt4/GuiProgress.h [deleted file]
src/frontends/qt4/GuiView.cpp
src/frontends/qt4/Makefile.am
src/support/Makefile.am
src/support/ProgressInterface.h [deleted file]
src/support/Systemcall.cpp
src/support/Systemcall.h
src/support/SystemcallPrivate.cpp [deleted file]
src/support/SystemcallPrivate.h [deleted file]

index ee93246cf583d1a0098fea3fb4ae785ca2fd9e4d..f4c71d1f44baf376fb88e295244c1973496331ca 100644 (file)
@@ -1499,11 +1499,6 @@ if (included_gettext and not libExists('included_intl')) or 'intl' in BUILD_TARG
 #
 # src/support
 #
-frontend_env['QT4_MOCHPREFIX'] = ''
-frontend_env['QT4_MOCHSUFFIX'] = '_moc.cpp'
-
-support_moced_files = [frontend_env.Moc4('$BUILDDIR/src/support/%s' % x)
-    for x in src_support_header_files ]
 support = frontend_env.StaticLibrary(
     target = '$LOCALLIBPATH/support',
     source = ['$BUILDDIR/src/support/%s' % x for x in src_support_files] + \
@@ -1516,7 +1511,7 @@ support = frontend_env.StaticLibrary(
         '-DQT_NO_STL',
         '-DQT_NO_KEYWORDS',
     ],
-    CPPPATH = ['$CPPPATH', '$BUILDDIR/src/support', '$TOP_SRCDIR/src/support/minizip']
+    CPPPATH = ['$CPPPATH', '$TOP_SRCDIR/src/support/minizip']
 )
 Alias('support', support)
 
@@ -1564,6 +1559,9 @@ Alias('graphics', graphics)
 #
 # src/frontend/qt4
 #
+frontend_env['QT4_MOCHPREFIX'] = ''
+frontend_env['QT4_MOCHSUFFIX'] = '_moc.cpp'
+
 # tells scons how to get these moced files, although not all moced files are needed
 # (or are actually generated).
 qt4_moced_files = [frontend_env.Moc4('$BUILDDIR/src/frontends/qt4/%s' % x)
index 617d76209c18f6b00c92d3b4e5290c9d8d354c86..a133d9b13b909bc6d11bbf6faab733bec7b41808 100644 (file)
@@ -297,9 +297,7 @@ src_support_header_files = Split('''
     RandomAccessList.h
     SignalSlot.h
     SignalSlotPrivate.h
-    ProgressInterface.h
     Systemcall.h
-    SystemcallPrivate.h
     Timeout.h
     Translator.h
     convert.h
@@ -340,7 +338,6 @@ src_support_files = Split('''
     Path.cpp
     SignalSlot.cpp
     Systemcall.cpp
-    SystemcallPrivate.cpp
     Timeout.cpp
     abort.cpp
     convert.cpp
@@ -758,7 +755,6 @@ src_frontends_qt4_header_files = Split('''
     GuiPopupMenu.h
     GuiPrefs.h
     GuiPrint.h
-    GuiProgress.h
     GuiRef.h
     GuiSearch.h
     GuiSelection.h
@@ -846,7 +842,6 @@ src_frontends_qt4_files = Split('''
     GuiParagraph.cpp
     GuiPopupMenu.cpp
     GuiPrefs.cpp
-    GuiProgress.cpp
     GuiPrint.cpp
     GuiRef.cpp
     GuiSearch.cpp
index f31dc262bd056b16cf98dccad2070199715bb9c1..d108e827de2124ab14d7afa011760d5d5de8acfd 100644 (file)
@@ -286,7 +286,6 @@ Menuset
                Item "Fold Math Macro" "math-macro-fold"
                Separator
                Item "View Source|S" "dialog-toggle view-source"
-               Item "View Console" "dialog-toggle view-console"
                Submenu "Update|U" "view_update"
                ViewFormats
                Separator
index 319942d46b8f9457795e8d8b14ad986cad7cacad..83002cc6f7aae662baf7eea09bd340e4144ff1be 100644 (file)
@@ -1083,7 +1083,8 @@ void Buffer::writeLaTeXSource(odocstream & os,
        if (output_preamble) {
                if (!runparams.nice) {
                        // code for usual, NOT nice-latex-file
-                       os << "\\nonstopmode\n"; 
+                       os << "\\batchmode\n"; // changed
+                       // from \nonstopmode
                        d->texrow.newline();
                }
                if (!original_path.empty()) {
index 5c62824e0e12dd5a5d8e8d3d57119e593218eb5c..7a71b457c9d0ef41fcb93a4d4fe3636ec5508acd 100644 (file)
@@ -405,9 +405,11 @@ int LaTeX::run(TeXErrors & terr)
 int LaTeX::startscript()
 {
        // onlyFilename() is needed for cygwin
-       string tmp = cmd + ' ' + "-max-print-line=200 "
-                               + quoteName(onlyFilename(file.toFilesystemEncoding()));
-       return Systemcall().startscript(Systemcall::Wait, tmp);
+       string tmp = cmd + ' '
+                    + quoteName(onlyFilename(file.toFilesystemEncoding()))
+                    + " > " + os::nulldev();
+       Systemcall one;
+       return one.startscript(Systemcall::Wait, tmp);
 }
 
 
diff --git a/src/frontends/qt4/GuiProgress.cpp b/src/frontends/qt4/GuiProgress.cpp
deleted file mode 100644 (file)
index 95a56d7..0000000
+++ /dev/null
@@ -1,66 +0,0 @@
-// -*- C++ -*-
-/**
- * \file GuiProgress.cpp
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author Peter Kümmel
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#include <config.h>
-
-#include "GuiProgress.h"
-
-#include "qt_helpers.h"
-
-#include "support/Systemcall.h"
-
-#include <QApplication>
-
-
-namespace lyx {
-namespace frontend {
-
-
-GuiProgress::GuiProgress(GuiView & parent, Qt::DockWidgetArea area, 
-       Qt::WindowFlags flags) : DockView(parent, "view-console", area, flags)
-{
-       setWindowTitle(qt_("External process monitoring"));
-       setWidget(&text_edit);
-       support::Systemcall::registerProgressInterface(this);
-}
-
-
-void GuiProgress::appendMessage(QString const & msg)
-{
-       text_edit.append(msg);
-       // QEventLoop::ExcludeUserInputEvents: 
-       // don't allow user inputs while processing a document
-       // if we allow it, we open will Pandora's Box of multithreading
-       QApplication::processEvents(QEventLoop::ExcludeUserInputEvents);
-}
-
-
-void GuiProgress::clearMessages()
-{
-       text_edit.clear();
-}
-
-
-Dialog * createGuiProgress(GuiView & lv)
-{
-       GuiView & guiview = static_cast<GuiView &>(lv);
-#ifdef Q_WS_MACX
-       // TODO where to show up on the Mac?
-       //return new GuiProgress(guiview, Qt::RightDockWidgetArea, Qt::Drawer);
-#else
-       return new GuiProgress(guiview, Qt::BottomDockWidgetArea);
-#endif
-}
-
-} // namespace frontend
-} // namespace lyx
-
-
diff --git a/src/frontends/qt4/GuiProgress.h b/src/frontends/qt4/GuiProgress.h
deleted file mode 100644 (file)
index 6a41646..0000000
+++ /dev/null
@@ -1,62 +0,0 @@
-// -*- C++ -*-
-/**
- * \file GuiProgress.h
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author Peter Kümmel
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#ifndef GUIPROGRESS_H
-#define GUIPROGRESS_H
-
-#include "support/ProgressInterface.h"
-
-#include "DockView.h"
-
-#include <QTextEdit>
-
-#include <string>
-
-
-namespace lyx {
-namespace frontend {
-
-
-class GuiProgress : 
-       public DockView, 
-       public lyx::support::ProgressInterface
-{
-
-public:
-       GuiProgress(
-               GuiView & parent, ///< the main window where to dock.
-               Qt::DockWidgetArea area, ///< Position of the dock (and also drawer)
-               Qt::WindowFlags flags = 0);
-
-       void appendMessage(QString const &);
-       void clearMessages();
-
-       /// Controller inherited method.
-       ///@{
-       bool initialiseParams(std::string const & source) { return true; }
-       void clearParams() {}
-       void dispatchParams() {}
-       bool isBufferDependent() const { return false; }
-       bool canApply() const { return true; }
-       bool canApplyToReadOnly() const { return true; }
-       void updateView() {}
-       ///@}
-
-private:
-       QTextEdit text_edit;
-};
-
-
-} // namespace frontend
-} // namespace lyx
-
-#endif
-
index 0217a128374a0d49b7e61495755d05441d82c259..0674d5ed7c7367622a517b84ccd09a1abf7658b3 100644 (file)
@@ -23,7 +23,6 @@
 #include "GuiMenubar.h"
 #include "GuiToolbar.h"
 #include "GuiToolbars.h"
-#include "GuiProgress.h"
 
 #include "qt_helpers.h"
 
@@ -1572,7 +1571,7 @@ char const * const dialognames[] = {
 "thesaurus",
 #endif
 
-"texinfo", "toc", "href", "view-source", "view-console", "vspace", "wrap", "listings" };
+"texinfo", "toc", "href", "view-source", "vspace", "wrap", "listings" };
 
 char const * const * const end_dialognames =
        dialognames + (sizeof(dialognames) / sizeof(char *));
@@ -1799,7 +1798,6 @@ Dialog * createGuiThesaurus(GuiView & lv);
 Dialog * createGuiHyperlink(GuiView & lv);
 Dialog * createGuiVSpace(GuiView & lv);
 Dialog * createGuiViewSource(GuiView & lv);
-Dialog * createGuiProgress(GuiView & lv);
 Dialog * createGuiWrap(GuiView & lv);
 
 
@@ -1851,8 +1849,6 @@ Dialog * GuiView::build(string const & name)
                return createGuiLog(*this);
        if (name == "view-source")
                return createGuiViewSource(*this);
-       if (name == "view-console")
-               return createGuiProgress(*this);
        if (name == "mathdelimiter")
                return createGuiDelimiter(*this);
        if (name == "mathmatrix")
index 8221cd4954de4a1552130672d37c4912d9a882c1..ed17a5de395bcdb727856cb28c59e6047a4c7c9e 100644 (file)
@@ -102,7 +102,6 @@ SOURCEFILES = \
        GuiPopupMenu.cpp \
        GuiPrefs.cpp \
        GuiPrint.cpp \
-       GuiProgress.cpp \
        GuiRef.cpp \
        GuiSearch.cpp \
        GuiSelection.cpp \
@@ -189,7 +188,6 @@ MOCHEADER = \
        GuiPopupMenu.h \
        GuiPrefs.h \
        GuiPrint.h \
-       GuiProgress.h \
        GuiRef.h \
        GuiSearch.h \
        GuiSelection.h \
index 1f12c670341bdd2015c5c15ceca04ccf74221cb9..3e69f53f008bb50ac22ab11e069a158c6dabf52f 100644 (file)
@@ -12,25 +12,6 @@ liblyxsupport_la_LDFLAGS = $(QT4_CORE_LDFLAGS)
 
 BUILT_SOURCES = $(PCH_FILE)
 
-#########################  Qt stuff  #############################
-# 
-
-CLEANFILES += $(MOCEDFILES)
-BUILT_SOURCES += $(MOCEDFILES)
-
-MOCEDFILES = $(MOCHEADER:%.h=%_moc.cpp)
-
-%_moc.cpp: %.h
-       $(MOC4) -o $@ $<
-
-MOCHEADER = \
-       SystemcallPrivate.h
-
-liblyxsupport_la_DEPENDENCIES = $(MOCEDFILES)
-
-#
-#################################################################
-
 AM_CPPFLAGS += $(PCH_FLAGS) -I$(srcdir)/.. $(BOOST_INCLUDES)
 AM_CPPFLAGS += $(QT4_CPPFLAGS) $(QT4_CORE_INCLUDES) -I$(srcdir)/minizip
 
@@ -39,7 +20,6 @@ AM_CPPFLAGS += $(QT4_CPPFLAGS) $(QT4_CORE_INCLUDES) -I$(srcdir)/minizip
 liblyxsupport_la_CFLAGS = -x c++
 
 liblyxsupport_la_SOURCES = \
-       $(MOCHEADER) \
        FileMonitor.h \
        FileMonitor.cpp \
        RandomAccessList.h \
@@ -95,8 +75,6 @@ liblyxsupport_la_SOURCES = \
        strfwd.h \
        Systemcall.cpp \
        Systemcall.h \
-       SystemcallPrivate.cpp \
-       ProgressInterface.h \
        SignalSlot.cpp \
        SignalSlot.h \
        SignalSlotPrivate.h \
diff --git a/src/support/ProgressInterface.h b/src/support/ProgressInterface.h
deleted file mode 100644 (file)
index 1bc980e..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-// -*- C++ -*-
-/**
- * \file ProgressInterface.h
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author Peter Kümmel
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#ifndef LYX_SUPPORT_PROGRESSINTERFACE_H
-#define LYX_SUPPORT_PROGRESSINTERFACE_H
-
-class QString;
-
-namespace lyx {
-namespace support {
-
-
-class ProgressInterface
-{
-public:
-       virtual ~ProgressInterface() {}
-
-       virtual void appendMessage(QString const &) = 0;
-       virtual void clearMessages() = 0;
-
-protected:
-       ProgressInterface() {}
-};
-
-
-} // namespace support
-} // namespace lyx
-
-#endif // LYX_SUPPORT_PROGRESSINTERFACE_H
-
index bf7192dd428f2e6742e7e03eb18b02ec7f71b10b..e8fbd6404e4206d91cb1e8600622184d27099e43 100644 (file)
@@ -4,7 +4,6 @@
  * Licence details can be found in the file COPYING.
  *
  * \author Asger Alstrup
- * \author Peter Kümmel
  *
  * Interface cleaned up by
  * \author Angus Leeming
 #include <config.h>
 
 #include "support/Systemcall.h"
-#include "support/SystemcallPrivate.h"
-#include "support/ProgressInterface.h"
+#include "support/os.h"
 
-namespace lyx {
-namespace support {
-
-static ProgressInterface* progress_impl = 0;
-
-
-void Systemcall::registerProgressInterface(ProgressInterface* p)
-{
-       progress_impl = p;
-}
+#include <cstdlib>
 
+using std::string;
 
-ProgressInterface* Systemcall::progress()
-{
-       return progress_impl;
-}
+#ifndef CXX_GLOBAL_CSTD
+using std::system;
+#endif
 
+namespace lyx {
+namespace support {
 
-int Systemcall::startscript(Starttype how, std::string const & what)
+// Reuse of instance
+int Systemcall::startscript(Starttype how, string const & what)
 {
-       // TODO Reuse of instance?
-       SystemcallPrivate* process = new SystemcallPrivate;
-       if (how == Wait)
-               return process->start(what, true);
-       return process->start(what, false);
+       string command = what;
+
+       if (how == DontWait) {
+               switch (os::shell()) {
+               case os::UNIX:
+                       command += " &";
+                       break;
+               case os::CMD_EXE:
+                       command = "start /min " + command;
+                       break;
+               }
+       }
+
+       return ::system(command.c_str());
 }
 
-
 } // namespace support
 } // namespace lyx
index 8ed0277c0d922e407f249c9c52c6ffe73c1d88bf..61ba092a2dde0a3c93296de11a6650569faea15c 100644 (file)
@@ -5,7 +5,6 @@
  * Licence details can be found in the file COPYING.
  *
  * \author Asger Alstrup
- * \author Peter Kümmel
  *
  * Interface cleaned up by
  * \author Angus Leeming
 namespace lyx {
 namespace support {
 
-class ProgressInterface;
-
 /**
  * An instance of Class Systemcall represents a single child process.
  *
- * Class Systemcall uses SystemcallPrivate to launch the child process.
+ * Class Systemcall uses system() to launch the child process.
  * The user can choose to wait or not wait for the process to complete, but no
  * callback is invoked upon completion of the child.
  *
@@ -46,9 +43,6 @@ public:
         *  by spaces.
         */
        int startscript(Starttype how, std::string const & what);
-
-       static void registerProgressInterface(ProgressInterface*);
-       static ProgressInterface* progress();
 };
 
 } // namespace support
diff --git a/src/support/SystemcallPrivate.cpp b/src/support/SystemcallPrivate.cpp
deleted file mode 100644 (file)
index 6bab2f5..0000000
+++ /dev/null
@@ -1,156 +0,0 @@
-// -*- C++ -*-
-/**
- * \file SystemcallPrivate.cpp
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author Peter Kümmel
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#include <config.h>
-
-#include "SystemcallPrivate.h"
-
-#include "Systemcall.h"
-#include "ProgressInterface.h"
-
-#include "gettext.h"
-#include "qstring_helpers.h"
-
-
-namespace lyx {
-namespace support {
-
-
-// TODO should we move qt_ to qstring_helpers?
-static
-QString const qt_(char const * str)
-{
-       return toqstr(_(str));
-}
-
-
-
-SystemcallPrivate::SystemcallPrivate() 
-{ 
-       ProgressInterface* progress = Systemcall::progress();
-       if (progress) {
-               connect(&process, SIGNAL(readyReadStandardOutput()), this, SLOT(newProcessOutput()));
-               connect(&process, SIGNAL(started()), this, SLOT(processStarted()));
-               connect(&process, SIGNAL(error(QProcess::ProcessError)), this, SLOT(processError(QProcess::ProcessError)));
-               connect(&process, SIGNAL(finished(int, QProcess::ExitStatus)), 
-                               this, SLOT(processFinished(int, QProcess::ExitStatus)));                                
-       }
-}
-
-
-int SystemcallPrivate::start(const std::string & cmd, bool waitForFinished)
-{
-       ProgressInterface* progress = Systemcall::progress();
-       if (progress) {
-               progress->clearMessages();
-               progress->appendMessage(qt_("Starting process with command "));
-               progress->appendMessage(toqstr(cmd));
-       }
-
-       process.setReadChannel(QProcess::StandardOutput);
-       process.start(toqstr(cmd), QStringList(), QIODevice::ReadOnly);
-       // wait some seconds until the process has started
-       process.waitForStarted(10 * 1000);
-       if (waitForFinished) {
-               // with waitForFinished(-1); we only get one signal per run
-               while (process.state() == QProcess::Running)
-                       process.waitForFinished(500);
-               return process.exitCode();
-       }
-       if (process.state() != QProcess::Running) {
-               process.kill();
-               // TODO this needs more testing
-               deleteLater();
-               return -1;
-       }
-       return 0;
-}
-
-
-void SystemcallPrivate::newProcessOutput()
-{
-       ProgressInterface* progress = Systemcall::progress();
-       if (progress) {
-               const QString output = QString::fromLocal8Bit(process.readAllStandardOutput());
-               progress->appendMessage(output);
-       }
-}
-
-
-void SystemcallPrivate::processStarted()
-{
-       ProgressInterface* progress = Systemcall::progress();
-       if (progress) {
-               progress->appendMessage(qt_("Process started\n"));
-       }
-}
-
-
-void SystemcallPrivate::processError(QProcess::ProcessError err)
-{
-       ProgressInterface* progress = Systemcall::progress();
-       if (progress) {
-               QString message;
-               switch (err) {
-                       case QProcess::FailedToStart:
-                               message = qt_("The process failed to start. Either the invoked program is missing, "
-                                             "or you may have insufficient permissions to invoke the program.");
-                               break;
-                       case QProcess::Crashed:
-                               message = qt_("The process crashed some time after starting successfully.");
-                               break;
-                       case QProcess::Timedout:
-                               message = qt_("The process timed out. It might be restarted automatically.");
-                               break;
-                       case QProcess::WriteError:
-                               message = qt_("An error occurred when attempting to write to the process. For example, "
-                                             "the process may not be running, or it may have closed its input channel.");
-                               break;
-                       case QProcess::ReadError:
-                               message = qt_("An error occurred when attempting to read from the process. For example, "
-                                             "the process may not be running.");
-                               break;
-                       case QProcess::UnknownError:
-                       default:
-                               message = qt_("An unknown error occured.");
-                               break;
-               }
-               progress->appendMessage(qt_("The process failed: ") + message + '\n');
-       }
-}
-
-
-void SystemcallPrivate::processFinished(int, QProcess::ExitStatus status)
-{
-       ProgressInterface* progress = Systemcall::progress();
-       if (progress) {
-               QString message;
-               switch (status) {
-                       case QProcess::NormalExit:
-                               message = qt_("The process exited normally.");
-                               break;
-                       case QProcess::CrashExit:
-                               message = qt_("The process crashed.");
-                               break;
-                       default:
-                               message = qt_("Unknown exit state.");
-                               break;
-               }
-               progress->appendMessage(qt_("Process finished: ") + message + '\n');
-       }
-       deleteLater();
-}
-
-
-} // namespace support
-} // namespace lyx
-
-#include "SystemcallPrivate_moc.cpp"
diff --git a/src/support/SystemcallPrivate.h b/src/support/SystemcallPrivate.h
deleted file mode 100644 (file)
index 98073da..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-// -*- C++ -*-
-/**
- * \file SystemcallPrivate.h
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author Peter Kümmel
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#ifndef LYX_SUPPORT_SYSTEMCALLPRIVATE_H
-#define LYX_SUPPORT_SYSTEMCALLPRIVATE_H
-
-#include <QObject>
-#include <QProcess>
-
-#include <string>
-
-
-namespace lyx {
-namespace support {
-
-class ProgressInterface;
-
-class SystemcallPrivate : public QObject
-{
-       Q_OBJECT
-
-public:
-       SystemcallPrivate();
-
-       // When waitForFinished == true :   returns the exit code of the process
-       // When waitForFinished == false:   returns 0 if the process could be started
-       int start(const std::string & cmd, bool waitForFinished);
-
-public Q_SLOTS:
-       void newProcessOutput();
-       void processStarted();
-       void processError(QProcess::ProcessError);
-       void processFinished(int, QProcess::ExitStatus);
-       
-private:
-       QProcess process;
-};
-
-
-} // namespace support
-} // namespace lyx
-
-#endif // LYX_SUPPORT_SYSTEMCALLPRIVATE_H