Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: if IPC serialization exception happens, client app would crash cause no exception handler provided. #1304

Merged
merged 1 commit into from
Jun 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion WeaselIPC/ContextUpdater.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ void ContextUpdater::_StoreCand(Deserializer::KeyType k,
std::wstringstream ss(value);
boost::archive::text_wiarchive ia(ss);

ia >> cinfo;
TryDeserialize(ia, cinfo);

for (auto& cand : cinfo.candies)
cand.str = unescape_string(cand.str);
Expand Down
10 changes: 10 additions & 0 deletions WeaselIPC/Deserializer.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,16 @@

namespace weasel {

template <typename T>
void TryDeserialize(boost::archive::text_wiarchive& ia, T& t) {
try {
ia >> t;
} catch (const boost::archive::archive_exception& e) {
const std::string msg =
std::string("boost::archive::archive_exception: ") + e.what();
MessageBoxA(NULL, msg.c_str(), "IPC exception", MB_OK | MB_ICONERROR);
}
}
class Deserializer {
public:
typedef std::vector<std::wstring> KeyType;
Expand Down
2 changes: 1 addition & 1 deletion WeaselIPC/Styler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ void Styler::Store(weasel::Deserializer::KeyType const& key,
std::wstringstream ss(value);
boost::archive::text_wiarchive ia(ss);

ia >> sty;
TryDeserialize(ia, sty);
}

weasel::Deserializer::Ptr Styler::Create(weasel::ResponseParser* pTarget) {
Expand Down