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] - Blame information for rev 4

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 4 sergeykhbr
/*
2
 *  Copyright 2018 Sergey Khabarov, sergeykhbr@gmail.com
3
 *
4
 *  Licensed under the Apache License, Version 2.0 (the "License");
5
 *  you may not use this file except in compliance with the License.
6
 *  You may obtain a copy of the License at
7
 *
8
 *      http://www.apache.org/licenses/LICENSE-2.0
9
 *
10
 *  Unless required by applicable law or agreed to in writing, software
11
 *  distributed under the License is distributed on an "AS IS" BASIS,
12
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
 *  See the License for the specific language governing permissions and
14
 *  limitations under the License.
15 3 sergeykhbr
 */
16
 
17
#include "api_core.h"
18
#include "qt_wrapper.h"
19
#include "moc_qt_wrapper.h"
20
#include <string>
21
#include <QtWidgets/QApplication>
22
 
23
#define QT_EXEC_IMPL
24
 
25
namespace debugger {
26
 
27 4 sergeykhbr
static event_def eventAppDestroyed_;
28 3 sergeykhbr
 
29
/** It's a blocking event that runs only once */
30
void ui_events_update(void *args) {
31
    QtWrapper *ui = reinterpret_cast<QtWrapper *>(args);
32
    ui->eventsUpdate();
33
    RISCV_event_set(&eventAppDestroyed_);
34 4 sergeykhbr
    //RISCV_event_close(&eventAppDestroyed_);
35 3 sergeykhbr
}
36
 
37 4 sergeykhbr
QtWrapper::QtWrapper(IGui *igui)
38
    : QObject() {
39
    igui_ = igui;
40
    exiting_ = false;
41
    RISCV_event_create(&eventAppDestroyed_, "eventAppDestroyed_");
42 3 sergeykhbr
}
43
 
44
QtWrapper::~QtWrapper() {
45
}
46
 
47
void QtWrapper::postInit(AttributeType *gui_cfg) {
48 4 sergeykhbr
    RISCV_register_timer(1, 1, ui_events_update, this);
49 3 sergeykhbr
}
50
 
51
void QtWrapper::eventsUpdate() {
52
    int argc = 0;
53
    char *argv[] = {0};
54 4 sergeykhbr
 
55
    QApplication app(argc, argv);
56
    app.setQuitOnLastWindowClosed(true);
57
 
58 3 sergeykhbr
    mainWindow_ = new DbgMainWindow(igui_);
59 4 sergeykhbr
    connect(mainWindow_, SIGNAL(signalAboutToClose()),
60
            this, SLOT(slotMainWindowAboutToClose()));
61
 
62
    mainWindow_->show();
63
    RISCV_unregister_timer(ui_events_update);
64
    app.exec();
65
 
66
    delete mainWindow_;
67
    app.quit();
68 3 sergeykhbr
}
69
 
70
void QtWrapper::gracefulClose() {
71
    if (!exiting_) {
72
        /** Exit through console command 'exit' */
73
        mainWindow_->close();
74 4 sergeykhbr
        RISCV_event_wait_ms(&eventAppDestroyed_, 10000);
75 3 sergeykhbr
    }
76
}
77
 
78
void QtWrapper::slotMainWindowAboutToClose() {
79
    if (exiting_) {
80
        return;
81
    }
82
    /** Exit from GUI button push */
83
    exiting_ = true;
84
    RISCV_break_simulation();
85
}
86
 
87
}  // namespace debugger

powered by: WebSVN 2.1.0

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