mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-09 18:31:04 +00:00
Do not use Application for a 'cancel export' boolean
It is not good for a support function to depend of anything outside of it, especially Application. Here the boolean that indicates that export should be canceled is put in Systemcall. This allows to remove all the dummy theApp() function that have been added here and there for linking needs.
This commit is contained in:
parent
fd6ff2b203
commit
39a8000589
@ -69,13 +69,6 @@ namespace lyx {
|
||||
// Dummy verbose support
|
||||
bool verbose = false;
|
||||
|
||||
struct App {
|
||||
bool cancel_export;
|
||||
};
|
||||
|
||||
App app;
|
||||
App * theApp() { return &app; }
|
||||
|
||||
// Dummy LyXRC support
|
||||
struct LyXRC {
|
||||
string icon_set;
|
||||
|
@ -166,7 +166,7 @@ class Application
|
||||
{
|
||||
public:
|
||||
///
|
||||
Application() : cancel_export(false) {}
|
||||
Application() {}
|
||||
///
|
||||
virtual ~Application() {}
|
||||
|
||||
@ -253,8 +253,6 @@ public:
|
||||
|
||||
// Add a buffer to the current view, do not switch to it.
|
||||
virtual bool unhide(Buffer * buf) = 0;
|
||||
///
|
||||
bool cancel_export;
|
||||
};
|
||||
|
||||
/// Return the list of loadable formats.
|
||||
|
@ -3731,7 +3731,7 @@ void GuiView::dispatch(FuncRequest const & cmd, DispatchResult & dr)
|
||||
break;
|
||||
}
|
||||
case LFUN_EXPORT_CANCEL: {
|
||||
theApp()->cancel_export = true;
|
||||
Systemcall::killscript();
|
||||
break;
|
||||
}
|
||||
case LFUN_BUFFER_SWITCH: {
|
||||
|
@ -23,10 +23,7 @@
|
||||
#include "support/os.h"
|
||||
#include "support/ProgressInterface.h"
|
||||
|
||||
#include "frontends/Application.h"
|
||||
|
||||
#include "LyX.h"
|
||||
#include "LyXRC.h"
|
||||
|
||||
#include <cstdlib>
|
||||
#include <iostream>
|
||||
@ -236,6 +233,12 @@ string const parsecmd(string const & incmd, string & infile, string & outfile,
|
||||
} // namespace
|
||||
|
||||
|
||||
void Systemcall::killscript()
|
||||
{
|
||||
SystemcallPrivate::kill_script = true;
|
||||
}
|
||||
|
||||
|
||||
int Systemcall::startscript(Starttype how, string const & what,
|
||||
string const & path, string const & lpath,
|
||||
bool process_events)
|
||||
@ -315,6 +318,9 @@ int Systemcall::startscript(Starttype how, string const & what,
|
||||
}
|
||||
|
||||
|
||||
bool SystemcallPrivate::kill_script = false;
|
||||
|
||||
|
||||
SystemcallPrivate::SystemcallPrivate(std::string const & sf, std::string const & of,
|
||||
std::string const & ef)
|
||||
: state(Error), process_(new QProcess), out_index_(0), err_index_(0),
|
||||
@ -403,11 +409,11 @@ void SystemcallPrivate::startProcess(QString const & cmd, string const & path,
|
||||
bool SystemcallPrivate::waitAndCheck()
|
||||
{
|
||||
Sleep::millisec(100);
|
||||
if (theApp() && theApp()->cancel_export) {
|
||||
if (kill_script) {
|
||||
// is there a better place to reset this?
|
||||
process_->kill();
|
||||
state = Killed;
|
||||
theApp()->cancel_export = false;
|
||||
kill_script = false;
|
||||
LYXERR0("Export Canceled!!");
|
||||
return false;
|
||||
}
|
||||
|
@ -38,7 +38,7 @@ public:
|
||||
WaitLoop, //< wait, but check occasionally for cancellation
|
||||
DontWait //< don't wait for completion
|
||||
};
|
||||
|
||||
|
||||
// enum values chosen hopefully not to conflict with ordinary return values
|
||||
enum ReturnValue {
|
||||
OK = 0,
|
||||
@ -48,6 +48,10 @@ public:
|
||||
KILLED = 9001
|
||||
};
|
||||
|
||||
|
||||
// Kill the process which is running at time being
|
||||
static void killscript();
|
||||
|
||||
/** Start child process.
|
||||
* The string "what" contains a commandline with arguments separated
|
||||
* by spaces and encoded in the filesystem encoding. "$$s" will be
|
||||
|
@ -58,6 +58,9 @@ public:
|
||||
|
||||
static void killProcess(QProcess * p);
|
||||
|
||||
// when true, kill any running script ASAP
|
||||
static bool kill_script;
|
||||
|
||||
|
||||
public Q_SLOTS:
|
||||
void stdOut();
|
||||
|
@ -62,11 +62,4 @@ namespace lyx {
|
||||
return dummy;
|
||||
}
|
||||
|
||||
struct App {
|
||||
bool cancel_export;
|
||||
};
|
||||
|
||||
App app;
|
||||
App * theApp() { return &app; }
|
||||
|
||||
} // namespace lyx
|
||||
|
@ -65,11 +65,4 @@ namespace lyx {
|
||||
return dummy;
|
||||
}
|
||||
|
||||
struct App {
|
||||
bool cancel_export;
|
||||
};
|
||||
|
||||
App app;
|
||||
App * theApp() { return &app; }
|
||||
|
||||
} // namespace lyx
|
||||
|
@ -129,16 +129,6 @@ frontend::FontMetrics const & theFontMetrics(FontInfo const &) {
|
||||
return dummy;
|
||||
}
|
||||
|
||||
//
|
||||
// Dummy theApp() support (needed by support/Systemcall.cpp)
|
||||
//
|
||||
struct App {
|
||||
bool cancel_export;
|
||||
};
|
||||
|
||||
App app;
|
||||
App * theApp() { return &app; }
|
||||
|
||||
//
|
||||
// Keep the linker happy on Windows
|
||||
//
|
||||
|
Loading…
Reference in New Issue
Block a user