Mercurial > hg > octave-nkf
changeset 15641:b8d787001038
Fixed bug with creating multiple ptys.
author | Jacob Dawid <jacob.dawid@googlemail.com> |
---|---|
date | Tue, 24 Jan 2012 22:12:04 +0100 |
parents | d649d67078e9 |
children | 1073b2efaa93 |
files | libqterminal/PseudoTerminal.cpp libqterminal/PseudoTerminal.h libqterminal/QTerminal.cpp libqterminal/SessionModel.cpp libqterminal/SessionModel.h libqterminal/k3process.cpp libqterminal/k3process.h |
diffstat | 7 files changed, 18 insertions(+), 33 deletions(-) [+] |
line wrap: on
line diff
--- a/libqterminal/PseudoTerminal.cpp +++ b/libqterminal/PseudoTerminal.cpp @@ -147,9 +147,7 @@ const QStringList& programArguments, const QStringList& environment, ulong winid, - bool addToUtmp, - int masterFd, - int slaveFd + bool addToUtmp // const QString& dbusService, // const QString& dbusSession) ) @@ -185,7 +183,7 @@ if (!environment.contains("LANGUAGE")) setEnvironment("LANGUAGE",QString()); - setUsePty(All, addToUtmp, masterFd, slaveFd); + setUsePty(All, addToUtmp, _pty); pty()->open(); @@ -244,10 +242,10 @@ this, SLOT(writeReady())); _pty = new KPty; - setUsePty(All, false, -1, -1); // utmp will be overridden later + setUsePty(All, false); // utmp will be overridden later } -PseudoTerminal::PseudoTerminal(int masterFd, int slaveFd) +PseudoTerminal::PseudoTerminal(KPty *kpty) : _bufferFull(false), _windowColumns(0), _windowLines(0), @@ -261,9 +259,9 @@ this, SLOT(donePty())); connect(this, SIGNAL(wroteStdin(K3Process *)), this, SLOT(writeReady())); - _pty = new KPty(masterFd, slaveFd); + _pty = kpty; - setUsePty(All, false, masterFd, slaveFd); // utmp will be overridden later + setUsePty(All, false, _pty); // utmp will be overridden later } PseudoTerminal::~PseudoTerminal()
--- a/libqterminal/PseudoTerminal.h +++ b/libqterminal/PseudoTerminal.h @@ -62,7 +62,7 @@ * name of the program to start and appropriate arguments. */ PseudoTerminal(); - PseudoTerminal(int masterFd, int slaveFd); + PseudoTerminal(KPty *kpty); ~PseudoTerminal(); @@ -90,9 +90,7 @@ const QStringList& arguments, const QStringList& environment, ulong winid, - bool addToUtmp, - int masterFd, - int slaveFd + bool addToUtmp // const QString& dbusService, // const QString& dbusSession );
--- a/libqterminal/QTerminal.cpp +++ b/libqterminal/QTerminal.cpp @@ -35,14 +35,13 @@ { KPty *kpty = new KPty(); kpty->open(); - int fdm = kpty->masterFd(); int fds = kpty->slaveFd(); dup2 (fds, 0); dup2 (fds, 1); dup2 (fds, 2); - m_sessionModel = new SessionModel(fdm, fds); + m_sessionModel = new SessionModel(kpty); m_sessionModel->setTitle(SessionModel::NameRole, "QTermWidget"); m_sessionModel->setProgram("/bin/bash");
--- a/libqterminal/SessionModel.cpp +++ b/libqterminal/SessionModel.cpp @@ -45,7 +45,7 @@ int SessionModel::lastSessionId = 0; -SessionModel::SessionModel(int masterFd, int slaveFd) : +SessionModel::SessionModel(KPty *kpty) : _shellProcess(0) , _emulation(0) , _monitorActivity(false) @@ -67,8 +67,6 @@ // , _zmodemProgress(0) , _hasDarkBackground(false) { - _masterFd = masterFd; - _slaveFd = slaveFd; //prepare DBus communication // new SessionAdaptor(this); @@ -76,11 +74,7 @@ // QDBusConnection::sessionBus().registerObject(QLatin1String("/Sessions/")+QString::number(_sessionId), this); //create teletype for I/O with shell process - if(_masterFd >= 0) { - _shellProcess = new PseudoTerminal(_masterFd, _slaveFd); - } else { - _shellProcess = new PseudoTerminal(); - } + _shellProcess = new PseudoTerminal(kpty); //create emulation backend _emulation = new Vt102Emulation(); @@ -307,9 +301,7 @@ arguments, _environment << backgroundColorHint, windowId(), - _addToUtmp, - _masterFd, - _slaveFd); + _addToUtmp); if (result < 0) {
--- a/libqterminal/SessionModel.h +++ b/libqterminal/SessionModel.h @@ -32,6 +32,7 @@ // Konsole #include "History.h" +#include "kpty.h" class KProcess; @@ -70,7 +71,7 @@ * falls back to using the program specified in the SHELL environment * variable. */ - SessionModel(int masterFd = -1, int slaveFd = -1); + SessionModel(KPty *kpty); ~SessionModel(); /** @@ -484,7 +485,7 @@ int _uniqueIdentifier; - PseudoTerminal* _shellProcess; + PseudoTerminal* _shellProcess; Emulation* _emulation; QList<SessionView*> _views;
--- a/libqterminal/k3process.cpp +++ b/libqterminal/k3process.cpp @@ -731,16 +731,13 @@ d->shell = "/bin/sh"; } -void K3Process::setUsePty(Communication usePty, bool addUtmp, int masterFd, int slaveFd) +void K3Process::setUsePty(Communication usePty, bool addUtmp, KPty *kpty) { d->usePty = usePty; d->addUtmp = addUtmp; if (usePty) { if (!d->pty) { - if(masterFd >= 0) - d->pty = new KPty(masterFd, slaveFd); - else - d->pty = new KPty; + d->pty = kpty; } } else { delete d->pty;
--- a/libqterminal/k3process.h +++ b/libqterminal/k3process.h @@ -514,7 +514,7 @@ * start (there is only one pty, so they cannot be distinguished). * @param addUtmp true if a utmp entry should be created for the pty */ - void setUsePty(Communication comm, bool addUtmp, int masterFd, int slaveFd); + void setUsePty(Communication comm, bool addUtmp, KPty *kpty = 0); /** * Obtains the pty object used by this process. The return value is