Skip to content

Commit

Permalink
Lock m_renderMain in Grapher::TryInitializeGraph to avoid modifying m…
Browse files Browse the repository at this point in the history
…_graph during rendering (microsoft#1430)
  • Loading branch information
xuhongxu96 authored Nov 11, 2020
1 parent 483dacb commit 296cf03
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/GraphControl/Control/Grapher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ namespace GraphControl
{
if (m_graph != nullptr && m_renderMain != nullptr)
{
if(auto renderer = m_graph->GetRenderer())
if (auto renderer = m_graph->GetRenderer())
{
HRESULT hr;

Expand Down Expand Up @@ -281,7 +281,7 @@ namespace GraphControl

void Grapher::PlotGraph(bool keepCurrentView)
{
TryPlotGraph(keepCurrentView,false);
TryPlotGraph(keepCurrentView, false);
}

task<void> Grapher::TryPlotGraph(bool keepCurrentView, bool shouldRetry)
Expand Down Expand Up @@ -587,7 +587,7 @@ namespace GraphControl
auto lineColor = eq->LineColor;
graphColors.emplace_back(lineColor.R, lineColor.G, lineColor.B, lineColor.A);

if (eq->GraphedEquation)
if (eq->GraphedEquation)
{
if (!eq->HasGraphError && eq->IsSelected)
{
Expand Down Expand Up @@ -1085,7 +1085,6 @@ void Grapher::OnGraphBackgroundPropertyChanged(Windows::UI::Color /*oldValue*/,
}
}


void Grapher::OnGridLinesColorPropertyChanged(Windows::UI::Color /*oldValue*/, Windows::UI::Color newValue)
{
if (m_renderMain != nullptr && m_graph != nullptr)
Expand All @@ -1106,13 +1105,14 @@ void Grapher::OnLineWidthPropertyChanged(double oldValue, double newValue)
m_renderMain->SetPointRadius(LineWidth + 1);
m_renderMain->RunRenderPass();

TraceLogger::GetInstance()->LogLineWidthChanged();
TraceLogger::GetInstance()->LogLineWidthChanged();
}
}
}

optional<vector<shared_ptr<Graphing::IEquation>>> Grapher::TryInitializeGraph(bool keepCurrentView, const IExpression* graphingExp)
{
critical_section::scoped_lock lock(m_renderMain->GetCriticalSection());
if (keepCurrentView || IsKeepCurrentView)
{
auto renderer = m_graph->GetRenderer();
Expand Down

0 comments on commit 296cf03

Please sign in to comment.