Skip to content

Commit c591400

Browse files
committed
fix: 修复一些小问题;
1 parent 221d916 commit c591400

15 files changed

Lines changed: 1255 additions & 1239 deletions

lang/en_US/winghex_en_US.ts

Lines changed: 363 additions & 363 deletions
Large diffs are not rendered by default.

lang/zh_CN/winghex_zh_CN.ts

Lines changed: 363 additions & 363 deletions
Large diffs are not rendered by default.

lang/zh_TW/winghex_zh_TW.ts

Lines changed: 363 additions & 363 deletions
Large diffs are not rendered by default.

src/class/scriptmachine.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -705,7 +705,6 @@ bool ScriptMachine::executeScript(
705705
ConsoleMode mode, const QString &script, bool isInDebug,
706706
std::function<void(const QHash<QString, AsPreprocesser::Result> &)>
707707
sections,
708-
const std::function<void()> &beginexec,
709708
const std::function<void()> &onFinished) {
710709

711710
ASSERT(mode != Interactive);
@@ -785,6 +784,7 @@ bool ScriptMachine::executeScript(
785784
info.type = MessageType::Error;
786785
outputMessage(info);
787786
_engine->SetUserData(0, AsUserDataType::UserData_ContextMode);
787+
endEvaluateDefine();
788788
onFinished();
789789
return false;
790790
}
@@ -797,6 +797,7 @@ bool ScriptMachine::executeScript(
797797
info.type = MessageType::Error;
798798
outputMessage(info);
799799
_engine->SetUserData(0, AsUserDataType::UserData_ContextMode);
800+
endEvaluateDefine();
800801
onFinished();
801802
return false;
802803
}
@@ -816,6 +817,7 @@ bool ScriptMachine::executeScript(
816817
info.type = MessageType::Error;
817818
outputMessage(info);
818819
_engine->SetUserData(0, AsUserDataType::UserData_ContextMode);
820+
endEvaluateDefine();
819821
onFinished();
820822
return false;
821823
}
@@ -885,10 +887,6 @@ bool ScriptMachine::executeScript(
885887
auto &api = PluginSystem::instance();
886888
auto handles = api.scriptHandles();
887889

888-
if (beginexec) {
889-
beginexec();
890-
}
891-
892890
_ctx[mode] = ctx;
893891
_ctxMgr[mode] = ctxMgr;
894892

src/class/scriptmachine.h

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -154,16 +154,14 @@ class ScriptMachine {
154154

155155
public:
156156
void executeCode(ScriptMachine::ConsoleMode mode, const QString &code,
157-
const std::function<void()> &onFinished = {});
157+
const std::function<void()> &onFinished);
158158

159159
// only scripting mode can be debugged
160160
bool executeScript(
161-
ScriptMachine::ConsoleMode mode, const QString &script,
162-
bool isInDebug = false,
161+
ScriptMachine::ConsoleMode mode, const QString &script, bool isInDebug,
163162
std::function<void(const QHash<QString, AsPreprocesser::Result> &)>
164-
sections = {},
165-
const std::function<void()> &beginexec = {},
166-
const std::function<void()> &onFinished = {});
163+
sections,
164+
const std::function<void()> &onFinished);
167165

168166
QVariant evaluateDefine(const QString &code);
169167

src/class/scriptmanager.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -388,10 +388,9 @@ void ScriptManager::runScript(const QString &filename) {
388388
}
389389

390390
Q_ASSERT(m_indicator);
391-
ins.executeScript(
392-
ScriptMachine::Background, filename, false, {},
393-
[this]() { setIndicatorBusy(true); },
394-
[this]() { setIndicatorBusy(false); });
391+
setIndicatorBusy(true);
392+
ins.executeScript(ScriptMachine::Background, filename, false, {},
393+
[this]() { setIndicatorBusy(false); });
395394
}
396395

