Changeset View
Changeset View
Standalone View
Standalone View
kdevplatform/vcs/dvcs/dvcsjob.cpp
Show First 20 Lines • Show All 94 Lines • ▼ Show 20 Line(s) | |||||
95 | DVcsJob& DVcsJob::operator<<(const QString& arg) | 95 | DVcsJob& DVcsJob::operator<<(const QString& arg) | ||
96 | { | 96 | { | ||
97 | *d->childproc << arg; | 97 | *d->childproc << arg; | ||
98 | return *this; | 98 | return *this; | ||
99 | } | 99 | } | ||
100 | 100 | | |||
101 | DVcsJob& DVcsJob::operator<<(const char* arg) | 101 | DVcsJob& DVcsJob::operator<<(const char* arg) | ||
102 | { | 102 | { | ||
103 | *d->childproc << arg; | 103 | *d->childproc << QString::fromUtf8(arg); | ||
104 | return *this; | 104 | return *this; | ||
105 | } | 105 | } | ||
106 | 106 | | |||
107 | DVcsJob& DVcsJob::operator<<(const QStringList& args) | 107 | DVcsJob& DVcsJob::operator<<(const QStringList& args) | ||
108 | { | 108 | { | ||
109 | *d->childproc << args; | 109 | *d->childproc << args; | ||
110 | return *this; | 110 | return *this; | ||
111 | } | 111 | } | ||
112 | 112 | | |||
113 | QStringList DVcsJob::dvcsCommand() const | 113 | QStringList DVcsJob::dvcsCommand() const | ||
114 | { | 114 | { | ||
115 | return d->childproc->program(); | 115 | return d->childproc->program(); | ||
116 | } | 116 | } | ||
117 | 117 | | |||
118 | QString DVcsJob::output() const | 118 | QString DVcsJob::output() const | ||
119 | { | 119 | { | ||
120 | QByteArray stdoutbuf = rawOutput(); | 120 | QByteArray stdoutbuf = rawOutput(); | ||
121 | int endpos = stdoutbuf.size(); | 121 | int endpos = stdoutbuf.size(); | ||
122 | if (d->status==JobRunning) { // We may have received only part of a code-point. apol: ASSERT? | 122 | if (d->status==JobRunning) { // We may have received only part of a code-point. apol: ASSERT? | ||
123 | endpos = stdoutbuf.lastIndexOf('\n')+1; // Include the final newline or become 0, when there is no newline | 123 | endpos = stdoutbuf.lastIndexOf('\n')+1; // Include the final newline or become 0, when there is no newline | ||
124 | } | 124 | } | ||
125 | 125 | | |||
126 | return QString::fromLocal8Bit(stdoutbuf, endpos); | 126 | return QString::fromLocal8Bit(stdoutbuf.constData(), endpos); | ||
127 | } | 127 | } | ||
128 | 128 | | |||
129 | QByteArray DVcsJob::rawOutput() const | 129 | QByteArray DVcsJob::rawOutput() const | ||
130 | { | 130 | { | ||
131 | return d->output; | 131 | return d->output; | ||
132 | } | 132 | } | ||
133 | 133 | | |||
134 | QByteArray DVcsJob::errorOutput() const | 134 | QByteArray DVcsJob::errorOutput() const | ||
▲ Show 20 Lines • Show All 41 Lines • ▼ Show 20 Line(s) | 155 | { | |||
176 | } | 176 | } | ||
177 | 177 | | |||
178 | QString commandDisplay = KShell::joinArgs(dvcsCommand()); | 178 | QString commandDisplay = KShell::joinArgs(dvcsCommand()); | ||
179 | qCDebug(VCS) << "Execute dvcs command:" << commandDisplay; | 179 | qCDebug(VCS) << "Execute dvcs command:" << commandDisplay; | ||
180 | 180 | | |||
181 | QString service; | 181 | QString service; | ||
182 | if(d->vcsplugin) | 182 | if(d->vcsplugin) | ||
183 | service = d->vcsplugin->objectName(); | 183 | service = d->vcsplugin->objectName(); | ||
184 | setObjectName(service+": "+commandDisplay); | 184 | setObjectName(service + QLatin1String(": ") + commandDisplay); | ||
185 | 185 | | |||
186 | d->status = JobRunning; | 186 | d->status = JobRunning; | ||
187 | d->childproc->setOutputChannelMode(KProcess::SeparateChannels); | 187 | d->childproc->setOutputChannelMode(KProcess::SeparateChannels); | ||
188 | //the started() and error() signals may be delayed! It causes crash with deferred deletion!!! | 188 | //the started() and error() signals may be delayed! It causes crash with deferred deletion!!! | ||
189 | d->childproc->start(); | 189 | d->childproc->start(); | ||
190 | 190 | | |||
191 | d->model->appendLine(directory().path() + "> " + commandDisplay); | 191 | d->model->appendLine(directory().path() + QLatin1String("> ") + commandDisplay); | ||
192 | } | 192 | } | ||
193 | 193 | | |||
194 | void DVcsJob::setCommunicationMode(KProcess::OutputChannelMode comm) | 194 | void DVcsJob::setCommunicationMode(KProcess::OutputChannelMode comm) | ||
195 | { | 195 | { | ||
196 | d->childproc->setOutputChannelMode(comm); | 196 | d->childproc->setOutputChannelMode(comm); | ||
197 | } | 197 | } | ||
198 | 198 | | |||
199 | void DVcsJob::cancel() | 199 | void DVcsJob::cancel() | ||
▲ Show 20 Lines • Show All 62 Lines • ▼ Show 20 Line(s) | 261 | else if (exitCode != 0 && !d->ignoreError) | |||
262 | slotProcessError(QProcess::UnknownError); | 262 | slotProcessError(QProcess::UnknownError); | ||
263 | 263 | | |||
264 | else | 264 | else | ||
265 | jobIsReady(); | 265 | jobIsReady(); | ||
266 | } | 266 | } | ||
267 | 267 | | |||
268 | void DVcsJob::displayOutput(const QString& data) | 268 | void DVcsJob::displayOutput(const QString& data) | ||
269 | { | 269 | { | ||
270 | d->model->appendLines(data.split('\n')); | 270 | d->model->appendLines(data.split(QLatin1Char('\n'))); | ||
271 | } | 271 | } | ||
272 | 272 | | |||
273 | void DVcsJob::slotReceivedStdout() | 273 | void DVcsJob::slotReceivedStdout() | ||
274 | { | 274 | { | ||
275 | QByteArray output = d->childproc->readAllStandardOutput(); | 275 | QByteArray output = d->childproc->readAllStandardOutput(); | ||
276 | 276 | | |||
277 | // accumulate output | 277 | // accumulate output | ||
278 | d->output.append(output); | 278 | d->output.append(output); | ||
▲ Show 20 Lines • Show All 51 Lines • Show Last 20 Lines |