Skip to content

Commit 3229a7a

Browse files
authored
Merge pull request #96 from labstreaminglayer/cboulay/whitespace
Whitespace Fixes
2 parents 41434dc + 1147962 commit 3229a7a

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

src/mainwindow.cpp

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -431,19 +431,26 @@ void MainWindow::startRecording() {
431431
". Please check your permissions.");
432432
return;
433433
}
434-
435434

436435
std::vector<std::string> watchfor;
437436
for (const QString &missing : qAsConst(missingStreams)) {
437+
std::string query;
438438
// Convert missing to query expected by lsl::resolve_stream
439439
// name='BioSemi' and hostname=AASDFSDF
440-
// QRegularExpression rx("(\S+)\s+\((\S+)\)");
441-
QStringList name_host = missing.split(QRegExp("\\s+"));
442-
std::string query = "name='" + name_host[0].toStdString() + "'";
443-
if (name_host.size() > 1) {
444-
std::string host = name_host[1].toStdString();
445-
query += " and hostname='" + host.substr(1, host.length() - 2) + "'";
446-
}
440+
QRegularExpression re("(.+)\\s+\\((\\S+)\\)");
441+
QRegularExpressionMatch match = re.match(missing);
442+
if (match.hasMatch())
443+
{
444+
QString name = match.captured(1);
445+
QString host = match.captured(2);
446+
query = "name='" + match.captured(1).toStdString() + "'";
447+
if (host.size() > 1) {
448+
query += " and hostname='" + host.toStdString() + "'";
449+
}
450+
} else {
451+
// Regexp failed but we can try using the entire string as the stream name.
452+
query = "name='" + missing.toStdString() + "'";
453+
}
447454
watchfor.push_back(query);
448455
}
449456
qInfo() << "Missing: " << missingStreams;
@@ -557,7 +564,7 @@ QString MainWindow::replaceFilename(QString fullfile) const {
557564
QString run = QString("%1").arg(ui->spin_counter->value(), 3, 10, QChar('0'));
558565
fullfile.replace(counterPlaceholder(), run);
559566

560-
return fullfile;
567+
return fullfile.trimmed();
561568
}
562569

563570
/**

0 commit comments

Comments
 (0)