Skip to content

Commit eac76f3

Browse files
committed
Fixes #95
1 parent 41434dc commit eac76f3

1 file changed

Lines changed: 15 additions & 8 deletions

File tree

src/mainwindow.cpp

Lines changed: 15 additions & 8 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;

0 commit comments

Comments
 (0)