397396
QStringList ScriptManager::usrScriptsDbCats() const {

src/class/wingangelapi.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1746,11 +1746,10 @@ bool WingAngelAPI::execScriptCode(const WingHex::SenderInfo &sender,
17461746

17471747
bool WingAngelAPI::execScript(const WingHex::SenderInfo &sender,
17481748
const QString &fileName) {
1749-
17501749
auto exec = [this, fileName]() -> bool {
1750+
ScriptManager::instance().setIndicatorBusy(true);
17511751
return ScriptMachine::instance().executeScript(
17521752
ScriptMachine::Background, fileName, false, {},
1753-
[this]() { ScriptManager::instance().setIndicatorBusy(true); },
17541753
[this]() { ScriptManager::instance().setIndicatorBusy(false); });
17551754
};
17561755

@@ -1767,7 +1766,10 @@ bool WingAngelAPI::execScript(const WingHex::SenderInfo &sender,
17671766
bool WingAngelAPI::execCode(const WingHex::SenderInfo &sender,
17681767
const QString &code) {
17691768
auto exec = [this, code]() -> void {
1770-
ScriptMachine::instance().executeCode(ScriptMachine::Background, code);
1769+
ScriptManager::instance().setIndicatorBusy(true);
1770+
ScriptMachine::instance().executeCode(
1771+
ScriptMachine::Background, code,
1772+
[this]() { ScriptManager::instance().setIndicatorBusy(false); });
17711773
};
17721774

17731775
if (QThread::currentThread() != qApp->thread()) {

src/control/editorview.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -689,7 +689,6 @@ ErrFile EditorView::save(const QString &workSpaceName, const QString &path,
689689
// when path is empty, only save self
690690
if (m_docType == DocumentType::Extension) {
691691
if (doc->saveTo(nullptr, true)) {
692-
doc->setDocSaved();
693692
if (!orginWorkSpace && !workSpaceName.isEmpty()) {
694693
applyWorkSpaceStyle(this);
695694
notifyOnWorkSpace(true);
@@ -700,7 +699,6 @@ ErrFile EditorView::save(const QString &workSpaceName, const QString &path,
700699
if (doc->saveTo(nullptr, true)) {
701700
m_isNewFile = false;
702701
m_docType = DocumentType::File;
703-
doc->setDocSaved();
704702
if (!orginWorkSpace && !workSpaceName.isEmpty()) {
705703
applyWorkSpaceStyle(this);
706704
notifyOnWorkSpace(true);
@@ -712,7 +710,7 @@ ErrFile EditorView::save(const QString &workSpaceName, const QString &path,
712710
auto file = new QFile(path);
713711
bool flag = !isExport;
714712
if (m_docType == DocumentType::Extension) {
715-
if (doc->saveTo(file, flag)) {
713+
if (doc->saveTo(file, false)) {
716714
if (flag) {
717715
m_isNewFile = false;
718716
m_docType = DocumentType::File;
@@ -724,7 +722,6 @@ ErrFile EditorView::save(const QString &workSpaceName, const QString &path,
724722
return ErrFile::Permission;
725723
}
726724
doc->setBuffer(buffer);
727-
doc->setDocSaved();
728725

729726
auto fName = QFileInfo(path).absoluteFilePath();
730727
if (workSpaceName.isEmpty()) {
@@ -736,6 +733,7 @@ ErrFile EditorView::save(const QString &workSpaceName, const QString &path,
736733
applyWorkSpaceStyle(this);
737734
}
738735
setFileNameUrl(QUrl::fromLocalFile(fName));
736+
doc->setDocSaved();
739737
} else {
740738
delete file;
741739
}
@@ -746,7 +744,7 @@ ErrFile EditorView::save(const QString &workSpaceName, const QString &path,
746744
return ErrFile::Success;
747745
}
748746
} else {
749-
if (doc->saveTo(file, flag)) {
747+
if (doc->saveTo(file, false)) {
750748
if (flag) {
751749
auto buffer = new QFileBuffer;
752750
if (!buffer->open(file, false)) {
@@ -758,7 +756,6 @@ ErrFile EditorView::save(const QString &workSpaceName, const QString &path,
758756

759757
m_isNewFile = false;
760758
m_docType = DocumentType::File;
761-
doc->setDocSaved();
762759
auto fName = QFileInfo(path).absoluteFilePath();
763760
if (workSpaceName.isEmpty()) {
764761
clearWorkSpaceStyle(this);
@@ -769,6 +766,7 @@ ErrFile EditorView::save(const QString &workSpaceName, const QString &path,
769766
applyWorkSpaceStyle(this);
770767
}
771768
setFileNameUrl(QUrl::fromLocalFile(fName));
769+
doc->setDocSaved();
772770
} else {
773771
delete file;
774772
}

0 commit comments

Comments
 (0)