Skip to content

Commit

Permalink
Compare again if all panes reload as a result of clicking the link
Browse files Browse the repository at this point in the history
  • Loading branch information
sdottaka committed Dec 27, 2023
1 parent 4ef5283 commit 691e280
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/WinWebDiffLib/WebDiffWindow.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,13 @@ class CWebDiffWindow : public IWebDiffWindow
if (m_hWnd)
{
Close();
std::shared_ptr<int> counter(new int{ nPanes });
for (int i = 0; i < nPanes; ++i)
{
std::wstring userDataFolder = GetUserDataFolderPath(i);
ComPtr<IWebDiffCallback> callback2(callback);
hr = m_webWindow[i].Create(m_hInstance, m_hWnd, urls[i], userDataFolder.c_str(),
m_size, m_fitToWindow, m_zoom, m_userAgent, nullptr,
[this, i, counter, callback2](WebDiffEvent::EVENT_TYPE event, IUnknown* sender, IUnknown* args)
[this, i, callback2](WebDiffEvent::EVENT_TYPE event, IUnknown* sender, IUnknown* args)
{
WebDiffEvent ev{};
ev.type = event;
Expand Down Expand Up @@ -122,6 +121,8 @@ class CWebDiffWindow : public IWebDiffWindow
}
else if (event == WebDiffEvent::NavigationStarting)
{
m_documentLoaded[ev.pane] = false;
m_urlChanged[ev.pane] = true;
SetCompareState(NOT_COMPARED);
}
else if (event == WebDiffEvent::FrameNavigationStarting)
Expand All @@ -130,9 +131,13 @@ class CWebDiffWindow : public IWebDiffWindow
else if (event == WebDiffEvent::NavigationCompleted)
{
addEventListener(sender, ev.pane, nullptr);
*counter = *counter - 1;
if (*counter == 0)
m_documentLoaded[ev.pane] = true;
if ((std::count(m_documentLoaded, m_documentLoaded + m_nPanes, true) == m_nPanes) &&
(std::count(m_urlChanged, m_urlChanged + m_nPanes, true) == m_nPanes))
{
std::fill_n(m_urlChanged, m_nPanes, false);
Recompare(callback2.Get());
}
}
else if (event == WebDiffEvent::FrameNavigationCompleted)
{
Expand Down Expand Up @@ -1477,6 +1482,8 @@ class CWebDiffWindow : public IWebDiffWindow
bool m_bShowDifferences = true;
bool m_bShowWordDifferences = true;
bool m_bSynchronizeEvents = true;
bool m_documentLoaded[3] = { false, false, false };
bool m_urlChanged[3] = { false, false, false };
unsigned m_eventSyncFlags = EVENT_SCROLL | EVENT_CLICK | EVENT_INPUT | EVENT_GOBACKFORWARD;
CompareState m_compareState = NOT_COMPARED;
IWebDiffWindow::ColorSettings m_colorSettings = {
Expand Down

0 comments on commit 691e280

Please sign in to comment.