diff options
-rw-r--r-- | src/mir_app/mir_app.vcxproj | 8 | ||||
-rw-r--r-- | src/mir_app/src/MDatabaseCommonCrypt.cpp | 2 | ||||
-rw-r--r-- | src/mir_app/src/database.cpp | 54 |
3 files changed, 37 insertions, 27 deletions
diff --git a/src/mir_app/mir_app.vcxproj b/src/mir_app/mir_app.vcxproj index 50cfd59262..b2b3925bb9 100644 --- a/src/mir_app/mir_app.vcxproj +++ b/src/mir_app/mir_app.vcxproj @@ -64,7 +64,9 @@ <ClCompile Include="src\db_upgrade.cpp" />
<ClCompile Include="src\db_util.cpp" />
<ClCompile Include="src\descbutton.cpp" />
- <ClCompile Include="src\dll_sniffer.cpp" />
+ <ClCompile Include="src\dll_sniffer.cpp">
+ <ExceptionHandling>false</ExceptionHandling>
+ </ClCompile>
<ClCompile Include="src\Docking.cpp" />
<ClCompile Include="src\ei_baseIcon.cpp" />
<ClCompile Include="src\ei_callbackIcon.cpp" />
@@ -196,8 +198,8 @@ </ItemGroup>
<ItemDefinitionGroup>
<ClCompile>
- <PreprocessorDefinitions Condition="'$(Configuration)'=='Debug'">MIR_APP_EXPORTS;DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <PreprocessorDefinitions Condition="'$(Configuration)'=='Release'">MIR_APP_EXPORTS;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <PreprocessorDefinitions>MIR_APP_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <ExceptionHandling>Sync</ExceptionHandling>
</ClCompile>
<Link>
<ModuleDefinitionFile Condition="'$(Platform)'=='Win32'">src/mir_app.def</ModuleDefinitionFile>
diff --git a/src/mir_app/src/MDatabaseCommonCrypt.cpp b/src/mir_app/src/MDatabaseCommonCrypt.cpp index 47a75a8cba..a3b9efdbeb 100644 --- a/src/mir_app/src/MDatabaseCommonCrypt.cpp +++ b/src/mir_app/src/MDatabaseCommonCrypt.cpp @@ -457,7 +457,7 @@ int MDatabaseCommon::InitCrypt() CEnterPasswordDialog dlg(this);
while (true) {
if (!dlg.DoModal())
- return 4;
+ throw -2;
pass_ptrA szPassword(mir_utf8encodeW(dlg.m_newPass));
if (m_crypto->setKey(szPassword, (const uint8_t*)key.data(), key.length())) {
diff --git a/src/mir_app/src/database.cpp b/src/mir_app/src/database.cpp index 5b1c0f882d..40bc14ccb9 100644 --- a/src/mir_app/src/database.cpp +++ b/src/mir_app/src/database.cpp @@ -527,39 +527,47 @@ int LoadDatabaseModule(void) }
// find a driver to support the given profile
- bool retry;
+LBL_Restart:
int rc;
- do {
- retry = false;
+ try {
if (!szProfile.isExist() && shouldAutoCreate(szProfile))
rc = tryCreateDatabase(szProfile);
else
rc = tryOpenDatabase(szProfile);
+ }
+ catch (int errorCode) {
+ rc = errorCode;
+ }
+
+ switch (rc) {
+ case 0:
+ HookEvent(ME_SYSTEM_MODULESLOADED, OnModulesLoaded);
+ g_plugin.registerIcon(LPGEN("Database"), iconList, "database");
+ break;
+
+ // there were no suitable driver installed
+ case -1:
+ MessageBoxW(nullptr,
+ CMStringW(FORMAT, TranslateW(tszNoSuitableDriver), ptszFileName),
+ TranslateT("Miranda can't open that profile"), MB_OK | MB_ICONERROR);
+ break;
- // there were no suitable driver installed
- if (rc == -1) {
+ default:
+ if (rc < 0) // smth strange happened, exit silently
+ break;
+
+ if (fileExist(szProfile)) {
+ // file isn't locked, just no driver could open it.
MessageBoxW(nullptr,
- CMStringW(FORMAT, TranslateW(tszNoSuitableDriver), ptszFileName),
- TranslateT("Miranda can't open that profile"), MB_OK | MB_ICONERROR);
+ CMStringW(FORMAT, TranslateW(tszUnknownFormat), ptszFileName),
+ TranslateT("Miranda can't understand that profile"), MB_OK | MB_ICONERROR);
}
- else if (rc > 0) {
- if (fileExist(szProfile)) {
- // file isn't locked, just no driver could open it.
- MessageBoxW(nullptr,
- CMStringW(FORMAT, TranslateW(tszUnknownFormat), ptszFileName),
- TranslateT("Miranda can't understand that profile"), MB_OK | MB_ICONERROR);
- }
- else
- retry = IDRETRY == MessageBoxW(nullptr,
- CMStringW(FORMAT, TranslateW(tszProfileLocked), ptszFileName),
- TranslateT("Miranda can't open that profile"), MB_RETRYCANCEL | MB_ICONERROR);
+ else {
+ CMStringW wszTitle(FORMAT, TranslateW(tszProfileLocked), ptszFileName);
+ if (IDRETRY == MessageBoxW(nullptr, wszTitle, TranslateT("Miranda can't open that profile"), MB_RETRYCANCEL | MB_ICONERROR))
+ goto LBL_Restart;
}
}
- while (retry);
-
- if (rc == 0)
- HookEvent(ME_SYSTEM_MODULESLOADED, OnModulesLoaded);
- g_plugin.registerIcon(LPGEN("Database"), iconList, "database");
return rc;
}
|