mirror of
https://github.com/rizinorg/cutter.git
synced 2025-02-12 09:52:05 +00:00
MainWindow fixes and improvments
- no static WebServerThreads anymore. fixes a crash on load/new - manage own QRCore - don't quit the Application but close the window in actionNew - use startDetached in actionLoad, so the new instance won't get killed
This commit is contained in:
parent
1f36c55f6a
commit
fbabb83060
@ -60,10 +60,12 @@ static void appendRow(QTreeWidget *tw, const QString &str, const QString &str2=N
|
|||||||
|
|
||||||
MainWindow::MainWindow(QWidget *parent) :
|
MainWindow::MainWindow(QWidget *parent) :
|
||||||
QMainWindow(parent),
|
QMainWindow(parent),
|
||||||
ui(new Ui::MainWindow)
|
core(new QRCore()),
|
||||||
|
ui(new Ui::MainWindow),
|
||||||
|
webserverThread(core, this)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
this->core = NULL;
|
|
||||||
doLock = false;
|
doLock = false;
|
||||||
|
|
||||||
// Add custom font
|
// Add custom font
|
||||||
@ -237,18 +239,27 @@ MainWindow::MainWindow(QWidget *parent) :
|
|||||||
QShortcut* commands_shortcut = new QShortcut(QKeySequence(Qt::Key_Colon), this);
|
QShortcut* commands_shortcut = new QShortcut(QKeySequence(Qt::Key_Colon), this);
|
||||||
connect(commands_shortcut, SIGNAL(activated()), this->omnibar, SLOT(showCommands()));
|
connect(commands_shortcut, SIGNAL(activated()), this->omnibar, SLOT(showCommands()));
|
||||||
|
|
||||||
|
connect(&webserverThread, SIGNAL(finished()), this, SLOT(webserverThreadFinished()));
|
||||||
|
}
|
||||||
|
|
||||||
|
MainWindow::~MainWindow() {
|
||||||
|
delete ui;
|
||||||
|
delete core;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::start_web_server() {
|
void MainWindow::start_web_server() {
|
||||||
// To be removed
|
|
||||||
static WebServerThread thread;
|
|
||||||
// Start web server
|
// Start web server
|
||||||
thread.core = core;
|
webserverThread.startServer();
|
||||||
thread.start();
|
}
|
||||||
QThread::sleep (1);
|
|
||||||
if (core->core->http_up == R_FALSE) {
|
void MainWindow::webserverThreadFinished()
|
||||||
eprintf ("FAILED TO LAUNCH\n");
|
{
|
||||||
}
|
core->core->http_up = webserverThread.isStarted() ? R_TRUE : R_FALSE;
|
||||||
|
|
||||||
|
// this is not true anymore, cause the webserver might have been stopped
|
||||||
|
//if (core->core->http_up == R_FALSE) {
|
||||||
|
// eprintf("FAILED TO LAUNCH\n");
|
||||||
|
//}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::adjustColumns(QTreeWidget *tw) {
|
void MainWindow::adjustColumns(QTreeWidget *tw) {
|
||||||
@ -275,6 +286,20 @@ void MainWindow::appendRow(QTreeWidget *tw, const QString &str, const QString &s
|
|||||||
tw->insertTopLevelItem(0, tempItem);
|
tw->insertTopLevelItem(0, tempItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::setWebServerState(bool start)
|
||||||
|
{
|
||||||
|
if (start) {
|
||||||
|
webserverThread.startServer();
|
||||||
|
|
||||||
|
// Open web interface on default browser
|
||||||
|
// ballessay: well isn't this possible with =H&
|
||||||
|
//QString link = "http://localhost:9090/";
|
||||||
|
//QDesktopServices::openUrl(QUrl(link));
|
||||||
|
} else {
|
||||||
|
webserverThread.stopServer();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void MainWindow::hideDummyColumns() {
|
void MainWindow::hideDummyColumns() {
|
||||||
// UGLY, should be a loop over all treewidgets...
|
// UGLY, should be a loop over all treewidgets...
|
||||||
this->functionsDock->functionsTreeWidget->setColumnHidden(0, true);
|
this->functionsDock->functionsTreeWidget->setColumnHidden(0, true);
|
||||||
@ -362,10 +387,6 @@ void MainWindow::def_theme() {
|
|||||||
settings.setValue("dark", false);
|
settings.setValue("dark", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
MainWindow::~MainWindow() {
|
|
||||||
delete ui;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Refresh widget functions
|
* Refresh widget functions
|
||||||
*/
|
*/
|
||||||
@ -739,6 +760,7 @@ void MainWindow::on_consoleInputLineEdit_returnPressed()
|
|||||||
QCompleter *completer = ui->consoleInputLineEdit->completer();
|
QCompleter *completer = ui->consoleInputLineEdit->completer();
|
||||||
/*
|
/*
|
||||||
* TODO: FIXME: Crashed the fucking app
|
* TODO: FIXME: Crashed the fucking app
|
||||||
|
* ballessay: yes this will crash if no completer is set -> nullptr
|
||||||
*/
|
*/
|
||||||
//QStringListModel *completerModel = (QStringListModel*)(completer->model());
|
//QStringListModel *completerModel = (QStringListModel*)(completer->model());
|
||||||
//completerModel->setStringList(completerModel->stringList() << input);
|
//completerModel->setStringList(completerModel->stringList() << input);
|
||||||
@ -840,24 +862,7 @@ void MainWindow::on_consoleExecButton_clicked()
|
|||||||
|
|
||||||
void MainWindow::on_actionStart_Web_Server_triggered()
|
void MainWindow::on_actionStart_Web_Server_triggered()
|
||||||
{
|
{
|
||||||
static WebServerThread thread;
|
setWebServerState(ui->actionStart_Web_Server->isChecked());
|
||||||
if (ui->actionStart_Web_Server->isChecked()) {
|
|
||||||
// Start web server
|
|
||||||
thread.core = core;
|
|
||||||
thread.start();
|
|
||||||
QThread::sleep (1);
|
|
||||||
if (core->core->http_up==R_FALSE) {
|
|
||||||
eprintf ("FAILED TO LAUNCH\n");
|
|
||||||
}
|
|
||||||
// Open web interface on default browser
|
|
||||||
//QString link = "http://localhost:9090/";
|
|
||||||
//QDesktopServices::openUrl(QUrl(link));
|
|
||||||
} else {
|
|
||||||
core->core->http_up= R_FALSE;
|
|
||||||
// call something to kill the webserver!!
|
|
||||||
thread.exit(0);
|
|
||||||
// Stop web server
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::on_actionConsoleSync_with_core_triggered()
|
void MainWindow::on_actionConsoleSync_with_core_triggered()
|
||||||
@ -970,7 +975,7 @@ void MainWindow::add_debug_output(QString msg)
|
|||||||
|
|
||||||
void MainWindow::on_actionNew_triggered()
|
void MainWindow::on_actionNew_triggered()
|
||||||
{
|
{
|
||||||
qApp->quit();
|
close();
|
||||||
on_actionLoad_triggered();
|
on_actionLoad_triggered();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1018,10 +1023,9 @@ void MainWindow::on_actionSDB_browser_triggered()
|
|||||||
|
|
||||||
void MainWindow::on_actionLoad_triggered()
|
void MainWindow::on_actionLoad_triggered()
|
||||||
{
|
{
|
||||||
QProcess* process = new QProcess(this);
|
QProcess process(this);
|
||||||
process->setProgram(qApp->applicationFilePath());
|
process.setEnvironment(QProcess::systemEnvironment());
|
||||||
process->setEnvironment(QProcess::systemEnvironment());
|
process.startDetached(qApp->applicationFilePath());
|
||||||
process->start();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::on_actionShow_Hide_mainsidebar_triggered()
|
void MainWindow::on_actionShow_Hide_mainsidebar_triggered()
|
||||||
|
@ -57,13 +57,14 @@ public:
|
|||||||
bool responsive;
|
bool responsive;
|
||||||
|
|
||||||
explicit MainWindow(QWidget *parent = 0);
|
explicit MainWindow(QWidget *parent = 0);
|
||||||
|
~MainWindow();
|
||||||
|
|
||||||
void start_web_server();
|
void start_web_server();
|
||||||
void closeEvent(QCloseEvent *event);
|
void closeEvent(QCloseEvent *event);
|
||||||
void readSettings();
|
void readSettings();
|
||||||
void setFilename(QString fn);
|
void setFilename(QString fn);
|
||||||
void setCore(QRCore *core);
|
void setCore(QRCore *core);
|
||||||
void seek(const QString& offset, const QString& name=NULL);
|
void seek(const QString& offset, const QString& name=NULL);
|
||||||
~MainWindow();
|
|
||||||
void updateFrames();
|
void updateFrames();
|
||||||
void refreshFunctions();
|
void refreshFunctions();
|
||||||
void refreshComments();
|
void refreshComments();
|
||||||
@ -76,6 +77,8 @@ public:
|
|||||||
void appendRow(QTreeWidget *tw, const QString &str, const QString &str2=NULL,
|
void appendRow(QTreeWidget *tw, const QString &str, const QString &str2=NULL,
|
||||||
const QString &str3=NULL, const QString &str4=NULL, const QString &str5=NULL);
|
const QString &str3=NULL, const QString &str4=NULL, const QString &str5=NULL);
|
||||||
|
|
||||||
|
void setWebServerState(bool start);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
|
||||||
void dark();
|
void dark();
|
||||||
@ -186,6 +189,8 @@ private slots:
|
|||||||
|
|
||||||
void on_actionReset_settings_triggered();
|
void on_actionReset_settings_triggered();
|
||||||
|
|
||||||
|
void webserverThreadFinished();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void refreshFlagspaces();
|
void refreshFlagspaces();
|
||||||
bool doLock;
|
bool doLock;
|
||||||
@ -213,6 +218,7 @@ private:
|
|||||||
QLineEdit *gotoEntry;
|
QLineEdit *gotoEntry;
|
||||||
SdbDock *sdbDock;
|
SdbDock *sdbDock;
|
||||||
QAction *sidebar_action;
|
QAction *sidebar_action;
|
||||||
|
WebServerThread webserverThread;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // MAINWINDOW_H
|
#endif // MAINWINDOW_H
|
||||||
|
Loading…
Reference in New Issue
Block a user