feat: 增加崩溃报告;优化启动窗体;
This commit is contained in:
parent
80691396f3
commit
6581349950
|
@ -8,3 +8,6 @@
|
|||
path = 3rdparty/AngelScript
|
||||
url = git@github.com:Wing-summer/AngelScript.git
|
||||
branch=stable
|
||||
[submodule "3rdparty/cpptrace"]
|
||||
path = 3rdparty/cpptrace
|
||||
url = git@github.com:Wing-summer/cpptrace.git
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
Subproject commit 6689d14c203eed390ae7bb64f56a983cfd7dff9c
|
|
@ -2037,8 +2037,6 @@ void QEditor::createSimpleBasicContextMenu(bool shortcut, bool extTool) {
|
|||
a->setObjectName("paste");
|
||||
if (shortcut)
|
||||
Q_SHORTCUT(a, "Ctrl+V", "Edit");
|
||||
connect(QApplication::clipboard(), SIGNAL(dataChanged()), this,
|
||||
SLOT(checkClipboard()));
|
||||
|
||||
connect(a, SIGNAL(triggered()), this, SLOT(paste()));
|
||||
|
||||
|
|
|
@ -17,6 +17,19 @@ find_package(
|
|||
Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets Network Concurrent
|
||||
PrintSupport Xml LinguistTools)
|
||||
|
||||
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||
message("Build ${PROJECT_NAME} with ${CMAKE_BUILD_TYPE}.")
|
||||
elseif(CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
|
||||
message("Build ${PROJECT_NAME} with ${CMAKE_BUILD_TYPE}.")
|
||||
elseif(CMAKE_BUILD_TYPE STREQUAL "Release")
|
||||
message(
|
||||
WARNING
|
||||
"${PROJECT_NAME}'s stacktrace won't work built with ${CMAKE_BUILD_TYPE}."
|
||||
)
|
||||
else()
|
||||
message(FATAL_ERROR "Unsupported build type!")
|
||||
endif()
|
||||
|
||||
install(CODE "set(CMAKE_INSTALL_LOCAL_ONLY TRUE)" ALL_COMPONENTS)
|
||||
|
||||
option(BUILD_TEST_PLUGIN OFF)
|
||||
|
@ -72,6 +85,7 @@ set(ADS_VERSION 4.3.1)
|
|||
option(BUILD_EXAMPLES "Build the examples" FALSE)
|
||||
option(BUILD_STATIC "Build the static library" TRUE)
|
||||
|
||||
add_subdirectory(3rdparty/cpptrace)
|
||||
add_subdirectory(3rdparty/QHexView)
|
||||
add_subdirectory(3rdparty/qcodeedit2)
|
||||
add_subdirectory(3rdparty/Qt-Advanced-Docking-System)
|
||||
|
@ -158,7 +172,10 @@ set(DIALOG_SRC
|
|||
src/dialog/splashdialog.h
|
||||
src/dialog/historydeldialog.h
|
||||
src/dialog/historydeldialog.cpp
|
||||
src/dialog/historydeldialog.ui)
|
||||
src/dialog/historydeldialog.ui
|
||||
src/dialog/crashreport.h
|
||||
src/dialog/crashreport.cpp
|
||||
src/dialog/crashreport.ui)
|
||||
|
||||
set(CONTROL_SRC
|
||||
src/control/editorview.h
|
||||
|
@ -195,7 +212,6 @@ set(CONTROL_SRC
|
|||
set(CLASS_SRC
|
||||
src/class/logger.cpp
|
||||
src/class/logger.h
|
||||
src/class/scopeguard.h
|
||||
src/class/skinmanager.cpp
|
||||
src/class/skinmanager.h
|
||||
src/class/workspacemanager.cpp
|
||||
|
@ -264,7 +280,9 @@ set(CLASS_SRC
|
|||
src/class/dockcomponentsfactory.cpp
|
||||
src/class/diffutil.h
|
||||
src/class/diffutil.cpp
|
||||
src/class/clickcallback.h)
|
||||
src/class/clickcallback.h
|
||||
src/class/crashhandler.h
|
||||
src/class/crashhandler.cpp)
|
||||
|
||||
set(INTERNAL_PLG_SRC
|
||||
src/class/wingangelapi.h src/class/wingangelapi.cpp
|
||||
|
@ -502,6 +520,7 @@ target_link_libraries(
|
|||
Qt${QT_VERSION_MAJOR}::GuiPrivate
|
||||
Qt${QT_VERSION_MAJOR}::CorePrivate
|
||||
Qt${QT_VERSION_MAJOR}::Xml
|
||||
cpptrace::cpptrace
|
||||
QtSingleApplication::QtSingleApplication
|
||||
QHexView
|
||||
QCodeEditor2
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 20 KiB |
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -14,6 +14,7 @@
|
|||
<file>images/convpro.png</file>
|
||||
<file>images/copy.png</file>
|
||||
<file>images/copyhex.png</file>
|
||||
<file>images/crashicon.png</file>
|
||||
<file>images/cut.png</file>
|
||||
<file>images/cuthex.png</file>
|
||||
<file>images/dbgcontinue.png</file>
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#include "angelscript.h"
|
||||
#include "clangformatmanager.h"
|
||||
#include "control/toast.h"
|
||||
#include "crashhandler.h"
|
||||
#include "dbghelper.h"
|
||||
#include "define.h"
|
||||
#include "dialog/mainwindow.h"
|
||||
|
@ -41,6 +42,8 @@ AppManager::AppManager(int &argc, char *argv[])
|
|||
: QtSingleApplication(argc, argv) {
|
||||
ASSERT_SINGLETON;
|
||||
|
||||
CrashHandler::instance().init();
|
||||
|
||||
auto args = arguments();
|
||||
if (this->isRunning()) {
|
||||
QByteArray buffer;
|
||||
|
|
|
@ -0,0 +1,126 @@
|
|||
#include "crashhandler.h"
|
||||
#include "angelscript.h"
|
||||
#include "dialog/crashreport.h"
|
||||
#include "plugin/pluginsystem.h"
|
||||
|
||||
#include <QApplication>
|
||||
#include <QLibraryInfo>
|
||||
#include <QTextStream>
|
||||
|
||||
#include <cpptrace/cpptrace.hpp>
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
#include <Windows.h>
|
||||
|
||||
#include <cpptrace/from_current.hpp>
|
||||
|
||||
LONG WINAPI ExceptionFilter(EXCEPTION_POINTERS *) {
|
||||
CrashHandler::reportCrashAndExit();
|
||||
// Terminate the program
|
||||
return EXCEPTION_EXECUTE_HANDLER;
|
||||
}
|
||||
|
||||
#else
|
||||
#include <csignal>
|
||||
#include <execinfo.h>
|
||||
#include <unistd.h>
|
||||
|
||||
void signalHandler(int) { CrashHandler::reportCrashAndExit(); }
|
||||
|
||||
#endif
|
||||
|
||||
CrashHandler &CrashHandler::instance() {
|
||||
static CrashHandler ins;
|
||||
return ins;
|
||||
}
|
||||
|
||||
void CrashHandler::init() {
|
||||
#ifdef Q_OS_WIN
|
||||
::SetUnhandledExceptionFilter(ExceptionFilter);
|
||||
#else
|
||||
::signal(SIGSEGV, signalHandler);
|
||||
::signal(SIGABRT, signalHandler);
|
||||
#endif
|
||||
}
|
||||
|
||||
CrashHandler::CrashHandler() {}
|
||||
|
||||
void CrashHandler::reportCrashAndExit() {
|
||||
QString buffer;
|
||||
QTextStream ss(&buffer);
|
||||
|
||||
ss << QStringLiteral("Basic Infomation:") << Qt::endl;
|
||||
ss << QStringLiteral("* Qt: ") << QLibraryInfo::build() << Qt::endl;
|
||||
ss << QStringLiteral("* OS: ") << QSysInfo::prettyProductName() << Qt::endl;
|
||||
ss << QStringLiteral("* Version: ") << WINGHEX_VERSION << Qt::endl;
|
||||
ss << QStringLiteral("* ScriptEngine: ") << ANGELSCRIPT_VERSION_STRING
|
||||
<< Qt::endl;
|
||||
|
||||
ss << Qt::endl;
|
||||
|
||||
auto &plgsys = PluginSystem::instance();
|
||||
ss << QStringLiteral("Plugin System:") << Qt::endl;
|
||||
ss << QStringLiteral("* Loading: ") << plgsys.currentLoadingPlugin()
|
||||
<< Qt::endl;
|
||||
|
||||
size_t i = 1;
|
||||
ss << QStringLiteral("* Plugins:") << Qt::endl;
|
||||
for (auto &plg : plgsys.plugins()) {
|
||||
auto info = plgsys.getPluginInfo(plg);
|
||||
|
||||
auto header = QStringLiteral(" ");
|
||||
ss << header << QStringLiteral("#") << i << Qt::endl;
|
||||
|
||||
ss << header << QStringLiteral("- ID: ") << info.id << Qt::endl;
|
||||
ss << header << QStringLiteral("- Name: ") << plg->pluginName()
|
||||
<< Qt::endl;
|
||||
ss << header << QStringLiteral("- License: ") << info.license
|
||||
<< Qt::endl;
|
||||
ss << header << QStringLiteral("- Author: ") << info.author << Qt::endl;
|
||||
ss << header << QStringLiteral("- Vendor: ") << info.vendor << Qt::endl;
|
||||
ss << header << QStringLiteral("- Version: ")
|
||||
<< info.version.toString();
|
||||
ss << header << QStringLiteral("- Comment: ") << plg->pluginComment()
|
||||
<< Qt::endl;
|
||||
ss << header << QStringLiteral("- URL: ") << info.url << Qt::endl;
|
||||
|
||||
i++;
|
||||
|
||||
ss << Qt::endl;
|
||||
}
|
||||
|
||||
i = 1;
|
||||
ss << QStringLiteral("* Devices:") << Qt::endl;
|
||||
for (auto &plg : plgsys.devices()) {
|
||||
auto info = plgsys.getPluginInfo(plg);
|
||||
|
||||
auto header = QStringLiteral(" ");
|
||||
ss << header << QStringLiteral("#") << i << Qt::endl;
|
||||
|
||||
ss << header << QStringLiteral("- ID: ") << info.id << Qt::endl;
|
||||
ss << header << QStringLiteral("- Name: ") << plg->pluginName()
|
||||
<< Qt::endl;
|
||||
ss << header << QStringLiteral("- License: ") << info.license
|
||||
<< Qt::endl;
|
||||
ss << header << QStringLiteral("- Author: ") << info.author << Qt::endl;
|
||||
ss << header << QStringLiteral("- Vendor: ") << info.vendor << Qt::endl;
|
||||
ss << header << QStringLiteral("- Version: ")
|
||||
<< info.version.toString();
|
||||
ss << header << QStringLiteral("- Comment: ") << plg->pluginComment()
|
||||
<< Qt::endl;
|
||||
ss << header << QStringLiteral("- URL: ") << info.url << Qt::endl;
|
||||
|
||||
i++;
|
||||
|
||||
ss << Qt::endl;
|
||||
}
|
||||
|
||||
auto str = cpptrace::generate_trace().to_string();
|
||||
ss << QString::fromStdString(str) << Qt::endl;
|
||||
|
||||
CrashReport r;
|
||||
r.setInfomation(buffer);
|
||||
r.exec();
|
||||
|
||||
abort();
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
#ifndef CRASHHANDLER_H
|
||||
#define CRASHHANDLER_H
|
||||
|
||||
#include <QtGlobal>
|
||||
|
||||
class CrashHandler {
|
||||
public:
|
||||
static CrashHandler &instance();
|
||||
|
||||
void init();
|
||||
|
||||
static void reportCrashAndExit();
|
||||
|
||||
private:
|
||||
CrashHandler();
|
||||
};
|
||||
|
||||
#endif // CRASHHANDLER_H
|
|
@ -1,19 +0,0 @@
|
|||
#ifndef SCOPEGUARD_H
|
||||
#define SCOPEGUARD_H
|
||||
|
||||
#include <QtGlobal>
|
||||
|
||||
template <typename CtorFn, typename DctorFn>
|
||||
class ScopeGuard {
|
||||
const DctorFn &dctorfn;
|
||||
|
||||
Q_DISABLE_COPY_MOVE(ScopeGuard)
|
||||
|
||||
public:
|
||||
ScopeGuard(CtorFn &&ctorfn, DctorFn &&dctorfn) : dctorfn(dctorfn) {
|
||||
ctorfn();
|
||||
}
|
||||
~ScopeGuard() { dctorfn(); }
|
||||
};
|
||||
|
||||
#endif // SCOPEGUARD_H
|
|
@ -213,7 +213,8 @@ void SettingManager::setLogCount(qsizetype newLogCount) {
|
|||
void SettingManager::checkWriteableAndWarn() {
|
||||
HANDLE_CONFIG;
|
||||
if (!CONFIG.isWritable()) {
|
||||
Logger::warning(tr("ConfigUnableSave"));
|
||||
Logger::warning(QStringLiteral("<i><u>") % tr("ConfigUnableSave") %
|
||||
QStringLiteral("</u></i>"));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,40 @@
|
|||
#include "crashreport.h"
|
||||
#include "ui_crashreport.h"
|
||||
|
||||
#include <QClipboard>
|
||||
#include <QPushButton>
|
||||
|
||||
#include "utilities.h"
|
||||
|
||||
#include "control/toast.h"
|
||||
|
||||
CrashReport::CrashReport(QWidget *parent)
|
||||
: QWidget(parent), ui(new Ui::CrashReport) {
|
||||
ui->setupUi(this);
|
||||
|
||||
_dialog = new FramelessDialogBase(parent);
|
||||
_dialog->buildUpContent(this);
|
||||
_dialog->setWindowTitle(this->windowTitle());
|
||||
_dialog->setMinimumSize(600, 500);
|
||||
|
||||
Utilities::moveToCenter(_dialog);
|
||||
}
|
||||
|
||||
CrashReport::~CrashReport() { delete ui; }
|
||||
|
||||
void CrashReport::setInfomation(const QString &info) {
|
||||
ui->textBrowser->setText(info);
|
||||
}
|
||||
|
||||
int CrashReport::exec() { return _dialog->exec(); }
|
||||
|
||||
void CrashReport::on_buttonBox_clicked(QAbstractButton *button) {
|
||||
if (button == ui->buttonBox->button(QDialogButtonBox::Save)) {
|
||||
auto clipboard = qApp->clipboard();
|
||||
clipboard->setText(ui->textBrowser->toPlainText());
|
||||
Toast::toast(_dialog, NAMEICONRES(QStringLiteral("copy")),
|
||||
tr("CopyToClipBoard"));
|
||||
} else {
|
||||
_dialog->done(1);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
#ifndef CRASHREPORT_H
|
||||
#define CRASHREPORT_H
|
||||
|
||||
#include "dialog/framelessdialogbase.h"
|
||||
|
||||
#include <QAbstractButton>
|
||||
#include <QWidget>
|
||||
|
||||
namespace Ui {
|
||||
class CrashReport;
|
||||
}
|
||||
|
||||
class CrashReport : public QWidget {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit CrashReport(QWidget *parent = nullptr);
|
||||
~CrashReport();
|
||||
|
||||
public slots:
|
||||
void setInfomation(const QString &info);
|
||||
int exec();
|
||||
|
||||
private slots:
|
||||
void on_buttonBox_clicked(QAbstractButton *button);
|
||||
|
||||
private:
|
||||
Ui::CrashReport *ui;
|
||||
|
||||
FramelessDialogBase *_dialog = nullptr;
|
||||
};
|
||||
|
||||
#endif // CRASHREPORT_H
|
|
@ -0,0 +1,90 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>CrashReport</class>
|
||||
<widget class="QWidget" name="CrashReport">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>446</width>
|
||||
<height>390</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>CrashReport</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<property name="spacing">
|
||||
<number>8</number>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>12</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>12</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>12</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>12</number>
|
||||
</property>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<property name="spacing">
|
||||
<number>10</number>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>15</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>15</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
<height>100</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="pixmap">
|
||||
<pixmap resource="../../resources.qrc">:/com.wingsummer.winghex/images/crashicon.png</pixmap>
|
||||
</property>
|
||||
<property name="scaledContents">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string><html><head/><body><p><span style=" font-size:12pt; font-weight:700;">Opps! The software has crashed! Please send the information below to the dev:</span></p></body></html></string>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QTextBrowser" name="textBrowser"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Ok|QDialogButtonBox::Save</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources>
|
||||
<include location="../../resources.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
</ui>
|
|
@ -32,7 +32,6 @@
|
|||
#include "class/logger.h"
|
||||
#include "class/qkeysequences.h"
|
||||
#include "class/richtextitemdelegate.h"
|
||||
#include "class/scopeguard.h"
|
||||
#include "class/scriptconsolemachine.h"
|
||||
#include "class/settingmanager.h"
|
||||
#include "class/wingfiledialog.h"
|
||||
|
@ -1941,8 +1940,8 @@ EditorView *MainWindow::newfileGUI() {
|
|||
void MainWindow::on_newfile() { newfileGUI(); }
|
||||
|
||||
void MainWindow::on_openfile() {
|
||||
ScopeGuard g([this]() { showStatus(tr("Opening...")); },
|
||||
[this]() { showStatus({}); });
|
||||
showStatus(tr("Opening..."));
|
||||
QScopeGuard g([this]() { showStatus({}); });
|
||||
|
||||
auto filename =
|
||||
WingFileDialog::getOpenFileName(this, tr("ChooseFile"), m_lastusedpath);
|
||||
|
@ -1972,8 +1971,8 @@ void MainWindow::on_openfile() {
|
|||
}
|
||||
|
||||
void MainWindow::on_openworkspace() {
|
||||
ScopeGuard g([this]() { showStatus(tr("WorkSpaceOpening...")); },
|
||||
[this]() { showStatus({}); });
|
||||
showStatus(tr("WorkSpaceOpening..."));
|
||||
QScopeGuard g([this]() { showStatus({}); });
|
||||
|
||||
auto filename = WingFileDialog::getOpenFileName(
|
||||
this, tr("ChooseFile"), m_lastusedpath, tr("ProjectFile (*.wingpro)"));
|
||||
|
@ -2008,8 +2007,8 @@ void MainWindow::on_openworkspace() {
|
|||
}
|
||||
|
||||
void MainWindow::on_reload() {
|
||||
ScopeGuard g([this]() { showStatus(tr("Reloading...")); },
|
||||
[this]() { showStatus({}); });
|
||||
showStatus(tr("Reloading..."));
|
||||
QScopeGuard g([this]() { showStatus({}); });
|
||||
|
||||
auto editor = currentEditor();
|
||||
if (editor == nullptr) {
|
||||
|
@ -2030,8 +2029,8 @@ void MainWindow::on_reload() {
|
|||
}
|
||||
|
||||
void MainWindow::on_save() {
|
||||
ScopeGuard g([this]() { showStatus(tr("Saving...")); },
|
||||
[this]() { showStatus({}); });
|
||||
showStatus(tr("Saving..."));
|
||||
QScopeGuard g([this]() { showStatus({}); });
|
||||
|
||||
auto editor = currentEditor();
|
||||
if (editor == nullptr) {
|
||||
|
@ -2101,8 +2100,8 @@ void MainWindow::on_convpro() {
|
|||
}
|
||||
|
||||
void MainWindow::on_saveas() {
|
||||
ScopeGuard g([this]() { showStatus(tr("SavingAs...")); },
|
||||
[this]() { showStatus({}); });
|
||||
showStatus(tr("SavingAs..."));
|
||||
QScopeGuard g([this]() { showStatus({}); });
|
||||
|
||||
auto editor = currentEditor();
|
||||
if (editor == nullptr) {
|
||||
|
@ -2147,8 +2146,8 @@ void MainWindow::on_saveas() {
|
|||
}
|
||||
|
||||
void MainWindow::on_exportfile() {
|
||||
ScopeGuard g([this]() { showStatus(tr("Exporting...")); },
|
||||
[this]() { showStatus({}); });
|
||||
showStatus(tr("Exporting..."));
|
||||
QScopeGuard g([this]() { showStatus({}); });
|
||||
|
||||
auto editor = currentEditor();
|
||||
if (editor == nullptr) {
|
||||
|
@ -2177,8 +2176,8 @@ void MainWindow::on_exportfile() {
|
|||
}
|
||||
|
||||
void MainWindow::on_savesel() {
|
||||
ScopeGuard g([this]() { showStatus(tr("SavingSel...")); },
|
||||
[this]() { showStatus({}); });
|
||||
showStatus(tr("SavingSel..."));
|
||||
QScopeGuard g([this]() { showStatus({}); });
|
||||
|
||||
auto hexeditor = currentHexView();
|
||||
if (hexeditor == nullptr) {
|
||||
|
@ -2745,8 +2744,8 @@ void MainWindow::on_clearfindresult() {
|
|||
}
|
||||
|
||||
void MainWindow::on_exportfindresult() {
|
||||
ScopeGuard g([this]() { showStatus(tr("FindResultExporting...")); },
|
||||
[this]() { showStatus({}); });
|
||||
showStatus(tr("FindResultExporting..."));
|
||||
QScopeGuard g([this]() { showStatus({}); });
|
||||
|
||||
auto editor = currentEditor();
|
||||
if (editor == nullptr) {
|
||||
|
@ -3001,8 +3000,8 @@ void MainWindow::on_fullScreen() {
|
|||
}
|
||||
|
||||
void MainWindow::on_saveLayout() {
|
||||
ScopeGuard g([this]() { showStatus(tr("LayoutSaving...")); },
|
||||
[this]() { showStatus({}); });
|
||||
showStatus(tr("LayoutSaving..."));
|
||||
QScopeGuard g([this]() { showStatus({}); });
|
||||
|
||||
static auto suffix = QStringLiteral(".wing-layout");
|
||||
bool ok;
|
||||
|
@ -3039,8 +3038,8 @@ void MainWindow::on_saveLayout() {
|
|||
}
|
||||
|
||||
void MainWindow::on_exportlog() {
|
||||
ScopeGuard g([this]() { showStatus(tr("LogExporting...")); },
|
||||
[this]() { showStatus({}); });
|
||||
showStatus(tr("LogExporting..."));
|
||||
QScopeGuard g([this]() { showStatus({}); });
|
||||
auto nfile = saveLog();
|
||||
if (nfile.isEmpty()) {
|
||||
Toast::toast(this, NAMEICONRES(QStringLiteral("log")),
|
||||
|
|
|
@ -1040,8 +1040,7 @@ void ScriptingDialog::startDebugScript(const QString &fileName) {
|
|||
}
|
||||
|
||||
_DebugingScript = fileName;
|
||||
PluginSystem::instance().dispatchEvent(
|
||||
IWingPlugin::RegisteredEvent::ScriptPragmaInit, {});
|
||||
PluginSystem::instance().scriptPragmaBegin();
|
||||
m_consoleout->machine()->executeScript(fileName, true);
|
||||
|
||||
updateRunDebugMode();
|
||||
|
@ -1393,8 +1392,7 @@ void ScriptingDialog::on_runscript() {
|
|||
return;
|
||||
}
|
||||
m_consoleout->clear();
|
||||
PluginSystem::instance().dispatchEvent(
|
||||
IWingPlugin::RegisteredEvent::ScriptPragmaInit, {});
|
||||
PluginSystem::instance().scriptPragmaBegin();
|
||||
m_consoleout->machine()->executeScript(e->fileName());
|
||||
updateRunDebugMode();
|
||||
}
|
||||
|
|
|
@ -27,8 +27,8 @@ SplashDialog::SplashDialog(QWidget *parent)
|
|||
QStringLiteral("<html><head/><body><p><span style=\" font-size:16pt; "
|
||||
"font-weight:600;\">%1</span></p></body></html>")
|
||||
.arg(qAppName()));
|
||||
setWindowFlags(Qt::CustomizeWindowHint | Qt::SplashScreen |
|
||||
Qt::WindowStaysOnTopHint);
|
||||
setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint |
|
||||
Qt::Window);
|
||||
setAttribute(Qt::WA_DeleteOnClose);
|
||||
setModal(true);
|
||||
show();
|
||||
|
|
|
@ -42,10 +42,7 @@
|
|||
|
||||
PluginSystem::PluginSystem(QObject *parent) : QObject(parent) {}
|
||||
|
||||
PluginSystem::~PluginSystem() {
|
||||
Q_ASSERT(_loadedplgs.isEmpty());
|
||||
Q_ASSERT(_loadeddevs.isEmpty());
|
||||
}
|
||||
PluginSystem::~PluginSystem() {}
|
||||
|
||||
void PluginSystem::initCheckingEngine() {
|
||||
_engine = dynamic_cast<asCScriptEngine *>(asCreateScriptEngine());
|
||||
|
@ -58,8 +55,12 @@ void PluginSystem::initCheckingEngine() {
|
|||
|
||||
void PluginSystem::finalizeCheckingEngine() { _engine->ShutDownAndRelease(); }
|
||||
|
||||
QString PluginSystem::currentLoadingPlugin() const { return _curLoadingPlg; }
|
||||
|
||||
QStringList PluginSystem::scriptMarcos() const { return _scriptMarcos; }
|
||||
|
||||
void PluginSystem::scriptPragmaBegin() { _pragmaedPlg.clear(); }
|
||||
|
||||
const QList<IWingPlugin *> &PluginSystem::plugins() const {
|
||||
return _loadedplgs;
|
||||
}
|
||||
|
@ -83,6 +84,10 @@ PluginSystem::loadPlugin(const QFileInfo &fileinfo, const QDir &setdir) {
|
|||
|
||||
if (fileinfo.exists()) {
|
||||
auto fileName = fileinfo.absoluteFilePath();
|
||||
_curLoadingPlg =
|
||||
QDir(qApp->applicationDirPath()).relativeFilePath(fileName);
|
||||
|
||||
QScopeGuard g([this]() { _curLoadingPlg.clear(); });
|
||||
QPluginLoader loader(fileName, this);
|
||||
Logger::info(tr("LoadingPlugin") + fileinfo.fileName());
|
||||
|
||||
|
@ -493,13 +498,15 @@ bool PluginSystem::dispatchEvent(IWingPlugin::RegisteredEvent event,
|
|||
if (r == es.constEnd()) {
|
||||
return false;
|
||||
}
|
||||
return (*r)->eventOnScriptPragma(section, params.at(3).toStringList());
|
||||
} break;
|
||||
case WingHex::IWingPlugin::RegisteredEvent::ScriptPragmaInit: {
|
||||
Q_ASSERT(params.isEmpty());
|
||||
for (auto &plg : _evplgs[event]) {
|
||||
auto plg = *r;
|
||||
if (!_pragmaedPlg.contains(plg)) {
|
||||
plg->eventOnScriptPragmaInit();
|
||||
}
|
||||
return plg->eventOnScriptPragma(section, params.at(3).toStringList());
|
||||
} break;
|
||||
case WingHex::IWingPlugin::RegisteredEvent::ScriptPragmaInit: {
|
||||
Q_ASSERT(false);
|
||||
// should not go there, lazy calling instead
|
||||
} break;
|
||||
case WingHex::IWingPlugin::RegisteredEvent::PluginFileOpened: {
|
||||
Q_ASSERT(params.size() == 4);
|
||||
|
@ -1281,6 +1288,7 @@ void PluginSystem::loadPlugin(IWingDevice *p, PluginInfo &meta,
|
|||
|
||||
registerPluginPages(p);
|
||||
connectInterface(p);
|
||||
registerMarcoDevice(p);
|
||||
|
||||
// ok register into menu open
|
||||
auto menu =
|
||||
|
@ -1417,6 +1425,12 @@ void PluginSystem::registerPluginPages(IWingPluginBase *p) {
|
|||
}
|
||||
}
|
||||
|
||||
void PluginSystem::registerMarcoDevice(IWingDevice *plg) {
|
||||
auto id = getPUID(plg).toUpper();
|
||||
auto sep = QStringLiteral("_");
|
||||
_scriptMarcos.append(sep + id + sep);
|
||||
}
|
||||
|
||||
bool PluginSystem::updateTextList_API(const QStringList &data,
|
||||
const QString &title,
|
||||
const ClickCallBack &click,
|
||||
|
|
|
@ -162,6 +162,9 @@ public:
|
|||
|
||||
QStringList scriptMarcos() const;
|
||||
|
||||
public:
|
||||
void scriptPragmaBegin();
|
||||
|
||||
public:
|
||||
PluginInfo getPluginInfo(IWingPluginBase *plg) const;
|
||||
|
||||
|
@ -256,6 +259,7 @@ private:
|
|||
private:
|
||||
void connectInterface(IWingDevice *plg);
|
||||
void connectLoadingInterface(IWingDevice *plg);
|
||||
void registerMarcoDevice(IWingDevice *plg);
|
||||
|
||||
private:
|
||||
void connectBaseInterface(IWingPluginBase *plg);
|
||||
|
@ -275,6 +279,10 @@ public:
|
|||
const QString &title, const ClickCallBack &click,
|
||||
const ClickCallBack &dblclick);
|
||||
|
||||
public:
|
||||
// fpr crash checking
|
||||
QString currentLoadingPlugin() const;
|
||||
|
||||
private:
|
||||
template <typename T>
|
||||
T readBasicTypeContent(IWingPlugin *plg, qsizetype offset) {
|
||||
|
@ -396,8 +404,12 @@ private:
|
|||
asCScriptEngine *_engine = nullptr;
|
||||
|
||||
QStringList _scriptMarcos;
|
||||
QList<IWingPlugin *> _pragmaedPlg;
|
||||
|
||||
QReadWriteLock _rwlock;
|
||||
|
||||
private:
|
||||
QString _curLoadingPlg;
|
||||
};
|
||||
|
||||
#endif // PLUGINSYSTEM_H
|
||||
|
|
Loading…
Reference in New Issue