OpenCores
URL https://opencores.org/ocsvn/riscv_vhdl/riscv_vhdl/trunk

Subversion Repositories riscv_vhdl

[/] [riscv_vhdl/] [trunk/] [debugger/] [src/] [gui_plugin/] [qt_wrapper.cpp] - Diff between revs 3 and 4

Only display areas with differences | Details | Blame | View Log

Rev 3 Rev 4
/**
/*
 * @file
 *  Copyright 2018 Sergey Khabarov, sergeykhbr@gmail.com
 * @copyright  Copyright 2017 GNSS Sensor Ltd. All right reserved.
 *
 * @author     Sergey Khabarov - sergeykhbr@gmail.com
 *  Licensed under the Apache License, Version 2.0 (the "License");
 * @brief      QT Wrapper connects QT libs to debugger core library.
 *  you may not use this file except in compliance with the License.
 
 *  You may obtain a copy of the License at
 
 *
 
 *      http://www.apache.org/licenses/LICENSE-2.0
 
 *
 
 *  Unless required by applicable law or agreed to in writing, software
 
 *  distributed under the License is distributed on an "AS IS" BASIS,
 
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 
 *  See the License for the specific language governing permissions and
 
 *  limitations under the License.
 */
 */
 
 
#include "api_core.h"
#include "api_core.h"
#include "qt_wrapper.h"
#include "qt_wrapper.h"
#include "moc_qt_wrapper.h"
#include "moc_qt_wrapper.h"
#include <string>
#include <string>
#include <QtWidgets/QApplication>
#include <QtWidgets/QApplication>
 
 
#define QT_EXEC_IMPL
#define QT_EXEC_IMPL
 
 
namespace debugger {
namespace debugger {
 
 
static event_def eventAppDestroyed_;
static event_def eventAppDestroyed_;
 
 
/** It's a blocking event that runs only once */
/** It's a blocking event that runs only once */
void ui_events_update(void *args) {
void ui_events_update(void *args) {
    QtWrapper *ui = reinterpret_cast<QtWrapper *>(args);
    QtWrapper *ui = reinterpret_cast<QtWrapper *>(args);
    ui->eventsUpdate();
    ui->eventsUpdate();
    RISCV_event_set(&eventAppDestroyed_);
    RISCV_event_set(&eventAppDestroyed_);
 
    //RISCV_event_close(&eventAppDestroyed_);
}
}
 
 
QtWrapper::QtWrapper(IGui *igui)
QtWrapper::QtWrapper(IGui *igui)
    : QObject() {
    : QObject() {
    igui_ = igui;
    igui_ = igui;
    exiting_ = false;
    exiting_ = false;
    RISCV_event_create(&eventAppDestroyed_, "eventAppDestroyed_");
    RISCV_event_create(&eventAppDestroyed_, "eventAppDestroyed_");
}
}
 
 
QtWrapper::~QtWrapper() {
QtWrapper::~QtWrapper() {
}
}
 
 
void QtWrapper::postInit(AttributeType *gui_cfg) {
void QtWrapper::postInit(AttributeType *gui_cfg) {
    RISCV_register_timer(1, 1, ui_events_update, this);
    RISCV_register_timer(1, 1, ui_events_update, this);
}
}
 
 
void QtWrapper::eventsUpdate() {
void QtWrapper::eventsUpdate() {
    int argc = 0;
    int argc = 0;
    char *argv[] = {0};
    char *argv[] = {0};
 
 
    QApplication app(argc, argv);
    QApplication app(argc, argv);
    app.setQuitOnLastWindowClosed(true);
    app.setQuitOnLastWindowClosed(true);
 
 
    mainWindow_ = new DbgMainWindow(igui_);
    mainWindow_ = new DbgMainWindow(igui_);
    connect(mainWindow_, SIGNAL(signalAboutToClose()),
    connect(mainWindow_, SIGNAL(signalAboutToClose()),
            this, SLOT(slotMainWindowAboutToClose()));
            this, SLOT(slotMainWindowAboutToClose()));
 
 
    mainWindow_->show();
    mainWindow_->show();
 
    RISCV_unregister_timer(ui_events_update);
    app.exec();
    app.exec();
 
 
    delete mainWindow_;
    delete mainWindow_;
    app.quit();
    app.quit();
}
}
 
 
void QtWrapper::gracefulClose() {
void QtWrapper::gracefulClose() {
    if (!exiting_) {
    if (!exiting_) {
        /** Exit through console command 'exit' */
        /** Exit through console command 'exit' */
        mainWindow_->close();
        mainWindow_->close();
        RISCV_event_wait_ms(&eventAppDestroyed_, 10000);
        RISCV_event_wait_ms(&eventAppDestroyed_, 10000);
    }
    }
    RISCV_event_close(&eventAppDestroyed_);
 
}
}
 
 
void QtWrapper::slotMainWindowAboutToClose() {
void QtWrapper::slotMainWindowAboutToClose() {
    if (exiting_) {
    if (exiting_) {
        return;
        return;
    }
    }
    /** Exit from GUI button push */
    /** Exit from GUI button push */
    exiting_ = true;
    exiting_ = true;
    RISCV_break_simulation();
    RISCV_break_simulation();
}
}
 
 
}  // namespace debugger
}  // namespace debugger
 
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.