Skip to content

Commit

Permalink
Fix script crash and incomplete script menu on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
felipemanga committed Dec 24, 2023
1 parent ec92a86 commit b2a4973
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/app/script/script_menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ using namespace ui;

void scanFolder(const std::string& scriptsDir, Command* cmd_run_script, Menu* parent) {
auto fs = FileSystemModule::instance();
auto item = fs->getFileItemFromPath(scriptsDir);
auto item = fs->getFileItemFromPath(base::fix_path_separators(scriptsDir));
if (!item)
return;
Params params;
FileItemList list = item->children();
for (auto child : list) {
bool isFolder = child->isFolder();
std::string fullPath = base::fix_path_separators(child->fileName());
std::string fullPath = child->fileName();
if (!isFolder) {
bool supported = false;
auto extension = base::string_to_lower(base::get_file_extension(fullPath));
Expand Down
14 changes: 9 additions & 5 deletions src/script/v8/engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
// Read LICENSE.txt for more information.


#include <cstring>
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
Expand All @@ -19,6 +18,8 @@
#include "script/engine.h"
#include "script/engine_delegate.h"

#include "app/resource_finder.h"
#include <cstring>
#include <map>
#include <iostream>
#include <string>
Expand Down Expand Up @@ -59,10 +60,13 @@ class V8Engine : public Engine {
void initV8() {
static std::unique_ptr<v8::Platform> m_platform;
if (!m_platform) {
// Conflicting documentation. Not sure if this is actually needed.
// v8::V8::InitializeICUDefaultLocation(base::get_app_path().c_str());
// v8::V8::InitializeExternalStartupData(base::get_app_path().c_str());
v8::V8::InitializeICU();
app::ResourceFinder rf;
rf.includeBinDir("snapshot_blob.bin");
if (rf.findFirst()) {
v8::V8::InitializeExternalStartupData(rf.filename().c_str());
} else {
v8::V8::InitializeICU();
}

m_platform = v8::platform::NewDefaultPlatform();
v8::V8::InitializePlatform(m_platform.get());
Expand Down

0 comments on commit b2a4973

Please sign in to comment.