<commit_before>#include "pcapplayback.h"
#include "ui_pcapplayback.h"
#include "pcapplaybacksender.h"
#include "pcap.h"
#include <QFileDialog>
#include <QMessageBox>
#include <QTime>
#include <QThread>
#include <QDebug>

PcapPlayback::PcapPlayback(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::PcapPlayback),
    sender(NULL)
{
    ui->setupUi(this);
}

PcapPlayback::~PcapPlayback()
{
    closeThread();
    delete ui;
}

void PcapPlayback::openThread()
{
    if (sender) {
        closeThread();
    }

    /* Create sender thread */
    sender = new pcapplaybacksender(ui->lblFilename->text());
    connect(sender, SIGNAL(packetSent()), this, SLOT(increaseProgress()));
    connect(sender, SIGNAL(sendingFinished()), this, SLOT(playbackFinished()));
    connect(sender, SIGNAL(sendingClosed()), this, SLOT(playbackClosed()));
    connect(sender, SIGNAL(error(QString)), this, SLOT(error(QString)));
    connect(sender, SIGNAL(finished()), sender, SLOT(deleteLater()));
    connect(sender, SIGNAL(finished()), this, SLOT(playbackThreadClosed()));
    ui->progressBar->reset();
    sender->start();
    sender->setPriority(QThread::HighPriority);
}

void PcapPlayback::closeThread()
{
    if (sender) sender->quit();
}

void PcapPlayback::playbackThreadClosed()
{
    sender = Q_NULLPTR;
    updateUIBtns();
}

void PcapPlayback::on_btnOpen_clicked()
{
    /* Select file to open */
    QString fileName = QFileDialog::getOpenFileName(this,
            tr("Open Capture"),
            QDir::homePath(),
            tr("PCap Files (*.pcap);; PCapNG Files (*.pcapng);; All files (*.*)"));
    if (fileName.isEmpty()) {
        return;
    }
<commit_msg>UI fix when opening a PCAP file while one is already open<commit_after>#include "pcapplayback.h"
#include "ui_pcapplayback.h"
#include "pcapplaybacksender.h"
#include "pcap.h"
#include <QFileDialog>
#include <QMessageBox>
#include <QTime>
#include <QThread>
#include <QDebug>

PcapPlayback::PcapPlayback(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::PcapPlayback),
    sender(NULL)
{
    ui->setupUi(this);
}

PcapPlayback::~PcapPlayback()
{
    closeThread();
    delete ui;
}

void PcapPlayback::openThread()
{
    if (sender) {
        closeThread();
    }

    /* Create sender thread */
    sender = new pcapplaybacksender(ui->lblFilename->text());
    connect(sender, SIGNAL(packetSent()), this, SLOT(increaseProgress()));
    connect(sender, SIGNAL(sendingFinished()), this, SLOT(playbackFinished()));
    connect(sender, SIGNAL(sendingClosed()), this, SLOT(playbackClosed()));
    connect(sender, SIGNAL(error(QString)), this, SLOT(error(QString)));
    connect(sender, SIGNAL(finished()), sender, SLOT(deleteLater()));
    connect(sender, SIGNAL(finished()), this, SLOT(playbackThreadClosed()));
    ui->progressBar->reset();
    sender->start();
    sender->setPriority(QThread::HighPriority);
}

void PcapPlayback::closeThread()
{
    if (!sender)
        return;

    sender->quit();
    sender->deleteLater();
    sender = Q_NULLPTR;
}

void PcapPlayback::playbackThreadClosed()
{
    updateUIBtns();
}

void PcapPlayback::on_btnOpen_clicked()
{
    /* Select file to open */
    QString fileName = QFileDialog::getOpenFileName(this,
            tr("Open Capture"),
            QDir::homePath(),
            tr("PCap Files (*.pcap);; PCapNG Files (*.pcapng);; All files (*.*)"));
    if (fileName.isEmpty()) {
        return;
    }

{'fraction_non_alphanumeric': 0.16427525622254757, 'fraction_numerical': 0.0, 'mean_word_length': 4.287925696594427, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 30, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2317817', 'n_tokens_mistral': 1154, 'n_tokens_neox': 1133, 'n_words': 213}