mirror of https://github.com/odrling/Aegisub
Eliminate some gratuitous exceptions
This commit is contained in:
parent
0416188235
commit
879788fe83
|
@ -98,12 +98,9 @@ public:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
throw UnknownCharset("Unknown character set.");
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (list.empty() && (mInputState == eHighbyte))
|
|
||||||
throw UnknownCharset("Unknown character set.");
|
|
||||||
|
|
||||||
typedef std::pair<float, std::string> const& result;
|
typedef std::pair<float, std::string> const& result;
|
||||||
sort(begin(list), end(list), [](result lft, result rgt) { return lft.first > rgt.first; });
|
sort(begin(list), end(list), [](result lft, result rgt) { return lft.first > rgt.first; });
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,9 +26,6 @@ namespace agi {
|
||||||
/// Character set conversion and detection.
|
/// Character set conversion and detection.
|
||||||
namespace charset {
|
namespace charset {
|
||||||
|
|
||||||
DEFINE_EXCEPTION(CharsetError, agi::Exception);
|
|
||||||
DEFINE_EXCEPTION(UnknownCharset, CharsetError);
|
|
||||||
|
|
||||||
/// List of detected encodings.
|
/// List of detected encodings.
|
||||||
typedef std::vector<std::pair<float, std::string>> CharsetListDetected;
|
typedef std::vector<std::pair<float, std::string>> CharsetListDetected;
|
||||||
|
|
||||||
|
|
|
@ -124,14 +124,14 @@ struct COMInitialization {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @brief Initialise the COM library as single-threaded apartment if isn't already inited by us
|
/// @brief Initialise the COM library as single-threaded apartment if isn't already inited by us
|
||||||
void Init()
|
bool Init()
|
||||||
{
|
{
|
||||||
if (!inited)
|
if (!inited)
|
||||||
{
|
{
|
||||||
if (FAILED(CoInitialize(nullptr)))
|
if (SUCCEEDED(CoInitialize(nullptr)))
|
||||||
throw std::exception();
|
inited = true;
|
||||||
inited = true;
|
|
||||||
}
|
}
|
||||||
|
return inited;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -302,8 +302,7 @@ unsigned int __stdcall DirectSoundPlayer2Thread::ThreadProc(void *parameter)
|
||||||
void DirectSoundPlayer2Thread::Run()
|
void DirectSoundPlayer2Thread::Run()
|
||||||
{
|
{
|
||||||
COMInitialization COM_library;
|
COMInitialization COM_library;
|
||||||
try { COM_library.Init(); }
|
if (!COM_library.Init())
|
||||||
catch (std::exception e)
|
|
||||||
REPORT_ERROR("Could not initialise COM")
|
REPORT_ERROR("Could not initialise COM")
|
||||||
|
|
||||||
// Create DirectSound object
|
// Create DirectSound object
|
||||||
|
|
|
@ -49,13 +49,7 @@
|
||||||
namespace CharSetDetect {
|
namespace CharSetDetect {
|
||||||
|
|
||||||
std::string GetEncoding(agi::fs::path const& filename) {
|
std::string GetEncoding(agi::fs::path const& filename) {
|
||||||
agi::charset::CharsetListDetected list;
|
auto list = agi::charset::DetectAll(filename);
|
||||||
|
|
||||||
try {
|
|
||||||
list = agi::charset::DetectAll(filename);
|
|
||||||
} catch (const agi::charset::UnknownCharset&) {
|
|
||||||
// will be set to the full list of charsets below
|
|
||||||
}
|
|
||||||
|
|
||||||
if (list.size() == 1) {
|
if (list.size() == 1) {
|
||||||
auto charset = list.begin();
|
auto charset = list.begin();
|
||||||
|
|
Loading…
Reference in New Issue