<commit_before>#include "MIPSEM_IDE.hpp"

#include <QCoreApplication>
#include <QProcess>

MIPSEM_IDE::MIPSEM_IDE(QWidget *parent)
    :   QWidget(parent)
{
    init_pointers();
    init();
    
    QShortcut *shortcut = new QShortcut(QKeySequence("F5"), this);
    connect(shortcut, SIGNAL(activated()),
            this, SLOT(assembleOpenFile()));
    /*
    ProgramLine line1;
    line1.fileName = "D:\\tmp\\test1.txt";
    line1.lineNumber = 2;
    line1.text = "line2text";
    AssemblerException e1 = AssemblerException(line1, "ERROR1", "badtoken1");
    
    ProgramLine line2;
    line2.fileName = "D:\\tmp\\test2.txt";
    line2.lineNumber = 11;
    line2.text = "text11";
    AssemblerException e2 = AssemblerException(line2, "ERROR2", "badToken2");
    vector<AssemblerException> vect;
    vect.push_back(e1);
    vect.push_back(e2);
    
    assemblerExceptionView->setAssemblerExceptionList(vect);
    */
    
}
void MIPSEM_IDE::init(){
    middle->addWidget(fileSelector);
    middle->addWidget(tabbedFileEditor);
    
    middle->setStretchFactor(1, 1);
    middle->setStretchFactor(0, 0);
    connect(fileSelector, SIGNAL(fileSelected(QString const &)), 
            tabbedFileEditor, SLOT(editFile(QString const &)));

    bottom->addWidget(middle);   
    bottom->addWidget(assemblerExceptionView);
    bottom->setStretchFactor(1, 0);
    bottom->setStretchFactor(0, 1);
    connect(assemblerExceptionView, SIGNAL(programLineSelected(const ProgramLine)),
            tabbedFileEditor, SLOT(selectFileLine(const ProgramLine)));
    
    layout->addWidget(bottom);
}

void MIPSEM_IDE::init_pointers(){
    layout = new QGridLayout(this);
        toolbar = new QToolBar();
        middle = new QSplitter(Qt::Horizontal);
            tabbedFileEditor = new TabbedFileEditor();
            fileSelector = new FileSelector();
        bottom = new QSplitter(Qt::Vertical);
            assemblerExceptionView = new AssemblerExceptionView();
}

MIPSEM_IDE::~MIPSEM_IDE(){
    deinit();
}
void MIPSEM_IDE::deinit(){
    delete 
    layout;
        middle,
            tabbedFileEditor,
            fileSelector,
        bottom,
            assemblerExceptionView
    ;
}



void MIPSEM_IDE::assembleOpenFile(){
    if(!tabbedFileEditor->saveAllTabs()){
        assemblerExceptionView->clearAssemblerExceptions();
        return;
    }
    FileEditor* editor = (FileEditor*)tabbedFileEditor->currentWidget(); 
    if(editor == NULL){return;}
    QString dir = editor->dir;
    core.reset();
    bool validAssembly = core.assemble(dir.toStdString());
    if(!validAssembly){
        assemblerExceptionView->setAssemblerExceptionList(core.recoverableExceptions);   
    }else{
        assemblerExceptionView->clearAssemblerExceptions();
        assemblerExceptionView->addTextLine("=>\tAssembly of \"" + dir + "\" successful.");
        
        //QProcess *process = new QProcess(this);
        QString MIPSEM_IDE_filePath = QFileInfo(QCoreApplication::applicationFilePath()).filePath();
        QString MIPSEM_IDE_parentDirPath = QString(Parser::filePathToParentDirectory(MIPSEM_IDE_filePath.toStdString()).c_str());
        QString MIPSEM_CORE_filePath = MIPSEM_IDE_parentDirPath + "MIPSEM_CORE.exe";
        QStringList MIPSEM_CORE_arguments;
        MIPSEM_CORE_arguments << QString(core.builtObjectFileName.c_str());
        QProcess *process = new QProcess();
        QString systemCall = MIPSEM_CORE_filePath + " " + MIPSEM_CORE_arguments[0];
        system(systemCall.toStdString().c_str());

    }
}






<commit_msg>Made MIPSEM_CORE.exe call asynchronous to not block GUI updates<commit_after>#include "MIPSEM_IDE.hpp"

#include <QCoreApplication>
#include <QProcess>

