Skip to content
This repository has been archived by the owner on Dec 11, 2021. It is now read-only.

Commit

Permalink
Add a log output to help debug, improve code style
Browse files Browse the repository at this point in the history
  • Loading branch information
SpriteOvO committed Feb 23, 2021
1 parent 752328a commit 9051fe1
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions Source/IAntiRevoke.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,7 @@ void IAntiRevoke::ProcessBlockedMessages()
// vvvvvvvvvvvvvvvvvvvv TODO: This is a workaround, try to hook HistoryMessage's destructor to improve.
if (pTimeText == NULL ||
pTimeText->IsEmpty() || // This message isn't the current channel or group.
pTimeText->Find(_MarkData.Content) != std::wstring::npos // This message is marked.
)
pTimeText->Find(_MarkData.Content) != std::wstring::npos /* This message is marked. */)
{
return;
}
Expand Down Expand Up @@ -308,6 +307,8 @@ void IAntiRevoke::OnFree(void *Block)

void IAntiRevoke::OnDestroyMessage(History *pHistory, HistoryMessage* pMessage)
{
auto &Logger = ILogger::GetInstance();

Safe::TryExcept(
[&]()
{
Expand All @@ -320,16 +321,19 @@ void IAntiRevoke::OnDestroyMessage(History *pHistory, HistoryMessage* pMessage)

QtString *pTimeText = pMessage->GetTimeText();
if (!pTimeText->IsValidTime()) {
ILogger::GetInstance().TraceWarn("A bad TimeText. Address: [" + Text::Format("0x%x", pMessage) + "]");
Logger.TraceWarn("A bad TimeText. Address: [" + Text::Format("0x%x", pMessage) + "]");
return;
}
#if defined _DEBUG
Logger.TraceInfo("Caught a deleted meesage. Address: [" + Text::Format("0x%x", pMessage) + "]");
#endif

std::lock_guard<std::mutex> Lock(_Mutex);
_BlockedMessages.insert(pMessage);

}, [](ULONG ExceptionCode)
},
[&](ULONG ExceptionCode)
{
ILogger::GetInstance().TraceWarn("Function: [" __FUNCTION__ "] An exception was caught. Code: [" + Text::Format("0x%x", ExceptionCode) + "]");
Logger.TraceWarn("Function: [" __FUNCTION__ "] An exception was caught. Code: [" + Text::Format("0x%x", ExceptionCode) + "]");
}
);
}
Expand Down

0 comments on commit 9051fe1

Please sign in to comment.