Exemplo n.º 1
0
void Invocation::terminate(bool needWarnings, bool needDeletingEnvironment) {
	if (needWarnings) cleanWarningsQueue();
	if (environmentCreated && needDeletingEnvironment) clearEnvironment();
	delete this;
	cout << endl;
	exit(0);
}
Exemplo n.º 2
0
/**
 * Executes the back-end process.
 * @param	sName		The name of the process (for error messages)
 * @param	slArgs		A list containing the command-line arguments
 * @param	sWorkDir	(Optional) working directory
 * @param	bBlock		(Optional) true to block, false otherwise
 * @return	true if the process was executed successfully, false otherwise
 */
bool Frontend::run(const QString& sName, const QStringList& slArgs, 
	const QString& sWorkDir, bool bBlock)
{
	// Cannot start if another controlled process is currently running
	if (state() == QProcess::Running) {
		m_sError = i18n("Cannot restart while another process is still "
			"running");
		return false;
	}

	// Reset variables
	m_nRecords = 0;
	m_bKilled = false;
	
    clearEnvironment(); // TODO: to check if this call is needed
	// Setup the command-line arguments
	clearProgram();
	*this << slArgs;

	// Set the working directory, if requested
	if (!sWorkDir.isEmpty())
		setWorkingDirectory(sWorkDir);

	// Execute the child process
    bool ret = true;
    if (bBlock) {
        if (execute() < 0)
            ret = false;
    } else {
        start();
    }
    if (!ret) {
		m_sError = sName + i18n(": Failed to start process");
		return false;
	}
	
	m_sError = i18n("No error");
	return true;
}