2 * This file is part of the vng project
3 * Copyright (C) 2008 Thomas Zander <tzander@trolltech.com>
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
25 // fix shortcoming in Qts version for right now, thiago is said to work on a fix
26 // This fixes 2 issues that probably are the same bug;
27 // * readline can return -1 while there is still data to be read on the device.
28 // * readline can return a partial line when the internal (QIOBuffer) seems to have run out.
29 qint64
Vng::readLine(QIODevice
*device
, char *buffer
, int maxLength
)
32 while (maxLength
- offset
> 2) {
33 qint64 lineLength
= device
->readLine(buffer
+ offset
, maxLength
- offset
);
35 QProcess
*process
= qobject_cast
<QProcess
*>(device
);
36 if (process
== 0 || process
->state() != QProcess::Running
)
37 return offset
== 0 ? -1 : offset
;
38 process
->waitForReadyRead();
42 if (buffer
[offset
-1] == '\n')