GUIでFatal Errorが発生した時に自分でメッセージを出すようにした

This commit is contained in:
lltcggie 2016-07-06 14:32:38 +09:00
parent c4a8e4d6db
commit 92ca8db404
4 changed files with 23 additions and 5 deletions

View File

@ -93,5 +93,6 @@
"Cancel":"Cancel",
"IDC_STATIC_USE_GPU_NO":"Use GPU No",
"IDC_RADIO_MODEL_UPCONV_RGB":"2-D illust (UpRGB Model)",
"IDC_RADIO_MODEL_UPCONV_PHOTO":"Photo (UpPhoto Model)"
"IDC_RADIO_MODEL_UPCONV_PHOTO":"Photo (UpPhoto Model)",
"MessageLogFatalError":"The fatal error has occurred.\r\nThere is a possibility the split size is too large"
}

View File

@ -93,5 +93,6 @@
"Cancel":"キャンセル",
"IDC_STATIC_USE_GPU_NO":"使用GPU No",
"IDC_RADIO_MODEL_UPCONV_RGB":"2次元イラスト (UpRGBモデル)",
"IDC_RADIO_MODEL_UPCONV_PHOTO":"写真・アニメ (UpPhotoモデル)"
"IDC_RADIO_MODEL_UPCONV_PHOTO":"写真・アニメ (UpPhotoモデル)",
"MessageLogFatalError":"致命的なエラーが発生しました。\r\n分割サイズが大きすぎる可能性があります"
}

View File

@ -20,6 +20,7 @@
#include "CControl.h"
//#include <boost/program_options.hpp>
#include <tclapw/CmdLine.h>
#include <glog/logging.h>
const size_t AR_PATH_MAX(1024);
@ -37,6 +38,9 @@ const TCHAR * const MultiFileStr = TEXT("(Multi File)");
const UINT_PTR nIDEventTimeLeft = 1000;
LangStringList DialogEvent::langStringList;
HWND DialogEvent::dh;
namespace
{
@ -1192,7 +1196,7 @@ UINT_PTR DialogEvent::OFNHookProcOut(HWND hdlg, UINT uiMsg, WPARAM wParam, LPARA
return 0L;
}
DialogEvent::DialogEvent() : dh(nullptr), mode(Waifu2x::eWaifu2xModelTypeNoiseScale), modeStr("noise_scale"), noise_level(1), scale_ratio(2.0), scale_width(0), scale_height(0), model_dir(TEXT("models/anime_style_art_rgb")),
DialogEvent::DialogEvent() : mode(Waifu2x::eWaifu2xModelTypeNoiseScale), modeStr("noise_scale"), noise_level(1), scale_ratio(2.0), scale_width(0), scale_height(0), model_dir(TEXT("models/anime_style_art_rgb")),
process("gpu"), outputExt(TEXT(".png")), inputFileExt(TEXT("png:jpg:jpeg:tif:tiff:bmp:tga")),
use_tta(false), output_depth(8), crop_size(128), batch_size(1), gpu_no(0), isLastError(false), scaleType(eScaleTypeEnd),
TimeLeftThread(-1), TimeLeftGetTimeThread(0), isCommandLineStart(false), tAutoMode(TEXT("none")),
@ -1626,6 +1630,9 @@ void DialogEvent::Create(HWND hWnd, WPARAM wParam, LPARAM lParam, LPVOID lpData)
SendMessage(hlang, CB_SETCURSEL, defaultListIndex, 0);
}
// 致命的エラーが発生した時にLogFatalFuncを呼び出すようにする
google::InstallFailureFunction(LogFatalFunc);
SetWindowTextLang();
{
@ -3120,3 +3127,9 @@ void DialogEvent::AppSetting(HWND hWnd, WPARAM wParam, LPARAM lParam, LPVOID lpD
}
}
}
void DialogEvent::LogFatalFunc()
{
MessageBox(dh, langStringList.GetString(L"MessageLogFatalError").c_str(), langStringList.GetString(L"MessageTitleError").c_str(), MB_OK | MB_ICONERROR);
abort();
}

View File

@ -26,7 +26,9 @@
class DialogEvent
{
private:
HWND dh;
static HWND dh;
static LangStringList langStringList;
boost::filesystem::path exeDir;
std::vector<int> CropSizeList;
@ -94,7 +96,6 @@ private:
eModelType modelType;
LangStringList langStringList;
std::wstring LangName;
std::atomic<int64_t> TimeLeftThread;
@ -153,6 +154,8 @@ private:
_In_ LPARAM lParam
);
static void LogFatalFunc();
public:
DialogEvent();