Kaydet (Commit) 2a5d8d73 authored tarafından Ashod Nakashian's avatar Ashod Nakashian Kaydeden (comit) Ashod Nakashian

Lok: better logging and warnings

Change-Id: Ia933ae65197893592eeb04cb8a1a617a931ad623
Reviewed-on: https://gerrit.libreoffice.org/31606Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarAshod Nakashian <ashnakash@gmail.com>
üst a8b2e3e9
...@@ -606,6 +606,7 @@ void CallbackFlushHandler::callback(const int type, const char* payload, void* d ...@@ -606,6 +606,7 @@ void CallbackFlushHandler::callback(const int type, const char* payload, void* d
void CallbackFlushHandler::queue(const int type, const char* data) void CallbackFlushHandler::queue(const int type, const char* data)
{ {
std::string payload(data ? data : "(nil)"); std::string payload(data ? data : "(nil)");
//SAL_WARN("lok", "Queue: " << type << " : " << payload);
if (m_bPartTilePainting) if (m_bPartTilePainting)
{ {
// We drop notifications when this is set, except for important ones. // We drop notifications when this is set, except for important ones.
...@@ -622,7 +623,7 @@ void CallbackFlushHandler::queue(const int type, const char* data) ...@@ -622,7 +623,7 @@ void CallbackFlushHandler::queue(const int type, const char* data)
type != LOK_CALLBACK_VIEW_CURSOR_VISIBLE && type != LOK_CALLBACK_VIEW_CURSOR_VISIBLE &&
type != LOK_CALLBACK_TEXT_SELECTION) type != LOK_CALLBACK_TEXT_SELECTION)
{ {
SAL_WARN("lok", "Skipping while painting [" + std::to_string(type) + "]: [" + payload + "]."); SAL_WARN("lok", "Skipping while painting [" << type << "]: [" << payload << "].");
return; return;
} }
...@@ -639,7 +640,7 @@ void CallbackFlushHandler::queue(const int type, const char* data) ...@@ -639,7 +640,7 @@ void CallbackFlushHandler::queue(const int type, const char* data)
// issuing it, instead of the absolute one that we expect. // issuing it, instead of the absolute one that we expect.
// This is temporary however, and, once the control is created and initialized // This is temporary however, and, once the control is created and initialized
// correctly, it eventually emits the correct absolute coordinates. // correctly, it eventually emits the correct absolute coordinates.
SAL_WARN("lok", "Skipping invalid event [" + std::to_string(type) + "]: [" + payload + "]."); SAL_WARN("lok", "Skipping invalid event [" << type << "]: [" << payload << "].");
return; return;
} }
...@@ -670,7 +671,7 @@ void CallbackFlushHandler::queue(const int type, const char* data) ...@@ -670,7 +671,7 @@ void CallbackFlushHandler::queue(const int type, const char* data)
if (pos != m_queue.rend() && pos->second == payload) if (pos != m_queue.rend() && pos->second == payload)
{ {
//SAL_WARN("lok", "Skipping queue duplicate [" + std::to_string(type) + "]: [" + payload + "]."); //SAL_WARN("lok", "Skipping queue duplicate [" << type << + "]: [" << payload << "].");
return; return;
} }
} }
...@@ -719,6 +720,7 @@ void CallbackFlushHandler::queue(const int type, const char* data) ...@@ -719,6 +720,7 @@ void CallbackFlushHandler::queue(const int type, const char* data)
case LOK_CALLBACK_GRAPHIC_SELECTION: case LOK_CALLBACK_GRAPHIC_SELECTION:
case LOK_CALLBACK_INVALIDATE_VISIBLE_CURSOR: case LOK_CALLBACK_INVALIDATE_VISIBLE_CURSOR:
case LOK_CALLBACK_INVALIDATE_TILES: case LOK_CALLBACK_INVALIDATE_TILES:
//SAL_WARN("lok", "Removing dups of [" << type << "]: [" << payload << "].");
removeAll([type] (const queue_type::value_type& elem) { return (elem.first == type); }); removeAll([type] (const queue_type::value_type& elem) { return (elem.first == type); });
break; break;
} }
...@@ -778,7 +780,7 @@ void CallbackFlushHandler::queue(const int type, const char* data) ...@@ -778,7 +780,7 @@ void CallbackFlushHandler::queue(const int type, const char* data)
//SAL_WARN("lok", "New: " << rcNew.toString()); //SAL_WARN("lok", "New: " << rcNew.toString());
if (rcNew.isInfinite()) if (rcNew.isInfinite())
{ {
SAL_WARN("lok", "Have Empty [" << type << "]: [" << payload << "] so removing all."); SAL_WARN("lok", "Have Empty [" << type << "]: [" << payload << "] so removing all with part " << rcNew.m_nPart << ".");
removeAll( removeAll(
[type, &rcNew] (const queue_type::value_type& elem) { [type, &rcNew] (const queue_type::value_type& elem) {
if (elem.first == type) if (elem.first == type)
...@@ -797,6 +799,7 @@ void CallbackFlushHandler::queue(const int type, const char* data) ...@@ -797,6 +799,7 @@ void CallbackFlushHandler::queue(const int type, const char* data)
{ {
const auto rcOrig = rcNew; const auto rcOrig = rcNew;
//SAL_WARN("lok", "Have [" << type << "]: [" << payload << "] so merging overlapping.");
removeAll( removeAll(
[type, &rcNew] (const queue_type::value_type& elem) { [type, &rcNew] (const queue_type::value_type& elem) {
if (elem.first == type) if (elem.first == type)
...@@ -804,14 +807,15 @@ void CallbackFlushHandler::queue(const int type, const char* data) ...@@ -804,14 +807,15 @@ void CallbackFlushHandler::queue(const int type, const char* data)
const RectangleAndPart rcOld = RectangleAndPart::Create(elem.second); const RectangleAndPart rcOld = RectangleAndPart::Create(elem.second);
if (rcOld.m_nPart != rcNew.m_nPart) if (rcOld.m_nPart != rcNew.m_nPart)
return false; return false;
//SAL_WARN("lok", "#" << i << " Old: " << rcOld.toString());
const Rectangle rcOverlap = rcNew.m_aRectangle.GetIntersection(rcOld.m_aRectangle); const Rectangle rcOverlap = rcNew.m_aRectangle.GetIntersection(rcOld.m_aRectangle);
//SAL_WARN("lok", "#" << i << " Overlap: " << rcOverlap.toString());
bool bOverlap = (rcOverlap.GetWidth() > 0 && rcOverlap.GetHeight() > 0); bool bOverlap = (rcOverlap.GetWidth() > 0 && rcOverlap.GetHeight() > 0);
SAL_WARN("lok", "Merging " << rcNew.toString() << " & " << rcOld.toString() << " => " <<
rcOverlap.toString() << " Overlap: " << bOverlap);
if (bOverlap) if (bOverlap)
{ {
//SAL_WARN("lok", rcOld.toString() << " U " << rcNew.toString());
rcNew.m_aRectangle.Union(rcOld.m_aRectangle); rcNew.m_aRectangle.Union(rcOld.m_aRectangle);
SAL_WARN("lok", "Merged: " << rcNew.toString());
} }
return bOverlap; return bOverlap;
} }
...@@ -825,6 +829,12 @@ void CallbackFlushHandler::queue(const int type, const char* data) ...@@ -825,6 +829,12 @@ void CallbackFlushHandler::queue(const int type, const char* data)
if (rcNew.m_aRectangle != rcOrig.m_aRectangle) if (rcNew.m_aRectangle != rcOrig.m_aRectangle)
{ {
SAL_WARN("lok", "Replacing: " << rcOrig.toString() << " by " << rcNew.toString()); SAL_WARN("lok", "Replacing: " << rcOrig.toString() << " by " << rcNew.toString());
if (rcNew.m_aRectangle.GetWidth() < rcOrig.m_aRectangle.GetWidth() ||
rcNew.m_aRectangle.GetHeight() < rcOrig.m_aRectangle.GetHeight())
{
SAL_WARN("lok", "Error: merged rect smaller.");
}
payload = rcNew.toString().getStr(); payload = rcNew.toString().getStr();
} }
} }
...@@ -852,6 +862,7 @@ void CallbackFlushHandler::queue(const int type, const char* data) ...@@ -852,6 +862,7 @@ void CallbackFlushHandler::queue(const int type, const char* data)
} }
m_queue.emplace_back(type, payload); m_queue.emplace_back(type, payload);
SAL_WARN("lok", "Queued [" << type << "]: [" << payload << "] to have " << m_queue.size() << " entries.");
lock.unlock(); lock.unlock();
if (!IsActive()) if (!IsActive())
...@@ -866,6 +877,7 @@ void CallbackFlushHandler::Invoke() ...@@ -866,6 +877,7 @@ void CallbackFlushHandler::Invoke()
{ {
std::unique_lock<std::mutex> lock(m_mutex); std::unique_lock<std::mutex> lock(m_mutex);
//SAL_WARN("lok", "Flushing " << m_queue.size() << " elements.");
for (auto& pair : m_queue) for (auto& pair : m_queue)
{ {
const int type = pair.first; const int type = pair.first;
...@@ -880,7 +892,7 @@ void CallbackFlushHandler::Invoke() ...@@ -880,7 +892,7 @@ void CallbackFlushHandler::Invoke()
// If the state didn't change, it's safe to ignore. // If the state didn't change, it's safe to ignore.
if (stateIt->second == payload) if (stateIt->second == payload)
{ {
//SAL_WARN("lok", "Skipping duplicate [" + std::to_string(type) + "]: [" + payload + "]."); //SAL_WARN("lok", "Skipping duplicate [" << type << "]: [" << payload << "].");
continue; continue;
} }
...@@ -899,24 +911,26 @@ void CallbackFlushHandler::Invoke() ...@@ -899,24 +911,26 @@ void CallbackFlushHandler::Invoke()
// If the state didn't change, it's safe to ignore. // If the state didn't change, it's safe to ignore.
if (stateIt->second == payload) if (stateIt->second == payload)
{ {
//SAL_WARN("lok", "Skipping view duplicate [" + std::to_string(type) + "," + std::to_string(viewId) + "]: [" + payload + "]."); //SAL_WARN("lok", "Skipping view duplicate [" << type << ',' << viewId << "]: [" << payload << "].");
continue; continue;
} }
stateIt->second = payload; stateIt->second = payload;
//SAL_WARN("lok", "Replacing an element in view states [" + std::to_string(type) + "," + std::to_string(viewId) + "]: [" + payload + "]."); //SAL_WARN("lok", "Replacing an element in view states [" << type << ',' << viewId << "]: [" << payload << "].");
} }
else else
{ {
states.emplace(type, payload); states.emplace(type, payload);
//SAL_WARN("lok", "Inserted a new element in view states: [" + std::to_string(type) + "," + std::to_string(viewId) + "]: [" + payload + "]"); //SAL_WARN("lok", "Inserted a new element in view states: [" << type << ',' << viewId << "]: [" << payload << "]");
} }
} }
} }
//SAL_WARN("lok", "Emitting [" << type << "]: [" << payload << "].");
m_pCallback(type, payload.c_str(), m_pData); m_pCallback(type, payload.c_str(), m_pData);
} }
//SAL_WARN("lok", "Done flushing.");
m_queue.clear(); m_queue.clear();
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment