Fix crash
This commit is contained in:
23
build.cmd
23
build.cmd
@@ -18,19 +18,20 @@ rd /s /q "%ROOT%dist\%TARGET_MODE%\htdocs"
|
|||||||
mkdir build >NUL 2>&1
|
mkdir build >NUL 2>&1
|
||||||
mkdir build\%TARGET_MODE% >NUL 2>&1
|
mkdir build\%TARGET_MODE% >NUL 2>&1
|
||||||
pushd build\%TARGET_MODE% >NUL 2>&1
|
pushd build\%TARGET_MODE% >NUL 2>&1
|
||||||
(%CMAKE% -G "Visual Studio 14 2015 Win64" -DCMAKE_BUILD_TYPE=%TARGET_MODE% -DSIADRIVE_INSTALL_FOLDER="%ROOT%dist\%TARGET_MODE%" ..\..) && (
|
((%CMAKE% -G "Visual Studio 14 2015 Win64" -DCMAKE_BUILD_TYPE=%TARGET_MODE% -DSIADRIVE_INSTALL_FOLDER="%ROOT%dist\%TARGET_MODE%" ..\..) && (
|
||||||
%CMAKE% --build . --config %TARGET_MODE%) && (
|
%CMAKE% --build . --config %TARGET_MODE%) && (
|
||||||
%CMAKE% --build . --target install --config %TARGET_MODE% && (
|
%CMAKE% --build . --target install --config %TARGET_MODE% && (
|
||||||
rd /s /q "%ROOT%dist\%TARGET_MODE%\config"
|
rd /s /q "%ROOT%dist\%TARGET_MODE%\config"
|
||||||
rd /s /q "%ROOT%dist\%TARGET_MODE%\htdocs\.idea"
|
rd /s /q "%ROOT%dist\%TARGET_MODE%\htdocs\.idea"
|
||||||
del /q "%ROOT%dist\%TARGET_MODE%\*.log"
|
del /q "%ROOT%dist\%TARGET_MODE%\*.log"
|
||||||
rd /s /q "%ROOT%dist\%TARGET_MODE%\logs"
|
rd /s /q "%ROOT%dist\%TARGET_MODE%\logs"
|
||||||
if "%TARGET_MODE%"=="Release" (
|
if "%TARGET_MODE%"=="Release" (
|
||||||
del /q "%ROOT%dist\%TARGET_MODE%\*.lib"
|
del /q "%ROOT%dist\%TARGET_MODE%\*.lib"
|
||||||
del /q "%ROOT%dist\%TARGET_MODE%\*.pdb"
|
del /q "%ROOT%dist\%TARGET_MODE%\*.pdb"
|
||||||
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
) || exit 1
|
||||||
popd
|
popd
|
||||||
|
|
||||||
popd
|
popd
|
@@ -261,7 +261,10 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function _setSiaSettings(settings, cb) {
|
function _setSiaSettings(settings, cb) {
|
||||||
window.appActions.setSiaSettings(settings, cb);
|
}
|
||||||
|
|
||||||
|
function _autoMountDrive() {
|
||||||
|
window.appActions.autoMountDrive();
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
@@ -273,7 +276,8 @@
|
|||||||
shutdown: _shutdown,
|
shutdown: _shutdown,
|
||||||
setRenterSettings: _setRenterSettings,
|
setRenterSettings: _setRenterSettings,
|
||||||
calculateEstimatedStorage: _calculateEstimatedStorage,
|
calculateEstimatedStorage: _calculateEstimatedStorage,
|
||||||
setSiaSettings: _setSiaSettings
|
setSiaSettings: _setSiaSettings,
|
||||||
|
autoMountDrive: _autoMountDrive
|
||||||
};
|
};
|
||||||
})();
|
})();
|
||||||
|
|
||||||
@@ -330,7 +334,7 @@
|
|||||||
const okButton = document.getElementById('ID_RenterUploadsOk');
|
const okButton = document.getElementById('ID_RenterUploadsOk');
|
||||||
okButton.onclick = () => {
|
okButton.onclick = () => {
|
||||||
okButton.onclick = null;
|
okButton.onclick = null;
|
||||||
beginMainApplication();
|
beginMainApplication(false);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -340,7 +344,7 @@
|
|||||||
cancelButton.onclick = () => {
|
cancelButton.onclick = () => {
|
||||||
cancelButton.onclick = null;
|
cancelButton.onclick = null;
|
||||||
saveButton.onclick = null;
|
saveButton.onclick = null;
|
||||||
beginMainApplication();
|
beginMainApplication(false);
|
||||||
};
|
};
|
||||||
|
|
||||||
const saveButton = document.getElementById('ID_SiaSettingsOK');
|
const saveButton = document.getElementById('ID_SiaSettingsOK');
|
||||||
@@ -360,7 +364,7 @@
|
|||||||
'AutoMountOnUnlock': getChecked('ID_Settings_AutoMountOnUnlock')
|
'AutoMountOnUnlock': getChecked('ID_Settings_AutoMountOnUnlock')
|
||||||
}, (success, reason) => {
|
}, (success, reason) => {
|
||||||
if (success) {
|
if (success) {
|
||||||
beginMainApplication();
|
beginMainApplication(false);
|
||||||
} else {
|
} else {
|
||||||
displayErrorPopup('Settings Failed', reason);
|
displayErrorPopup('Settings Failed', reason);
|
||||||
handleSiaEditSettings();
|
handleSiaEditSettings();
|
||||||
@@ -369,7 +373,7 @@
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function beginMainApplication() {
|
function beginMainApplication(checkAutoMount) {
|
||||||
setMainWindow('app_window');
|
setMainWindow('app_window');
|
||||||
const settingsEditLink = document.getElementById('ID_Sia_Settings_Edit');
|
const settingsEditLink = document.getElementById('ID_Sia_Settings_Edit');
|
||||||
settingsEditLink.onclick = () => {
|
settingsEditLink.onclick = () => {
|
||||||
@@ -422,6 +426,9 @@
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
mountButton.onclick = _mountHandler;
|
mountButton.onclick = _mountHandler;
|
||||||
|
if (checkAutoMount) {
|
||||||
|
AppActions.autoMountDrive( );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleRenterEditSettings() {
|
function handleRenterEditSettings() {
|
||||||
@@ -451,7 +458,7 @@
|
|||||||
saveButton.onclick = null;
|
saveButton.onclick = null;
|
||||||
cancelButton.onclick = null;
|
cancelButton.onclick = null;
|
||||||
defaultsButton.onclick = null;
|
defaultsButton.onclick = null;
|
||||||
beginMainApplication();
|
beginMainApplication(false);
|
||||||
};
|
};
|
||||||
|
|
||||||
const saveButton = document.getElementById('ID_RenterSettingsOK');
|
const saveButton = document.getElementById('ID_RenterSettingsOK');
|
||||||
@@ -467,7 +474,7 @@
|
|||||||
'RenewWindowInBlocks': getValue('ID_RenterSetRenewWindow')
|
'RenewWindowInBlocks': getValue('ID_RenterSetRenewWindow')
|
||||||
}, (success, reason) => {
|
}, (success, reason) => {
|
||||||
if (success) {
|
if (success) {
|
||||||
beginMainApplication();
|
beginMainApplication(false);
|
||||||
} else {
|
} else {
|
||||||
displayErrorPopup('Allocation Failed', reason);
|
displayErrorPopup('Allocation Failed', reason);
|
||||||
handleRenterEditSettings();
|
handleRenterEditSettings();
|
||||||
@@ -484,7 +491,7 @@
|
|||||||
const password = document.getElementById('ID_WalletUnlockPwd');
|
const password = document.getElementById('ID_WalletUnlockPwd');
|
||||||
if (AppActions.unlockWallet(password.value, (success, reason) => {
|
if (AppActions.unlockWallet(password.value, (success, reason) => {
|
||||||
if (success) {
|
if (success) {
|
||||||
beginMainApplication();
|
beginMainApplication(true);
|
||||||
} else {
|
} else {
|
||||||
displayErrorPopup('Error', reason, () => {
|
displayErrorPopup('Error', reason, () => {
|
||||||
handleUnlockWallet();
|
handleUnlockWallet();
|
||||||
@@ -503,7 +510,7 @@
|
|||||||
if (UiState.getStoreUnlockPassword()) {
|
if (UiState.getStoreUnlockPassword()) {
|
||||||
if (AppActions.autoUnlockWallet((success) => {
|
if (AppActions.autoUnlockWallet((success) => {
|
||||||
if (success) {
|
if (success) {
|
||||||
beginMainApplication();
|
beginMainApplication(true);
|
||||||
} else {
|
} else {
|
||||||
manualUnlockWallet();
|
manualUnlockWallet();
|
||||||
}
|
}
|
||||||
@@ -544,7 +551,7 @@
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function reloadApplication() {
|
function reloadApplication(checkAutoMount) {
|
||||||
document.getElementById('ID_SiaDrive').innerText = 'SiaDrive ' + UiState.clientVersion();
|
document.getElementById('ID_SiaDrive').innerText = 'SiaDrive ' + UiState.clientVersion();
|
||||||
document.getElementById('ID_ServerVersion').innerText = '...';
|
document.getElementById('ID_ServerVersion').innerText = '...';
|
||||||
if (UiState.isOnline()) {
|
if (UiState.isOnline()) {
|
||||||
@@ -552,7 +559,7 @@
|
|||||||
if (UiState.isWalletLocked()) {
|
if (UiState.isWalletLocked()) {
|
||||||
handleUnlockWallet();
|
handleUnlockWallet();
|
||||||
} else {
|
} else {
|
||||||
beginMainApplication();
|
beginMainApplication(checkAutoMount);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
handleCreateWallet();
|
handleCreateWallet();
|
||||||
@@ -564,6 +571,6 @@
|
|||||||
|
|
||||||
window.addEventListener('load', ()=> {
|
window.addEventListener('load', ()=> {
|
||||||
console.log('Main window load');
|
console.log('Main window load');
|
||||||
reloadApplication();
|
reloadApplication(true);
|
||||||
});
|
});
|
||||||
})();
|
})();
|
@@ -65,28 +65,7 @@ private:
|
|||||||
{
|
{
|
||||||
CefV8ValueList args;
|
CefV8ValueList args;
|
||||||
args.push_back(CefV8Value::CreateBool(ApiSuccess(error)));
|
args.push_back(CefV8Value::CreateBool(ApiSuccess(error)));
|
||||||
if (args[0]->GetBoolValue())
|
if (!args[0]->GetBoolValue())
|
||||||
{
|
|
||||||
if (_siaDriveConfig->GetAutoMountOnUnlock())
|
|
||||||
{
|
|
||||||
const auto lastMountLocation = _siaDriveConfig->GetLastMountLocation();
|
|
||||||
if (!lastMountLocation.empty())
|
|
||||||
{
|
|
||||||
auto global = context->GetGlobal();
|
|
||||||
auto uiUpdate = global->GetValue("uiUpdate");
|
|
||||||
auto notifyDriveMounting = uiUpdate->GetValue("notifyDriveMounting");;
|
|
||||||
|
|
||||||
CefV8ValueList args2;
|
|
||||||
args2.push_back(CefV8Value::CreateString(lastMountLocation));
|
|
||||||
notifyDriveMounting->ExecuteFunction(nullptr, args2);
|
|
||||||
std::thread([this, lastMountLocation, context]()
|
|
||||||
{
|
|
||||||
_siaDrive->Mount(lastMountLocation[0], _siaDriveConfig->GetCacheFolder(), 0);
|
|
||||||
}).detach();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
args.push_back(CefV8Value::CreateString("Failed to unlock wallet"));
|
args.push_back(CefV8Value::CreateString("Failed to unlock wallet"));
|
||||||
}
|
}
|
||||||
@@ -188,6 +167,30 @@ public:
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
else if (name == "autoMountDrive")
|
||||||
|
{
|
||||||
|
retval = CefV8Value::CreateBool(true);
|
||||||
|
if (_siaDriveConfig->GetAutoMountOnUnlock())
|
||||||
|
{
|
||||||
|
const auto lastMountLocation = _siaDriveConfig->GetLastMountLocation();
|
||||||
|
if (!lastMountLocation.empty())
|
||||||
|
{
|
||||||
|
auto global = context->GetGlobal();
|
||||||
|
auto uiUpdate = global->GetValue("uiUpdate");
|
||||||
|
auto notifyDriveMounting = uiUpdate->GetValue("notifyDriveMounting");;
|
||||||
|
|
||||||
|
CefV8ValueList args2;
|
||||||
|
args2.push_back(CefV8Value::CreateString(lastMountLocation));
|
||||||
|
notifyDriveMounting->ExecuteFunction(nullptr, args2);
|
||||||
|
std::thread([this, lastMountLocation, context]()
|
||||||
|
{
|
||||||
|
_siaDrive->Mount(lastMountLocation[0], _siaDriveConfig->GetCacheFolder(), 0);
|
||||||
|
}).detach();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
else if (name == "createWallet")
|
else if (name == "createWallet")
|
||||||
{
|
{
|
||||||
retval = CefV8Value::CreateBool(true);
|
retval = CefV8Value::CreateBool(true);
|
||||||
@@ -377,6 +380,7 @@ void CSiaDriveApp::OnContextCreated(
|
|||||||
global->SetValue("uiState", obj, V8_PROPERTY_ATTRIBUTE_NONE);
|
global->SetValue("uiState", obj, V8_PROPERTY_ATTRIBUTE_NONE);
|
||||||
|
|
||||||
obj = CefV8Value::CreateObject(nullptr, nullptr);
|
obj = CefV8Value::CreateObject(nullptr, nullptr);
|
||||||
|
obj->SetValue("autoMountDrive", CefV8Value::CreateFunction("autoMountDrive", handler), V8_PROPERTY_ATTRIBUTE_NONE);
|
||||||
obj->SetValue("autoUnlockWallet", CefV8Value::CreateFunction("autoUnlockWallet", handler), V8_PROPERTY_ATTRIBUTE_NONE);
|
obj->SetValue("autoUnlockWallet", CefV8Value::CreateFunction("autoUnlockWallet", handler), V8_PROPERTY_ATTRIBUTE_NONE);
|
||||||
obj->SetValue("unlockWallet", CefV8Value::CreateFunction("unlockWallet", handler), V8_PROPERTY_ATTRIBUTE_NONE);
|
obj->SetValue("unlockWallet", CefV8Value::CreateFunction("unlockWallet", handler), V8_PROPERTY_ATTRIBUTE_NONE);
|
||||||
obj->SetValue("createWallet", CefV8Value::CreateFunction("createWallet", handler), V8_PROPERTY_ATTRIBUTE_NONE);
|
obj->SetValue("createWallet", CefV8Value::CreateFunction("createWallet", handler), V8_PROPERTY_ATTRIBUTE_NONE);
|
||||||
@@ -608,30 +612,12 @@ void CSiaDriveApp::SiaApiRefreshCallback(CefRefPtr<CefV8Context> context, const
|
|||||||
{
|
{
|
||||||
CefRefPtr<CefV8Value> reloadApplication = global->GetValue("uiUpdate")->GetValue("reloadApplication");
|
CefRefPtr<CefV8Value> reloadApplication = global->GetValue("uiUpdate")->GetValue("reloadApplication");
|
||||||
CefV8ValueList args;
|
CefV8ValueList args;
|
||||||
|
args.push_back(CefV8Value::CreateBool(isOnline));
|
||||||
reloadApplication->ExecuteFunctionWithContext(context, nullptr, args);
|
reloadApplication->ExecuteFunctionWithContext(context, nullptr, args);
|
||||||
if (isOnline)
|
if (isOnline)
|
||||||
{
|
{
|
||||||
auto uiActions = global->GetValue("uiUpdate");
|
auto uiActions = global->GetValue("uiUpdate");
|
||||||
ExecuteSetter(context, uiActions, "setServerVersion", _siaApi->GetServerVersion());
|
ExecuteSetter(context, uiActions, "setServerVersion", _siaApi->GetServerVersion());
|
||||||
|
|
||||||
if (_siaDriveConfig->GetAutoMountOnUnlock())
|
|
||||||
{
|
|
||||||
const auto lastMountLocation = _siaDriveConfig->GetLastMountLocation();
|
|
||||||
if (!lastMountLocation.empty())
|
|
||||||
{
|
|
||||||
auto uiUpdate = global->GetValue("uiUpdate");
|
|
||||||
auto notifyDriveMounting = uiUpdate->GetValue("notifyDriveMounting");;
|
|
||||||
|
|
||||||
CefV8ValueList args2;
|
|
||||||
args2.push_back(CefV8Value::CreateString(lastMountLocation));
|
|
||||||
notifyDriveMounting->ExecuteFunction(nullptr, args2);
|
|
||||||
|
|
||||||
std::thread([this, lastMountLocation]()
|
|
||||||
{
|
|
||||||
_siaDrive->Mount(lastMountLocation[0], _siaDriveConfig->GetCacheFolder(), 0);
|
|
||||||
}).detach();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isOnline && _siaDrive)
|
if (!isOnline && _siaDrive)
|
||||||
|
Reference in New Issue
Block a user