annotate hgrunner.cpp @ 239:661f5808aa0a

* Overhaul settings-defaults mechanism, and add Restore Defaults button to settings dialog
author Chris Cannam
date Mon, 10 Jan 2011 15:18:21 +0000
parents e2f2c6e3c01b
children 53ad43d5a463
rev   line source
Chris@57 1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
Chris@57 2
Chris@57 3 /*
Chris@57 4 EasyMercurial
Chris@57 5
Chris@57 6 Based on HgExplorer by Jari Korhonen
Chris@57 7 Copyright (c) 2010 Jari Korhonen
Chris@57 8 Copyright (c) 2010 Chris Cannam
Chris@57 9 Copyright (c) 2010 Queen Mary, University of London
Chris@57 10
Chris@57 11 This program is free software; you can redistribute it and/or
Chris@57 12 modify it under the terms of the GNU General Public License as
Chris@57 13 published by the Free Software Foundation; either version 2 of the
Chris@57 14 License, or (at your option) any later version. See the file
Chris@57 15 COPYING included with this distribution for more information.
Chris@57 16 */
jtkorhonen@0 17
jtkorhonen@0 18 #include "hgrunner.h"
Chris@62 19 #include "common.h"
Chris@57 20 #include "debug.h"
Chris@50 21
Chris@50 22 #include <QPushButton>
Chris@50 23 #include <QListWidget>
Chris@50 24 #include <QDialog>
Chris@50 25 #include <QLabel>
Chris@50 26 #include <QVBoxLayout>
Chris@62 27 #include <QSettings>
Chris@75 28 #include <QInputDialog>
Chris@188 29 #include <QTemporaryFile>
Chris@161 30 #include <QDir>
jtkorhonen@0 31
Chris@43 32 #include <iostream>
Chris@75 33 #include <errno.h>
Chris@75 34 #include <stdio.h>
Chris@111 35 #include <stdlib.h>
jtkorhonen@0 36
Chris@76 37 #ifndef Q_OS_WIN32
Chris@111 38 #include <unistd.h>
Chris@113 39 #include <termios.h>
Chris@111 40 #include <fcntl.h>
Chris@80 41 #endif
Chris@76 42
Chris@172 43 HgRunner::HgRunner(QString myDirPath, QWidget * parent) :
Chris@172 44 QProgressBar(parent),
Chris@172 45 m_myDirPath(myDirPath)
jtkorhonen@0 46 {
Chris@113 47 m_proc = 0;
Chris@84 48
Chris@239 49 // Always unbundle the extension: even if it already exists (in
Chris@239 50 // case we're upgrading) and even if we're not going to use it (so
Chris@239 51 // that it's available in case someone wants to use it later,
Chris@239 52 // e.g. to fix a malfunctioning setup). But the path we actually
Chris@239 53 // prefer is the one in the settings first, if it exists; then the
Chris@239 54 // unbundled one; then anything in the path if for some reason
Chris@239 55 // unbundling failed
Chris@239 56 unbundleExtension();
Chris@239 57
jtkorhonen@0 58 setTextVisible(false);
jtkorhonen@0 59 setVisible(false);
Chris@84 60 m_isRunning = false;
jtkorhonen@0 61 }
jtkorhonen@0 62
jtkorhonen@0 63 HgRunner::~HgRunner()
jtkorhonen@0 64 {
Chris@111 65 closeTerminal();
Chris@120 66 if (m_proc) {
Chris@120 67 m_proc->kill();
Chris@122 68 m_proc->deleteLater();
Chris@120 69 }
jtkorhonen@0 70 }
jtkorhonen@0 71
Chris@188 72 QString HgRunner::getUnbundledFileName()
Chris@188 73 {
Chris@188 74 QString home = QDir::homePath();
Chris@188 75 QString target = QString("%1/.easyhg").arg(home);
Chris@188 76 QString extpath = QString("%1/easyhg.py").arg(target);
Chris@188 77 return extpath;
Chris@188 78 }
Chris@188 79
Chris@180 80 QString HgRunner::unbundleExtension()
Chris@161 81 {
Chris@188 82 // Pull out the bundled Python file into a temporary file, and
Chris@188 83 // copy it to our known extension location, replacing the magic
Chris@188 84 // text NO_EASYHG_IMPORT_PATH with our installation location
Chris@188 85
Chris@161 86 QString bundled = ":easyhg.py";
Chris@188 87 QString unbundled = getUnbundledFileName();
Chris@188 88
Chris@188 89 QString target = QFileInfo(unbundled).path();
Chris@161 90 if (!QDir().mkpath(target)) {
Chris@161 91 DEBUG << "Failed to make unbundle path " << target << endl;
Chris@188 92 std::cerr << "Failed to make unbundle path " << target << std::endl;
Chris@180 93 return "";
Chris@161 94 }
Chris@188 95
Chris@161 96 QFile bf(bundled);
Chris@188 97 DEBUG << "unbundle: bundled file will be " << bundled << endl;
Chris@188 98 if (!bf.exists() || !bf.open(QIODevice::ReadOnly)) {
Chris@180 99 DEBUG << "Bundled extension is missing!" << endl;
Chris@180 100 return "";
Chris@180 101 }
Chris@188 102
Chris@188 103 QTemporaryFile tmpfile(QString("%1/easyhg.py.XXXXXX").arg(target));
Chris@188 104 tmpfile.setAutoRemove(false);
Chris@188 105 DEBUG << "unbundle: temp file will be " << tmpfile.fileName() << endl;
Chris@188 106 if (!tmpfile.open()) {
Chris@188 107 DEBUG << "Failed to open temporary file " << tmpfile.fileName() << endl;
Chris@188 108 std::cerr << "Failed to open temporary file " << tmpfile.fileName() << std::endl;
Chris@180 109 return "";
Chris@161 110 }
Chris@188 111
Chris@188 112 QString all = QString::fromUtf8(bf.readAll());
Chris@188 113 all.replace("NO_EASYHG_IMPORT_PATH", m_myDirPath);
Chris@188 114 tmpfile.write(all.toUtf8());
Chris@188 115 DEBUG << "unbundle: wrote " << all.length() << " characters" << endl;
Chris@188 116
Chris@188 117 tmpfile.close();
Chris@188 118
Chris@188 119 QFile ef(unbundled);
Chris@188 120 if (ef.exists()) {
Chris@188 121 DEBUG << "unbundle: removing old file " << unbundled << endl;
Chris@188 122 ef.remove();
Chris@188 123 }
Chris@188 124 DEBUG << "unbundle: renaming " << tmpfile.fileName() << " to " << unbundled << endl;
Chris@188 125 if (!tmpfile.rename(unbundled)) {
Chris@188 126 DEBUG << "Failed to move temporary file to target file " << unbundled << endl;
Chris@188 127 std::cerr << "Failed to move temporary file to target file " << unbundled << std::endl;
Chris@188 128 return "";
Chris@188 129 }
Chris@188 130
Chris@188 131 DEBUG << "Unbundled extension to " << unbundled << endl;
Chris@188 132 return unbundled;
Chris@161 133 }
Chris@161 134
Chris@109 135 void HgRunner::requestAction(HgAction action)
Chris@109 136 {
Chris@109 137 DEBUG << "requestAction " << action.action << endl;
Chris@109 138 bool pushIt = true;
Chris@109 139 if (m_queue.empty()) {
Chris@109 140 if (action == m_currentAction) {
Chris@109 141 // this request is identical to the thing we're executing
Chris@109 142 DEBUG << "requestAction: we're already handling this one, ignoring identical request" << endl;
Chris@109 143 pushIt = false;
Chris@109 144 }
Chris@109 145 } else {
Chris@109 146 HgAction last = m_queue.back();
Chris@109 147 if (action == last) {
Chris@109 148 // this request is identical to the previous thing we
Chris@109 149 // queued which we haven't executed yet
Chris@109 150 DEBUG << "requestAction: we're already queueing this one, ignoring identical request" << endl;
Chris@109 151 pushIt = false;
Chris@109 152 }
Chris@109 153 }
Chris@109 154 if (pushIt) m_queue.push_back(action);
Chris@109 155 checkQueue();
Chris@109 156 }
Chris@109 157
Chris@239 158 QString HgRunner::getHgBinaryName()
Chris@62 159 {
Chris@62 160 QSettings settings;
Chris@175 161 settings.beginGroup("Locations");
Chris@239 162 return settings.value("hgbinary", "").toString();
Chris@62 163 }
Chris@62 164
Chris@239 165 QString HgRunner::getExtensionLocation()
Chris@239 166 {
Chris@239 167 QSettings settings;
Chris@239 168 settings.beginGroup("Locations");
Chris@239 169 QString extpath = settings.value("extensionpath", "").toString();
Chris@239 170 if (extpath != "" && QFile(extpath).exists()) return extpath;
Chris@239 171 return "";
Chris@239 172 }
Chris@239 173
jtkorhonen@0 174 void HgRunner::started()
jtkorhonen@0 175 {
Chris@104 176 DEBUG << "started" << endl;
Chris@75 177 /*
Chris@104 178 m_proc->write("blah\n");
Chris@104 179 m_proc->write("blah\n");
Chris@104 180 m_proc -> closeWriteChannel();
Chris@75 181 */
jtkorhonen@0 182 }
jtkorhonen@0 183
Chris@84 184 void HgRunner::noteUsername(QString name)
Chris@75 185 {
Chris@84 186 m_userName = name;
Chris@75 187 }
Chris@75 188
Chris@84 189 void HgRunner::noteRealm(QString realm)
Chris@75 190 {
Chris@84 191 m_realm = realm;
Chris@84 192 }
Chris@84 193
Chris@84 194 void HgRunner::getUsername()
Chris@84 195 {
Chris@113 196 if (m_ptyFile) {
Chris@84 197 bool ok = false;
Chris@84 198 QString prompt = tr("User name:");
Chris@84 199 if (m_realm != "") {
Chris@84 200 prompt = tr("User name for \"%1\":").arg(m_realm);
Chris@84 201 }
Chris@84 202 QString pwd = QInputDialog::getText
Chris@84 203 (qobject_cast<QWidget *>(parent()),
Chris@84 204 tr("Enter user name"), prompt,
Chris@84 205 QLineEdit::Normal, QString(), &ok);
Chris@84 206 if (ok) {
Chris@113 207 m_ptyFile->write(QString("%1\n").arg(pwd).toUtf8());
Chris@113 208 m_ptyFile->flush();
Chris@84 209 return;
Chris@111 210 } else {
Chris@111 211 DEBUG << "HgRunner::getUsername: user cancelled" << endl;
Chris@111 212 killCurrentCommand();
Chris@111 213 return;
Chris@84 214 }
Chris@84 215 }
Chris@84 216 // user cancelled or something went wrong
Chris@111 217 DEBUG << "HgRunner::getUsername: something went wrong" << endl;
Chris@84 218 killCurrentCommand();
Chris@84 219 }
Chris@84 220
Chris@84 221 void HgRunner::getPassword()
Chris@84 222 {
Chris@113 223 if (m_ptyFile) {
Chris@84 224 bool ok = false;
Chris@84 225 QString prompt = tr("Password:");
Chris@84 226 if (m_userName != "") {
Chris@84 227 if (m_realm != "") {
Chris@84 228 prompt = tr("Password for \"%1\" at \"%2\":")
Chris@84 229 .arg(m_userName).arg(m_realm);
Chris@75 230 } else {
Chris@84 231 prompt = tr("Password for user \"%1\":")
Chris@84 232 .arg(m_userName);
Chris@75 233 }
Chris@75 234 }
Chris@84 235 QString pwd = QInputDialog::getText
Chris@84 236 (qobject_cast<QWidget *>(parent()),
Chris@84 237 tr("Enter password"), prompt,
Chris@84 238 QLineEdit::Password, QString(), &ok);
Chris@84 239 if (ok) {
Chris@113 240 m_ptyFile->write(QString("%1\n").arg(pwd).toUtf8());
Chris@113 241 m_ptyFile->flush();
Chris@84 242 return;
Chris@111 243 } else {
Chris@111 244 DEBUG << "HgRunner::getPassword: user cancelled" << endl;
Chris@111 245 killCurrentCommand();
Chris@111 246 return;
Chris@84 247 }
Chris@75 248 }
Chris@84 249 // user cancelled or something went wrong
Chris@111 250 DEBUG << "HgRunner::getPassword: something went wrong" << endl;
Chris@84 251 killCurrentCommand();
Chris@84 252 }
Chris@84 253
Chris@113 254 bool HgRunner::checkPrompts(QString chunk)
Chris@84 255 {
Chris@93 256 //DEBUG << "checkPrompts: " << chunk << endl;
Chris@84 257
Chris@128 258 if (!m_currentAction.mayBeInteractive()) return false;
Chris@128 259
Chris@84 260 QString text = chunk.trimmed();
Chris@84 261 QString lower = text.toLower();
Chris@84 262 if (lower.endsWith("password:")) {
Chris@84 263 getPassword();
Chris@113 264 return true;
Chris@84 265 }
Chris@128 266 if (lower.endsWith("user:") || lower.endsWith("username:")) {
Chris@84 267 getUsername();
Chris@113 268 return true;
Chris@84 269 }
Chris@128 270 QRegExp userRe("\\buser(name)?:\\s*([^\\s]+)");
Chris@84 271 if (userRe.indexIn(text) >= 0) {
Chris@128 272 noteUsername(userRe.cap(2));
Chris@84 273 }
Chris@84 274 QRegExp realmRe("\\brealmr:\\s*([^\\s]+)");
Chris@84 275 if (realmRe.indexIn(text) >= 0) {
Chris@84 276 noteRealm(realmRe.cap(1));
Chris@84 277 }
Chris@113 278 return false;
Chris@84 279 }
Chris@84 280
Chris@110 281 void HgRunner::dataReadyStdout()
Chris@84 282 {
Chris@110 283 DEBUG << "dataReadyStdout" << endl;
Chris@110 284 QString chunk = QString::fromUtf8(m_proc->readAllStandardOutput());
Chris@113 285 if (!checkPrompts(chunk)) {
Chris@113 286 m_stdout += chunk;
Chris@113 287 }
Chris@110 288 }
Chris@110 289
Chris@110 290 void HgRunner::dataReadyStderr()
Chris@110 291 {
Chris@110 292 DEBUG << "dataReadyStderr" << endl;
Chris@110 293 QString chunk = QString::fromUtf8(m_proc->readAllStandardError());
Chris@113 294 DEBUG << chunk;
Chris@113 295 if (!checkPrompts(chunk)) {
Chris@113 296 m_stderr += chunk;
Chris@113 297 }
Chris@113 298 }
Chris@113 299
Chris@113 300 void HgRunner::dataReadyPty()
Chris@113 301 {
Chris@113 302 DEBUG << "dataReadyPty" << endl;
Chris@113 303 QString chunk = QString::fromUtf8(m_ptyFile->readAll());
Chris@113 304 DEBUG << "chunk of " << chunk.length() << " chars" << endl;
Chris@113 305 if (!checkPrompts(chunk)) {
Chris@113 306 m_stdout += chunk;
Chris@113 307 }
Chris@75 308 }
Chris@75 309
Chris@189 310 void HgRunner::error(QProcess::ProcessError)
Chris@189 311 {
Chris@189 312 finished(-1, QProcess::CrashExit);
Chris@189 313 }
Chris@189 314
jtkorhonen@0 315 void HgRunner::finished(int procExitCode, QProcess::ExitStatus procExitStatus)
jtkorhonen@0 316 {
Chris@109 317 // Save the current action and reset m_currentAction before we
Chris@109 318 // emit a signal to mark the completion; otherwise we may be
Chris@109 319 // resetting the action after a slot has already tried to set it
Chris@109 320 // to something else to start a new action
Chris@109 321
Chris@109 322 HgAction completedAction = m_currentAction;
Chris@109 323
Chris@84 324 m_isRunning = false;
Chris@109 325 m_currentAction = HgAction();
Chris@84 326
Chris@195 327 //closeProcInput();
Chris@189 328 m_proc->deleteLater();
Chris@113 329 m_proc = 0;
jtkorhonen@0 330
Chris@109 331 if (completedAction.action == ACT_NONE) {
Chris@109 332 DEBUG << "HgRunner::finished: WARNING: completed action is ACT_NONE" << endl;
Chris@62 333 } else {
Chris@113 334 if (procExitCode == 0 && procExitStatus == QProcess::NormalExit) {
Chris@113 335 DEBUG << "HgRunner::finished: Command completed successfully"
Chris@113 336 << endl;
Chris@124 337 // DEBUG << "stdout is " << m_stdout << endl;
Chris@113 338 emit commandCompleted(completedAction, m_stdout);
Chris@113 339 } else {
Chris@113 340 DEBUG << "HgRunner::finished: Command failed, exit code "
Chris@113 341 << procExitCode << ", exit status " << procExitStatus
Chris@113 342 << ", stderr follows" << endl;
Chris@113 343 DEBUG << m_stderr << endl;
Chris@113 344 emit commandFailed(completedAction, m_stderr);
Chris@113 345 }
jtkorhonen@0 346 }
Chris@109 347
Chris@109 348 checkQueue();
jtkorhonen@0 349 }
jtkorhonen@0 350
Chris@182 351 void HgRunner::killCurrentActions()
Chris@182 352 {
Chris@182 353 m_queue.clear();
Chris@182 354 killCurrentCommand();
Chris@182 355 }
Chris@182 356
Chris@62 357 void HgRunner::killCurrentCommand()
jtkorhonen@0 358 {
Chris@109 359 if (m_isRunning) {
Chris@113 360 m_currentAction.action = ACT_NONE; // so that we don't bother to notify
Chris@113 361 m_proc->kill();
jtkorhonen@0 362 }
jtkorhonen@0 363 }
jtkorhonen@0 364
Chris@109 365 void HgRunner::checkQueue()
Chris@62 366 {
Chris@109 367 if (m_isRunning) {
Chris@109 368 return;
Chris@109 369 }
Chris@109 370 if (m_queue.empty()) {
Chris@109 371 hide();
Chris@109 372 return;
Chris@109 373 }
Chris@109 374 HgAction toRun = m_queue.front();
Chris@109 375 m_queue.pop_front();
Chris@109 376 DEBUG << "checkQueue: have action: running " << toRun.action << endl;
Chris@109 377 startCommand(toRun);
Chris@109 378 }
Chris@109 379
Chris@109 380 void HgRunner::startCommand(HgAction action)
Chris@109 381 {
Chris@109 382 QString executable = action.executable;
Chris@109 383 bool interactive = false;
Chris@109 384 QStringList params = action.params;
Chris@109 385
Chris@109 386 if (executable == "") {
Chris@109 387 // This is a Hg command
Chris@239 388 executable = getHgBinaryName();
Chris@161 389
Chris@161 390 if (action.mayBeInteractive()) {
Chris@161 391 params.push_front("ui.interactive=true");
Chris@161 392 params.push_front("--config");
Chris@176 393
Chris@176 394 QSettings settings;
Chris@176 395 settings.beginGroup("General");
Chris@176 396 if (settings.value("useextension", true).toBool()) {
Chris@239 397 QString extpath = getExtensionLocation();
Chris@180 398 params.push_front(QString("extensions.easyhg=%1").arg(extpath));
Chris@176 399 params.push_front("--config");
Chris@176 400 }
Chris@161 401 interactive = true;
Chris@161 402 }
Chris@161 403
Chris@161 404 //!!! want an option to use the mercurial_keyring extension as well
Chris@107 405 }
jtkorhonen@0 406
Chris@84 407 m_isRunning = true;
jtkorhonen@0 408 setRange(0, 0);
Chris@115 409 if (!action.shouldBeFast()) show();
Chris@110 410 m_stdout.clear();
Chris@110 411 m_stderr.clear();
Chris@84 412 m_realm = "";
Chris@84 413 m_userName = "";
jtkorhonen@0 414
Chris@113 415 m_proc = new QProcess;
Chris@113 416
Chris@177 417 QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
Chris@177 418
Chris@177 419 #ifdef Q_OS_WIN32
Chris@177 420 if (m_myDirPath != "") {
Chris@177 421 env.insert("PATH", m_myDirPath + ";" + env.value("PATH"));
Chris@172 422 }
Chris@172 423 #endif
Chris@172 424
Chris@113 425 env.insert("LANG", "en_US.utf8");
Chris@113 426 env.insert("LC_ALL", "en_US.utf8");
Chris@113 427 env.insert("HGPLAIN", "1");
Chris@113 428 m_proc->setProcessEnvironment(env);
Chris@113 429
Chris@113 430 connect(m_proc, SIGNAL(started()), this, SLOT(started()));
Chris@189 431 connect(m_proc, SIGNAL(error(QProcess::ProcessError)),
Chris@189 432 this, SLOT(error(QProcess::ProcessError)));
Chris@113 433 connect(m_proc, SIGNAL(finished(int, QProcess::ExitStatus)),
Chris@113 434 this, SLOT(finished(int, QProcess::ExitStatus)));
Chris@113 435 connect(m_proc, SIGNAL(readyReadStandardOutput()),
Chris@113 436 this, SLOT(dataReadyStdout()));
Chris@113 437 connect(m_proc, SIGNAL(readyReadStandardError()),
Chris@113 438 this, SLOT(dataReadyStderr()));
Chris@113 439
Chris@109 440 if (!action.workingDir.isEmpty()) {
Chris@109 441 m_proc->setWorkingDirectory(action.workingDir);
jtkorhonen@0 442 }
jtkorhonen@0 443
Chris@107 444 if (interactive) {
Chris@111 445 openTerminal();
Chris@111 446 if (m_ptySlaveFilename != "") {
Chris@113 447 DEBUG << "HgRunner: connecting to pseudoterminal" << endl;
Chris@107 448 m_proc->setStandardInputFile(m_ptySlaveFilename);
Chris@114 449 // m_proc->setStandardOutputFile(m_ptySlaveFilename);
Chris@113 450 // m_proc->setStandardErrorFile(m_ptySlaveFilename);
Chris@107 451 }
Chris@84 452 }
Chris@84 453
Chris@109 454 QString cmdline = executable;
Chris@57 455 foreach (QString param, params) cmdline += " " + param;
Chris@64 456 DEBUG << "HgRunner: starting: " << cmdline << " with cwd "
Chris@109 457 << action.workingDir << endl;
Chris@43 458
Chris@109 459 m_currentAction = action;
Chris@109 460
Chris@113 461 // fill these out with what we actually ran
Chris@113 462 m_currentAction.executable = executable;
Chris@113 463 m_currentAction.params = params;
Chris@113 464
Chris@109 465 DEBUG << "set current action to " << m_currentAction.action << endl;
Chris@109 466
Chris@238 467 emit commandStarting(action);
Chris@238 468
Chris@109 469 m_proc->start(executable, params);
Chris@84 470 }
Chris@84 471
Chris@84 472 void HgRunner::closeProcInput()
Chris@84 473 {
Chris@84 474 DEBUG << "closeProcInput" << endl;
Chris@84 475
Chris@84 476 m_proc->closeWriteChannel();
Chris@111 477 }
Chris@111 478
Chris@111 479 void HgRunner::openTerminal()
Chris@111 480 {
Chris@111 481 #ifndef Q_OS_WIN32
Chris@111 482 if (m_ptySlaveFilename != "") return; // already open
Chris@111 483 DEBUG << "HgRunner::openTerminal: trying to open new pty" << endl;
Chris@111 484 int master = posix_openpt(O_RDWR | O_NOCTTY);
Chris@111 485 if (master < 0) {
Chris@111 486 DEBUG << "openpt failed" << endl;
Chris@111 487 perror("openpt failed");
Chris@111 488 return;
Chris@111 489 }
Chris@113 490 struct termios t;
Chris@113 491 if (tcgetattr(master, &t)) {
Chris@113 492 DEBUG << "tcgetattr failed" << endl;
Chris@113 493 perror("tcgetattr failed");
Chris@113 494 }
Chris@113 495 cfmakeraw(&t);
Chris@113 496 if (tcsetattr(master, TCSANOW, &t)) {
Chris@113 497 DEBUG << "tcsetattr failed" << endl;
Chris@113 498 perror("tcsetattr failed");
Chris@113 499 }
Chris@111 500 if (grantpt(master)) {
Chris@111 501 perror("grantpt failed");
Chris@111 502 }
Chris@111 503 if (unlockpt(master)) {
Chris@111 504 perror("unlockpt failed");
Chris@111 505 }
Chris@111 506 char *slave = ptsname(master);
Chris@111 507 if (!slave) {
Chris@111 508 perror("ptsname failed");
Chris@111 509 ::close(master);
Chris@111 510 return;
Chris@111 511 }
Chris@111 512 m_ptyMasterFd = master;
Chris@113 513 m_ptyFile = new QFile();
Chris@113 514 connect(m_ptyFile, SIGNAL(readyRead()), this, SLOT(dataReadyPty()));
Chris@113 515 if (!m_ptyFile->open(m_ptyMasterFd, QFile::ReadWrite)) {
Chris@113 516 DEBUG << "HgRunner::openTerminal: Failed to open QFile on master fd" << endl;
Chris@113 517 }
Chris@111 518 m_ptySlaveFilename = slave;
Chris@111 519 DEBUG << "HgRunner::openTerminal: succeeded, slave is "
Chris@111 520 << m_ptySlaveFilename << endl;
Chris@111 521 #endif
Chris@111 522 }
Chris@111 523
Chris@111 524 void HgRunner::closeTerminal()
Chris@111 525 {
Chris@84 526 #ifndef Q_OS_WIN32
Chris@84 527 if (m_ptySlaveFilename != "") {
Chris@113 528 delete m_ptyFile;
Chris@113 529 m_ptyFile = 0;
Chris@84 530 ::close(m_ptyMasterFd);
Chris@84 531 m_ptySlaveFilename = "";
Chris@84 532 }
Chris@84 533 #endif
jtkorhonen@0 534 }