Remove duplicate source files returned by gdb.

This commit is contained in:
Ernie Pasveer
2022-04-09 18:24:43 -05:00
parent b67beff242
commit 0bb793393b
+12 -4
View File
@@ -6,6 +6,7 @@
#include <QtWidgets/QApplication>
#include <QtCore/QFileInfo>
#include <QtCore/Qt>
#include <QtCore/QMap>
#include <QtCore/QDebug>
SeerSourceBrowserWidget::SeerSourceBrowserWidget (QWidget* parent) : QWidget(parent) {
@@ -63,12 +64,12 @@ void SeerSourceBrowserWidget::handleText (const QString& text) {
// {file=\"helloworld.cpp\",fullname=\"/home/erniep/Development/Peak/src/Seer/helloworld/helloworld.cpp\"}
// ]
QString files_text = Seer::parseFirst(text, "files=", '[', ']', false);
//qDebug() << files_text;
QString files_text = Seer::parseFirst(text, "files=", '[', ']', false);
QStringList files_list = Seer::parse(files_text, "", '{', '}', false);
// Set up a map to look for duplicate entries. QMap<fullname,file>
QMap<QString,QString> files;
for ( const auto& entry_text : files_list ) {
QString file_text = Seer::parseFirst(entry_text, "file=", '"', '"', false);
@@ -76,6 +77,13 @@ void SeerSourceBrowserWidget::handleText (const QString& text) {
//qDebug() << file_text << fullname_text;
// Skip duplicates
if (files.contains(fullname_text)) {
continue;
}
files.insert(fullname_text, file_text);
// Get information about the file.
QFileInfo fileInfo(fullname_text);