feat: 增加崩溃报告;优化启动窗体;
This commit is contained in:
parent
80691396f3
commit
a5a796861c
|
@ -8,3 +8,6 @@
|
||||||
path = 3rdparty/AngelScript
|
path = 3rdparty/AngelScript
|
||||||
url = git@github.com:Wing-summer/AngelScript.git
|
url = git@github.com:Wing-summer/AngelScript.git
|
||||||
branch=stable
|
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");
|
a->setObjectName("paste");
|
||||||
if (shortcut)
|
if (shortcut)
|
||||||
Q_SHORTCUT(a, "Ctrl+V", "Edit");
|
Q_SHORTCUT(a, "Ctrl+V", "Edit");
|
||||||
connect(QApplication::clipboard(), SIGNAL(dataChanged()), this,
|
|
||||||
SLOT(checkClipboard()));
|
|
||||||
|
|
||||||
connect(a, SIGNAL(triggered()), this, SLOT(paste()));
|
connect(a, SIGNAL(triggered()), this, SLOT(paste()));
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,19 @@ find_package(
|
||||||
Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets Network Concurrent
|
Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets Network Concurrent
|
||||||
PrintSupport Xml LinguistTools)
|
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)
|
install(CODE "set(CMAKE_INSTALL_LOCAL_ONLY TRUE)" ALL_COMPONENTS)
|
||||||
|
|
||||||
option(BUILD_TEST_PLUGIN OFF)
|
option(BUILD_TEST_PLUGIN OFF)
|
||||||
|
@ -72,6 +85,7 @@ set(ADS_VERSION 4.3.1)
|
||||||
option(BUILD_EXAMPLES "Build the examples" FALSE)
|
option(BUILD_EXAMPLES "Build the examples" FALSE)
|
||||||
option(BUILD_STATIC "Build the static library" TRUE)
|
option(BUILD_STATIC "Build the static library" TRUE)
|
||||||
|
|
||||||
|
add_subdirectory(3rdparty/cpptrace)
|
||||||
add_subdirectory(3rdparty/QHexView)
|
add_subdirectory(3rdparty/QHexView)
|
||||||
add_subdirectory(3rdparty/qcodeedit2)
|
add_subdirectory(3rdparty/qcodeedit2)
|
||||||
add_subdirectory(3rdparty/Qt-Advanced-Docking-System)
|
add_subdirectory(3rdparty/Qt-Advanced-Docking-System)
|
||||||
|
@ -158,7 +172,10 @@ set(DIALOG_SRC
|
||||||
src/dialog/splashdialog.h
|
src/dialog/splashdialog.h
|
||||||
src/dialog/historydeldialog.h
|
src/dialog/historydeldialog.h
|
||||||
src/dialog/historydeldialog.cpp
|
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
|
set(CONTROL_SRC
|
||||||
src/control/editorview.h
|
src/control/editorview.h
|
||||||
|
@ -195,7 +212,6 @@ set(CONTROL_SRC
|
||||||
set(CLASS_SRC
|
set(CLASS_SRC
|
||||||
src/class/logger.cpp
|
src/class/logger.cpp
|
||||||
src/class/logger.h
|
src/class/logger.h
|
||||||
src/class/scopeguard.h
|
|
||||||
src/class/skinmanager.cpp
|
src/class/skinmanager.cpp
|
||||||
src/class/skinmanager.h
|
src/class/skinmanager.h
|
||||||
src/class/workspacemanager.cpp
|
src/class/workspacemanager.cpp
|
||||||
|
@ -264,7 +280,9 @@ set(CLASS_SRC
|
||||||
src/class/dockcomponentsfactory.cpp
|
src/class/dockcomponentsfactory.cpp
|
||||||
src/class/diffutil.h
|
src/class/diffutil.h
|
||||||
src/class/diffutil.cpp
|
src/class/diffutil.cpp
|
||||||
src/class/clickcallback.h)
|
src/class/clickcallback.h
|
||||||
|
src/class/crashhandler.h
|
||||||
|
src/class/crashhandler.cpp)
|
||||||
|
|
||||||
set(INTERNAL_PLG_SRC
|
set(INTERNAL_PLG_SRC
|
||||||
src/class/wingangelapi.h src/class/wingangelapi.cpp
|
src/class/wingangelapi.h src/class/wingangelapi.cpp
|
||||||
|
@ -502,6 +520,7 @@ target_link_libraries(
|
||||||
Qt${QT_VERSION_MAJOR}::GuiPrivate
|
Qt${QT_VERSION_MAJOR}::GuiPrivate
|
||||||
Qt${QT_VERSION_MAJOR}::CorePrivate
|
Qt${QT_VERSION_MAJOR}::CorePrivate
|
||||||
Qt${QT_VERSION_MAJOR}::Xml
|
Qt${QT_VERSION_MAJOR}::Xml
|
||||||
|
cpptrace::cpptrace
|
||||||
QtSingleApplication::QtSingleApplication
|
QtSingleApplication::QtSingleApplication
|
||||||
QHexView
|
QHexView
|
||||||
QCodeEditor2
|
QCodeEditor2
|
||||||
|
|
|
@ -296,59 +296,60 @@
|
||||||
<context>
|
<context>
|
||||||
<name>TestPlugin</name>
|
<name>TestPlugin</name>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../testplugin.cpp" line="199"/>
|
<location filename="../testplugin.cpp" line="208"/>
|
||||||
<source>Test</source>
|
<source>Test</source>
|
||||||
<translation>测试</translation>
|
<translation>测试</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../testplugin.cpp" line="211"/>
|
|
||||||
<location filename="../testplugin.cpp" line="220"/>
|
<location filename="../testplugin.cpp" line="220"/>
|
||||||
<location filename="../testplugin.cpp" line="225"/>
|
<location filename="../testplugin.cpp" line="229"/>
|
||||||
<location filename="../testplugin.cpp" line="306"/>
|
<location filename="../testplugin.cpp" line="234"/>
|
||||||
|
<location filename="../testplugin.cpp" line="315"/>
|
||||||
<source>TestPlugin</source>
|
<source>TestPlugin</source>
|
||||||
<translation>测试插件</translation>
|
<translation>测试插件</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../testplugin.cpp" line="229"/>
|
<location filename="../testplugin.cpp" line="238"/>
|
||||||
<source>Button - </source>
|
<source>Button - </source>
|
||||||
<translation>按钮 - </translation>
|
<translation>按钮 - </translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../testplugin.cpp" line="233"/>
|
<location filename="../testplugin.cpp" line="242"/>
|
||||||
<source>Click</source>
|
<source>Click</source>
|
||||||
<translation>点击</translation>
|
<translation>点击</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../testplugin.cpp" line="309"/>
|
<location filename="../testplugin.cpp" line="318"/>
|
||||||
<source>A Test Plugin for WingHexExplorer2.</source>
|
<source>A Test Plugin for WingHexExplorer2.</source>
|
||||||
<translation>一个用来测试羽云十六进制编辑器2的插件</translation>
|
<translation>一个用来测试羽云十六进制编辑器2的插件</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../testplugin.cpp" line="347"/>
|
<location filename="../testplugin.cpp" line="356"/>
|
||||||
<location filename="../testplugin.cpp" line="355"/>
|
|
||||||
<location filename="../testplugin.cpp" line="364"/>
|
<location filename="../testplugin.cpp" line="364"/>
|
||||||
<location filename="../testplugin.cpp" line="385"/>
|
<location filename="../testplugin.cpp" line="373"/>
|
||||||
<location filename="../testplugin.cpp" line="401"/>
|
<location filename="../testplugin.cpp" line="394"/>
|
||||||
<location filename="../testplugin.cpp" line="408"/>
|
<location filename="../testplugin.cpp" line="410"/>
|
||||||
<location filename="../testplugin.cpp" line="415"/>
|
<location filename="../testplugin.cpp" line="417"/>
|
||||||
<location filename="../testplugin.cpp" line="422"/>
|
<location filename="../testplugin.cpp" line="424"/>
|
||||||
<location filename="../testplugin.cpp" line="430"/>
|
<location filename="../testplugin.cpp" line="431"/>
|
||||||
<location filename="../testplugin.cpp" line="461"/>
|
<location filename="../testplugin.cpp" line="439"/>
|
||||||
<location filename="../testplugin.cpp" line="469"/>
|
<location filename="../testplugin.cpp" line="470"/>
|
||||||
<location filename="../testplugin.cpp" line="477"/>
|
<location filename="../testplugin.cpp" line="478"/>
|
||||||
<location filename="../testplugin.cpp" line="485"/>
|
<location filename="../testplugin.cpp" line="486"/>
|
||||||
<location filename="../testplugin.cpp" line="494"/>
|
<location filename="../testplugin.cpp" line="494"/>
|
||||||
|
<location filename="../testplugin.cpp" line="503"/>
|
||||||
|
<location filename="../testplugin.cpp" line="510"/>
|
||||||
<source>InvalidParamsCount</source>
|
<source>InvalidParamsCount</source>
|
||||||
<translation>无效参数个数</translation>
|
<translation>无效参数个数</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../testplugin.cpp" line="378"/>
|
<location filename="../testplugin.cpp" line="387"/>
|
||||||
<location filename="../testplugin.cpp" line="394"/>
|
<location filename="../testplugin.cpp" line="403"/>
|
||||||
<source>InvalidParam</source>
|
<source>InvalidParam</source>
|
||||||
<translation>非法参数</translation>
|
<translation>非法参数</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../testplugin.cpp" line="452"/>
|
<location filename="../testplugin.cpp" line="461"/>
|
||||||
<source>AllocArrayFailed</source>
|
<source>AllocArrayFailed</source>
|
||||||
<translation>分配数组失败</translation>
|
<translation>分配数组失败</translation>
|
||||||
</message>
|
</message>
|
||||||
|
|
|
@ -166,6 +166,15 @@ TestPlugin::TestPlugin() : WingHex::IWingPlugin() {
|
||||||
info.ret = MetaType::Bool;
|
info.ret = MetaType::Bool;
|
||||||
_scriptInfo.insert(QStringLiteral("pluginMetaTestEnabled"), info);
|
_scriptInfo.insert(QStringLiteral("pluginMetaTestEnabled"), info);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
WingHex::IWingPlugin::ScriptFnInfo info;
|
||||||
|
info.fn = std::bind(
|
||||||
|
QOverload<const QVariantList &>::of(&TestPlugin::testCrash), this,
|
||||||
|
std::placeholders::_1);
|
||||||
|
info.ret = MetaType::Void;
|
||||||
|
_scriptInfo.insert(QStringLiteral("testCrash"), info);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TestPlugin::~TestPlugin() { destoryTestShareMem(); }
|
TestPlugin::~TestPlugin() { destoryTestShareMem(); }
|
||||||
|
@ -437,10 +446,10 @@ TestPlugin::colorTable(const QList<void *> ¶ms) {
|
||||||
}
|
}
|
||||||
|
|
||||||
auto invoked =
|
auto invoked =
|
||||||
emit invokeService(QStringLiteral("WingAngelAPI"), "vector2AsArray",
|
invokeService(QStringLiteral("WingAngelAPI"), "vector2AsArray",
|
||||||
WINGAPI_RETURN_ARG(void *, array),
|
WINGAPI_RETURN_ARG(void *, array),
|
||||||
WINGAPI_ARG(MetaType, MetaType::Color),
|
WINGAPI_ARG(MetaType, MetaType::Color),
|
||||||
WINGAPI_ARG(QVector<void *>, colors));
|
WINGAPI_ARG(QVector<void *>, colors));
|
||||||
if (invoked) {
|
if (invoked) {
|
||||||
if (array) {
|
if (array) {
|
||||||
qDeleteAll(colors);
|
qDeleteAll(colors);
|
||||||
|
@ -496,6 +505,14 @@ QVariant TestPlugin::pluginMetaTestEnabled(const QVariantList ¶ms) {
|
||||||
return pluginMetaTestEnabled();
|
return pluginMetaTestEnabled();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QVariant TestPlugin::testCrash(const QVariantList ¶ms) {
|
||||||
|
if (!params.isEmpty()) {
|
||||||
|
return getScriptCallError(-1, tr("InvalidParamsCount"));
|
||||||
|
}
|
||||||
|
testCrash();
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
void TestPlugin::test_a() { emit debug(__FUNCTION__); }
|
void TestPlugin::test_a() { emit debug(__FUNCTION__); }
|
||||||
|
|
||||||
void TestPlugin::test_b(const QString &b) {
|
void TestPlugin::test_b(const QString &b) {
|
||||||
|
@ -604,6 +621,15 @@ void TestPlugin::setPluginMetaTestEnabled(bool b) {
|
||||||
|
|
||||||
bool TestPlugin::pluginMetaTestEnabled() { return ENABLE_META; }
|
bool TestPlugin::pluginMetaTestEnabled() { return ENABLE_META; }
|
||||||
|
|
||||||
|
void TestPlugin::testCrash() {
|
||||||
|
// if you want to reproduce nullptr deferenced,
|
||||||
|
// you can use this example. 'volatile' is important in release mode
|
||||||
|
// volatile int *a = nullptr;
|
||||||
|
// (*a)++;
|
||||||
|
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
|
||||||
QHash<QString, WingHex::IWingPlugin::ScriptFnInfo>
|
QHash<QString, WingHex::IWingPlugin::ScriptFnInfo>
|
||||||
TestPlugin::registeredScriptFns() const {
|
TestPlugin::registeredScriptFns() const {
|
||||||
return _scriptInfo;
|
return _scriptInfo;
|
||||||
|
|
|
@ -91,6 +91,8 @@ private:
|
||||||
QVariant setPluginMetaTestEnabled(const QVariantList ¶ms);
|
QVariant setPluginMetaTestEnabled(const QVariantList ¶ms);
|
||||||
QVariant pluginMetaTestEnabled(const QVariantList ¶ms);
|
QVariant pluginMetaTestEnabled(const QVariantList ¶ms);
|
||||||
|
|
||||||
|
QVariant testCrash(const QVariantList ¶ms);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void test_a();
|
void test_a();
|
||||||
void test_b(const QString &b);
|
void test_b(const QString &b);
|
||||||
|
@ -110,6 +112,8 @@ private:
|
||||||
void setPluginMetaTestEnabled(bool b);
|
void setPluginMetaTestEnabled(bool b);
|
||||||
bool pluginMetaTestEnabled();
|
bool pluginMetaTestEnabled();
|
||||||
|
|
||||||
|
void testCrash();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QDialog *_tform = nullptr;
|
QDialog *_tform = nullptr;
|
||||||
QMenu *_tmenu = nullptr;
|
QMenu *_tmenu = nullptr;
|
||||||
|
|
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/convpro.png</file>
|
||||||
<file>images/copy.png</file>
|
<file>images/copy.png</file>
|
||||||
<file>images/copyhex.png</file>
|
<file>images/copyhex.png</file>
|
||||||
|
<file>images/crashicon.png</file>
|
||||||
<file>images/cut.png</file>
|
<file>images/cut.png</file>
|
||||||
<file>images/cuthex.png</file>
|
<file>images/cuthex.png</file>
|
||||||
<file>images/dbgcontinue.png</file>
|
<file>images/dbgcontinue.png</file>
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
#include "angelscript.h"
|
#include "angelscript.h"
|
||||||
#include "clangformatmanager.h"
|
#include "clangformatmanager.h"
|
||||||
#include "control/toast.h"
|
#include "control/toast.h"
|
||||||
|
#include "crashhandler.h"
|
||||||
#include "dbghelper.h"
|
#include "dbghelper.h"
|
||||||
#include "define.h"
|
#include "define.h"
|
||||||
#include "dialog/mainwindow.h"
|
#include "dialog/mainwindow.h"
|
||||||
|
@ -41,6 +42,8 @@ AppManager::AppManager(int &argc, char *argv[])
|
||||||
: QtSingleApplication(argc, argv) {
|
: QtSingleApplication(argc, argv) {
|
||||||
ASSERT_SINGLETON;
|
ASSERT_SINGLETON;
|
||||||
|
|
||||||
|
CrashHandler::instance().init();
|
||||||
|
|
||||||
auto args = arguments();
|
auto args = arguments();
|
||||||
if (this->isRunning()) {
|
if (this->isRunning()) {
|
||||||
QByteArray buffer;
|
QByteArray buffer;
|
||||||
|
|
|
@ -0,0 +1,135 @@
|
||||||
|
#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(SIGILL, signalHandler);
|
||||||
|
::signal(SIGABRT, signalHandler);
|
||||||
|
::signal(SIGFPE, signalHandler);
|
||||||
|
::signal(SIGBUS, 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;
|
||||||
|
|
||||||
|
// we should keep this exception free
|
||||||
|
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();
|
||||||
|
|
||||||
|
#ifdef Q_OS_LINUX
|
||||||
|
// because abort() will also trigger it
|
||||||
|
::signal(SIGABRT, nullptr);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
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() {
|
void SettingManager::checkWriteableAndWarn() {
|
||||||
HANDLE_CONFIG;
|
HANDLE_CONFIG;
|
||||||
if (!CONFIG.isWritable()) {
|
if (!CONFIG.isWritable()) {
|
||||||
Logger::warning(tr("ConfigUnableSave"));
|
Logger::warning(QStringLiteral("<i><u>") + tr("ConfigUnableSave") +
|
||||||
|
QStringLiteral("</u></i>"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,6 @@
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
|
|
||||||
#ifdef Q_OS_LINUX
|
#ifdef Q_OS_LINUX
|
||||||
#include "class/scopeguard.h"
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -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/logger.h"
|
||||||
#include "class/qkeysequences.h"
|
#include "class/qkeysequences.h"
|
||||||
#include "class/richtextitemdelegate.h"
|
#include "class/richtextitemdelegate.h"
|
||||||
#include "class/scopeguard.h"
|
|
||||||
#include "class/scriptconsolemachine.h"
|
#include "class/scriptconsolemachine.h"
|
||||||
#include "class/settingmanager.h"
|
#include "class/settingmanager.h"
|
||||||
#include "class/wingfiledialog.h"
|
#include "class/wingfiledialog.h"
|
||||||
|
@ -1941,8 +1940,8 @@ EditorView *MainWindow::newfileGUI() {
|
||||||
void MainWindow::on_newfile() { newfileGUI(); }
|
void MainWindow::on_newfile() { newfileGUI(); }
|
||||||
|
|
||||||
void MainWindow::on_openfile() {
|
void MainWindow::on_openfile() {
|
||||||
ScopeGuard g([this]() { showStatus(tr("Opening...")); },
|
showStatus(tr("Opening..."));
|
||||||
[this]() { showStatus({}); });
|
QScopeGuard g([this]() { showStatus({}); });
|
||||||
|
|
||||||
auto filename =
|
auto filename =
|
||||||
WingFileDialog::getOpenFileName(this, tr("ChooseFile"), m_lastusedpath);
|
WingFileDialog::getOpenFileName(this, tr("ChooseFile"), m_lastusedpath);
|
||||||
|
@ -1972,8 +1971,8 @@ void MainWindow::on_openfile() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::on_openworkspace() {
|
void MainWindow::on_openworkspace() {
|
||||||
ScopeGuard g([this]() { showStatus(tr("WorkSpaceOpening...")); },
|
showStatus(tr("WorkSpaceOpening..."));
|
||||||
[this]() { showStatus({}); });
|
QScopeGuard g([this]() { showStatus({}); });
|
||||||
|
|
||||||
auto filename = WingFileDialog::getOpenFileName(
|
auto filename = WingFileDialog::getOpenFileName(
|
||||||
this, tr("ChooseFile"), m_lastusedpath, tr("ProjectFile (*.wingpro)"));
|
this, tr("ChooseFile"), m_lastusedpath, tr("ProjectFile (*.wingpro)"));
|
||||||
|
@ -2008,8 +2007,8 @@ void MainWindow::on_openworkspace() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::on_reload() {
|
void MainWindow::on_reload() {
|
||||||
ScopeGuard g([this]() { showStatus(tr("Reloading...")); },
|
showStatus(tr("Reloading..."));
|
||||||
[this]() { showStatus({}); });
|
QScopeGuard g([this]() { showStatus({}); });
|
||||||
|
|
||||||
auto editor = currentEditor();
|
auto editor = currentEditor();
|
||||||
if (editor == nullptr) {
|
if (editor == nullptr) {
|
||||||
|
@ -2030,8 +2029,8 @@ void MainWindow::on_reload() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::on_save() {
|
void MainWindow::on_save() {
|
||||||
ScopeGuard g([this]() { showStatus(tr("Saving...")); },
|
showStatus(tr("Saving..."));
|
||||||
[this]() { showStatus({}); });
|
QScopeGuard g([this]() { showStatus({}); });
|
||||||
|
|
||||||
auto editor = currentEditor();
|
auto editor = currentEditor();
|
||||||
if (editor == nullptr) {
|
if (editor == nullptr) {
|
||||||
|
@ -2101,8 +2100,8 @@ void MainWindow::on_convpro() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::on_saveas() {
|
void MainWindow::on_saveas() {
|
||||||
ScopeGuard g([this]() { showStatus(tr("SavingAs...")); },
|
showStatus(tr("SavingAs..."));
|
||||||
[this]() { showStatus({}); });
|
QScopeGuard g([this]() { showStatus({}); });
|
||||||
|
|
||||||
auto editor = currentEditor();
|
auto editor = currentEditor();
|
||||||
if (editor == nullptr) {
|
if (editor == nullptr) {
|
||||||
|
@ -2147,8 +2146,8 @@ void MainWindow::on_saveas() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::on_exportfile() {
|
void MainWindow::on_exportfile() {
|
||||||
ScopeGuard g([this]() { showStatus(tr("Exporting...")); },
|
showStatus(tr("Exporting..."));
|
||||||
[this]() { showStatus({}); });
|
QScopeGuard g([this]() { showStatus({}); });
|
||||||
|
|
||||||
auto editor = currentEditor();
|
auto editor = currentEditor();
|
||||||
if (editor == nullptr) {
|
if (editor == nullptr) {
|
||||||
|
@ -2177,8 +2176,8 @@ void MainWindow::on_exportfile() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::on_savesel() {
|
void MainWindow::on_savesel() {
|
||||||
ScopeGuard g([this]() { showStatus(tr("SavingSel...")); },
|
showStatus(tr("SavingSel..."));
|
||||||
[this]() { showStatus({}); });
|
QScopeGuard g([this]() { showStatus({}); });
|
||||||
|
|
||||||
auto hexeditor = currentHexView();
|
auto hexeditor = currentHexView();
|
||||||
if (hexeditor == nullptr) {
|
if (hexeditor == nullptr) {
|
||||||
|
@ -2745,8 +2744,8 @@ void MainWindow::on_clearfindresult() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::on_exportfindresult() {
|
void MainWindow::on_exportfindresult() {
|
||||||
ScopeGuard g([this]() { showStatus(tr("FindResultExporting...")); },
|
showStatus(tr("FindResultExporting..."));
|
||||||
[this]() { showStatus({}); });
|
QScopeGuard g([this]() { showStatus({}); });
|
||||||
|
|
||||||
auto editor = currentEditor();
|
auto editor = currentEditor();
|
||||||
if (editor == nullptr) {
|
if (editor == nullptr) {
|
||||||
|
@ -3001,8 +3000,8 @@ void MainWindow::on_fullScreen() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::on_saveLayout() {
|
void MainWindow::on_saveLayout() {
|
||||||
ScopeGuard g([this]() { showStatus(tr("LayoutSaving...")); },
|
showStatus(tr("LayoutSaving..."));
|
||||||
[this]() { showStatus({}); });
|
QScopeGuard g([this]() { showStatus({}); });
|
||||||
|
|
||||||
static auto suffix = QStringLiteral(".wing-layout");
|
static auto suffix = QStringLiteral(".wing-layout");
|
||||||
bool ok;
|
bool ok;
|
||||||
|
@ -3039,8 +3038,8 @@ void MainWindow::on_saveLayout() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::on_exportlog() {
|
void MainWindow::on_exportlog() {
|
||||||
ScopeGuard g([this]() { showStatus(tr("LogExporting...")); },
|
showStatus(tr("LogExporting..."));
|
||||||
[this]() { showStatus({}); });
|
QScopeGuard g([this]() { showStatus({}); });
|
||||||
auto nfile = saveLog();
|
auto nfile = saveLog();
|
||||||
if (nfile.isEmpty()) {
|
if (nfile.isEmpty()) {
|
||||||
Toast::toast(this, NAMEICONRES(QStringLiteral("log")),
|
Toast::toast(this, NAMEICONRES(QStringLiteral("log")),
|
||||||
|
|
|
@ -1040,8 +1040,7 @@ void ScriptingDialog::startDebugScript(const QString &fileName) {
|
||||||
}
|
}
|
||||||
|
|
||||||
_DebugingScript = fileName;
|
_DebugingScript = fileName;
|
||||||
PluginSystem::instance().dispatchEvent(
|
PluginSystem::instance().scriptPragmaBegin();
|
||||||
IWingPlugin::RegisteredEvent::ScriptPragmaInit, {});
|
|
||||||
m_consoleout->machine()->executeScript(fileName, true);
|
m_consoleout->machine()->executeScript(fileName, true);
|
||||||
|
|
||||||
updateRunDebugMode();
|
updateRunDebugMode();
|
||||||
|
@ -1393,8 +1392,7 @@ void ScriptingDialog::on_runscript() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
m_consoleout->clear();
|
m_consoleout->clear();
|
||||||
PluginSystem::instance().dispatchEvent(
|
PluginSystem::instance().scriptPragmaBegin();
|
||||||
IWingPlugin::RegisteredEvent::ScriptPragmaInit, {});
|
|
||||||
m_consoleout->machine()->executeScript(e->fileName());
|
m_consoleout->machine()->executeScript(e->fileName());
|
||||||
updateRunDebugMode();
|
updateRunDebugMode();
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,8 +27,8 @@ SplashDialog::SplashDialog(QWidget *parent)
|
||||||
QStringLiteral("<html><head/><body><p><span style=\" font-size:16pt; "
|
QStringLiteral("<html><head/><body><p><span style=\" font-size:16pt; "
|
||||||
"font-weight:600;\">%1</span></p></body></html>")
|
"font-weight:600;\">%1</span></p></body></html>")
|
||||||
.arg(qAppName()));
|
.arg(qAppName()));
|
||||||
setWindowFlags(Qt::CustomizeWindowHint | Qt::SplashScreen |
|
setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint |
|
||||||
Qt::WindowStaysOnTopHint);
|
Qt::Window);
|
||||||
setAttribute(Qt::WA_DeleteOnClose);
|
setAttribute(Qt::WA_DeleteOnClose);
|
||||||
setModal(true);
|
setModal(true);
|
||||||
show();
|
show();
|
||||||
|
|
|
@ -38,14 +38,10 @@
|
||||||
#include <QFileInfoList>
|
#include <QFileInfoList>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QPluginLoader>
|
#include <QPluginLoader>
|
||||||
#include <QtCore>
|
|
||||||
|
|
||||||
PluginSystem::PluginSystem(QObject *parent) : QObject(parent) {}
|
PluginSystem::PluginSystem(QObject *parent) : QObject(parent) {}
|
||||||
|
|
||||||
PluginSystem::~PluginSystem() {
|
PluginSystem::~PluginSystem() {}
|
||||||
Q_ASSERT(_loadedplgs.isEmpty());
|
|
||||||
Q_ASSERT(_loadeddevs.isEmpty());
|
|
||||||
}
|
|
||||||
|
|
||||||
void PluginSystem::initCheckingEngine() {
|
void PluginSystem::initCheckingEngine() {
|
||||||
_engine = dynamic_cast<asCScriptEngine *>(asCreateScriptEngine());
|
_engine = dynamic_cast<asCScriptEngine *>(asCreateScriptEngine());
|
||||||
|
@ -58,8 +54,12 @@ void PluginSystem::initCheckingEngine() {
|
||||||
|
|
||||||
void PluginSystem::finalizeCheckingEngine() { _engine->ShutDownAndRelease(); }
|
void PluginSystem::finalizeCheckingEngine() { _engine->ShutDownAndRelease(); }
|
||||||
|
|
||||||
|
QString PluginSystem::currentLoadingPlugin() const { return _curLoadingPlg; }
|
||||||
|
|
||||||
QStringList PluginSystem::scriptMarcos() const { return _scriptMarcos; }
|
QStringList PluginSystem::scriptMarcos() const { return _scriptMarcos; }
|
||||||
|
|
||||||
|
void PluginSystem::scriptPragmaBegin() { _pragmaedPlg.clear(); }
|
||||||
|
|
||||||
const QList<IWingPlugin *> &PluginSystem::plugins() const {
|
const QList<IWingPlugin *> &PluginSystem::plugins() const {
|
||||||
return _loadedplgs;
|
return _loadedplgs;
|
||||||
}
|
}
|
||||||
|
@ -83,6 +83,10 @@ PluginSystem::loadPlugin(const QFileInfo &fileinfo, const QDir &setdir) {
|
||||||
|
|
||||||
if (fileinfo.exists()) {
|
if (fileinfo.exists()) {
|
||||||
auto fileName = fileinfo.absoluteFilePath();
|
auto fileName = fileinfo.absoluteFilePath();
|
||||||
|
_curLoadingPlg =
|
||||||
|
QDir(qApp->applicationDirPath()).relativeFilePath(fileName);
|
||||||
|
|
||||||
|
QScopeGuard g([this]() { _curLoadingPlg.clear(); });
|
||||||
QPluginLoader loader(fileName, this);
|
QPluginLoader loader(fileName, this);
|
||||||
Logger::info(tr("LoadingPlugin") + fileinfo.fileName());
|
Logger::info(tr("LoadingPlugin") + fileinfo.fileName());
|
||||||
|
|
||||||
|
@ -493,13 +497,15 @@ bool PluginSystem::dispatchEvent(IWingPlugin::RegisteredEvent event,
|
||||||
if (r == es.constEnd()) {
|
if (r == es.constEnd()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return (*r)->eventOnScriptPragma(section, params.at(3).toStringList());
|
auto plg = *r;
|
||||||
} break;
|
if (!_pragmaedPlg.contains(plg)) {
|
||||||
case WingHex::IWingPlugin::RegisteredEvent::ScriptPragmaInit: {
|
|
||||||
Q_ASSERT(params.isEmpty());
|
|
||||||
for (auto &plg : _evplgs[event]) {
|
|
||||||
plg->eventOnScriptPragmaInit();
|
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;
|
} break;
|
||||||
case WingHex::IWingPlugin::RegisteredEvent::PluginFileOpened: {
|
case WingHex::IWingPlugin::RegisteredEvent::PluginFileOpened: {
|
||||||
Q_ASSERT(params.size() == 4);
|
Q_ASSERT(params.size() == 4);
|
||||||
|
@ -1281,6 +1287,7 @@ void PluginSystem::loadPlugin(IWingDevice *p, PluginInfo &meta,
|
||||||
|
|
||||||
registerPluginPages(p);
|
registerPluginPages(p);
|
||||||
connectInterface(p);
|
connectInterface(p);
|
||||||
|
registerMarcoDevice(p);
|
||||||
|
|
||||||
// ok register into menu open
|
// ok register into menu open
|
||||||
auto menu =
|
auto menu =
|
||||||
|
@ -1417,6 +1424,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,
|
bool PluginSystem::updateTextList_API(const QStringList &data,
|
||||||
const QString &title,
|
const QString &title,
|
||||||
const ClickCallBack &click,
|
const ClickCallBack &click,
|
||||||
|
|
|
@ -162,6 +162,9 @@ public:
|
||||||
|
|
||||||
QStringList scriptMarcos() const;
|
QStringList scriptMarcos() const;
|
||||||
|
|
||||||
|
public:
|
||||||
|
void scriptPragmaBegin();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
PluginInfo getPluginInfo(IWingPluginBase *plg) const;
|
PluginInfo getPluginInfo(IWingPluginBase *plg) const;
|
||||||
|
|
||||||
|
@ -256,6 +259,7 @@ private:
|
||||||
private:
|
private:
|
||||||
void connectInterface(IWingDevice *plg);
|
void connectInterface(IWingDevice *plg);
|
||||||
void connectLoadingInterface(IWingDevice *plg);
|
void connectLoadingInterface(IWingDevice *plg);
|
||||||
|
void registerMarcoDevice(IWingDevice *plg);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void connectBaseInterface(IWingPluginBase *plg);
|
void connectBaseInterface(IWingPluginBase *plg);
|
||||||
|
@ -275,6 +279,10 @@ public:
|
||||||
const QString &title, const ClickCallBack &click,
|
const QString &title, const ClickCallBack &click,
|
||||||
const ClickCallBack &dblclick);
|
const ClickCallBack &dblclick);
|
||||||
|
|
||||||
|
public:
|
||||||
|
// fpr crash checking
|
||||||
|
QString currentLoadingPlugin() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T readBasicTypeContent(IWingPlugin *plg, qsizetype offset) {
|
T readBasicTypeContent(IWingPlugin *plg, qsizetype offset) {
|
||||||
|
@ -396,8 +404,12 @@ private:
|
||||||
asCScriptEngine *_engine = nullptr;
|
asCScriptEngine *_engine = nullptr;
|
||||||
|
|
||||||
QStringList _scriptMarcos;
|
QStringList _scriptMarcos;
|
||||||
|
QList<IWingPlugin *> _pragmaedPlg;
|
||||||
|
|
||||||
QReadWriteLock _rwlock;
|
QReadWriteLock _rwlock;
|
||||||
|
|
||||||
|
private:
|
||||||
|
QString _curLoadingPlg;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // PLUGINSYSTEM_H
|
#endif // PLUGINSYSTEM_H
|
||||||
|
|
Loading…
Reference in New Issue