fix(gui): trailing tabs stripped by trimmed() dropping empty sessions
refreshSessions() and onEventReadyRead() called .trimmed() on the full
session/idx output, which stripped trailing tab characters from the
last line. An empty session line ("testsession2\t\t\t\t\t")
became just "testsession2" — a single field that failed the size>=2
check and was silently dropped from the session list.
This commit is contained in:
parent
c8fb652785
commit
f0a2185e2f
|
|
@ -87,13 +87,15 @@ void Ollie9pClient::setActiveSessionId(const QString &id)
|
||||||
void Ollie9pClient::refreshSessions()
|
void Ollie9pClient::refreshSessions()
|
||||||
{
|
{
|
||||||
QByteArray out = run9p({"read", "session/idx"});
|
QByteArray out = run9p({"read", "session/idx"});
|
||||||
QString raw = QString::fromUtf8(out).trimmed();
|
// Don't trim the whole output — trailing tabs are significant fields
|
||||||
qDebug() << "refreshSessions: output length =" << out.length() << "content:" << raw.left(200);
|
QString raw = QString::fromUtf8(out);
|
||||||
|
|
||||||
m_sessions.clear();
|
m_sessions.clear();
|
||||||
if (!raw.isEmpty()) {
|
if (!raw.isEmpty()) {
|
||||||
for (const QString &line : raw.split('\n')) {
|
for (const QString &line : raw.split('\n', Qt::SkipEmptyParts)) {
|
||||||
QStringList parts = line.split('\t');
|
QString trimmed = line.trimmed();
|
||||||
|
if (trimmed.isEmpty()) continue;
|
||||||
|
QStringList parts = trimmed.split('\t');
|
||||||
if (parts.size() >= 2) {
|
if (parts.size() >= 2) {
|
||||||
QVariantMap session;
|
QVariantMap session;
|
||||||
session["id"] = parts[0];
|
session["id"] = parts[0];
|
||||||
|
|
@ -104,7 +106,6 @@ void Ollie9pClient::refreshSessions()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
qDebug() << "refreshSessions: m_sessions count =" << m_sessions.size();
|
|
||||||
emit sessionsChanged();
|
emit sessionsChanged();
|
||||||
|
|
||||||
// Auto-select first session if none active
|
// Auto-select first session if none active
|
||||||
|
|
@ -540,13 +541,15 @@ void Ollie9pClient::onEventReadyRead()
|
||||||
{
|
{
|
||||||
// eventwait returned the full session index — use it directly
|
// eventwait returned the full session index — use it directly
|
||||||
QByteArray data = m_eventProc->readAllStandardOutput();
|
QByteArray data = m_eventProc->readAllStandardOutput();
|
||||||
QString raw = QString::fromUtf8(data).trimmed();
|
// Don't trim the whole output — trailing tabs are significant fields
|
||||||
qDebug() << "onEventReadyRead: data length =" << data.length() << "content:" << raw.left(200);
|
QString raw = QString::fromUtf8(data);
|
||||||
|
|
||||||
m_sessions.clear();
|
m_sessions.clear();
|
||||||
if (!raw.isEmpty()) {
|
if (!raw.isEmpty()) {
|
||||||
for (const QString &line : raw.split('\n')) {
|
for (const QString &line : raw.split('\n', Qt::SkipEmptyParts)) {
|
||||||
QStringList parts = line.split('\t');
|
QString trimmed = line.trimmed();
|
||||||
|
if (trimmed.isEmpty()) continue;
|
||||||
|
QStringList parts = trimmed.split('\t');
|
||||||
if (parts.size() >= 2) {
|
if (parts.size() >= 2) {
|
||||||
QVariantMap session;
|
QVariantMap session;
|
||||||
session["id"] = parts[0];
|
session["id"] = parts[0];
|
||||||
|
|
@ -557,7 +560,6 @@ void Ollie9pClient::onEventReadyRead()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
qDebug() << "onEventReadyRead: m_sessions count =" << m_sessions.size();
|
|
||||||
emit sessionsChanged();
|
emit sessionsChanged();
|
||||||
|
|
||||||
// Auto-select first session if none active
|
// Auto-select first session if none active
|
||||||
|
|
|
||||||
Reference in New Issue