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

Lock m_renderMain in Grapher::TryInitializeGraph to avoid race condition #1430

Merged
merged 1 commit into from
Nov 11, 2020
Merged
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
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