MIPSEM_IDE::MIPSEM_IDE(QWidget *parent)
    :   QWidget(parent)
{
    init_pointers();
    init();
    
    QShortcut *shortcut = new QShortcut(QKeySequence("F5"), this);
    connect(shortcut, SIGNAL(activated()),
            this, SLOT(assembleOpenFile()));
    /*
    ProgramLine line1;
    line1.fileName = "D:\\tmp\\test1.txt";
    line1.lineNumber = 2;
    line1.text = "line2text";
    AssemblerException e1 = AssemblerException(line1, "ERROR1", "badtoken1");
    
    ProgramLine line2;
    line2.fileName = "D:\\tmp\\test2.txt";
    line2.lineNumber = 11;
    line2.text = "text11";
    AssemblerException e2 = AssemblerException(line2, "ERROR2", "badToken2");
    vector<AssemblerException> vect;
    vect.push_back(e1);
    vect.push_back(e2);
    
    assemblerExceptionView->setAssemblerExceptionList(vect);
    */
    
}
void MIPSEM_IDE::init(){
    middle->addWidget(fileSelector);
    middle->addWidget(tabbedFileEditor);
    
    middle->setStretchFactor(1, 1);
    middle->setStretchFactor(0, 0);
    connect(fileSelector, SIGNAL(fileSelected(QString const &)), 
            tabbedFileEditor, SLOT(editFile(QString const &)));

    bottom->addWidget(middle);   
    bottom->addWidget(assemblerExceptionView);
    bottom->setStretchFactor(1, 0);
    bottom->setStretchFactor(0, 1);
    connect(assemblerExceptionView, SIGNAL(programLineSelected(const ProgramLine)),
            tabbedFileEditor, SLOT(selectFileLine(const ProgramLine)));
    
    layout->addWidget(bottom);
}

void MIPSEM_IDE::init_pointers(){
    layout = new QGridLayout(this);
        toolbar = new QToolBar();
        middle = new QSplitter(Qt::Horizontal);
            tabbedFileEditor = new TabbedFileEditor();
            fileSelector = new FileSelector();
        bottom = new QSplitter(Qt::Vertical);
            assemblerExceptionView = new AssemblerExceptionView();
}

MIPSEM_IDE::~MIPSEM_IDE(){
    deinit();
}
void MIPSEM_IDE::deinit(){
    delete 
    layout;
        middle,
            tabbedFileEditor,
            fileSelector,
        bottom,
            assemblerExceptionView
    ;
}



void MIPSEM_IDE::assembleOpenFile(){
    if(!tabbedFileEditor->saveAllTabs()){
        assemblerExceptionView->clearAssemblerExceptions();
        return;
    }
    FileEditor* editor = (FileEditor*)tabbedFileEditor->currentWidget(); 
    if(editor == NULL){return;}
    QString dir = editor->dir;
    core.reset();
    bool validAssembly = core.assemble(dir.toStdString());
    if(!validAssembly){
        assemblerExceptionView->setAssemblerExceptionList(core.recoverableExceptions);   
    }else{
        assemblerExceptionView->clearAssemblerExceptions();
        assemblerExceptionView->addTextLine("=>\tAssembly of \"" + dir + "\" successful.");
        assemblerExceptionView->addTextLine("Running object file \"" + QString(core.builtObjectFileName.c_str()) + "\"...");
        //QProcess *process = new QProcess(this);
        QString MIPSEM_IDE_filePath = QFileInfo(QCoreApplication::applicationFilePath()).filePath();
        QString MIPSEM_IDE_parentDirPath = QString(Parser::filePathToParentDirectory(MIPSEM_IDE_filePath.toStdString()).c_str());
        QString MIPSEM_CORE_filePath = MIPSEM_IDE_parentDirPath + "MIPSEM_CORE.exe";
        QStringList MIPSEM_CORE_arguments;
        MIPSEM_CORE_arguments << QString(core.builtObjectFileName.c_str());
        QProcess *process = new QProcess();
        QString systemCall = "start " + MIPSEM_CORE_filePath + " " + MIPSEM_CORE_arguments[0];
        system(systemCall.toStdString().c_str());
    }
}







{'fraction_non_alphanumeric': 0.1251035625517813, 'fraction_numerical': 0.009942004971002486, 'mean_word_length': 3.5410658307210032, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 46, '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': '5498028', 'n_tokens_mistral': 2355, 'n_tokens_neox': 2273, 'n_words': 341}