C26494, uninitalized local variables
This commit is contained in:
parent
81ab5803aa
commit
d5d7cf420d
|
@ -366,7 +366,7 @@ using namespace Microsoft::Console::Render;
|
||||||
// This run is solid-color outlines, either from non-color
|
// This run is solid-color outlines, either from non-color
|
||||||
// glyphs or from COLR glyph layers. Use Direct2D to draw them.
|
// glyphs or from COLR glyph layers. Use Direct2D to draw them.
|
||||||
|
|
||||||
ID2D1Brush* layerBrush;
|
ID2D1Brush* layerBrush = nullptr;
|
||||||
// The rule is "if 0xffff, use current brush." See:
|
// The rule is "if 0xffff, use current brush." See:
|
||||||
// https://docs.microsoft.com/en-us/windows/desktop/api/dwrite_2/ns-dwrite_2-dwrite_color_glyph_run
|
// https://docs.microsoft.com/en-us/windows/desktop/api/dwrite_2/ns-dwrite_2-dwrite_color_glyph_run
|
||||||
if (colorRun->paletteIndex == 0xFFFF)
|
if (colorRun->paletteIndex == 0xFFFF)
|
||||||
|
|
|
@ -162,7 +162,7 @@ void UiaTextRangeBase::Initialize(_In_ const UiaPoint point)
|
||||||
// get row that point resides in
|
// get row that point resides in
|
||||||
const RECT windowRect = _getTerminalRect();
|
const RECT windowRect = _getTerminalRect();
|
||||||
const SMALL_RECT viewport = _pData->GetViewport().ToInclusive();
|
const SMALL_RECT viewport = _pData->GetViewport().ToInclusive();
|
||||||
ScreenInfoRow row;
|
ScreenInfoRow row = 0;
|
||||||
if (clientPoint.y <= windowRect.top)
|
if (clientPoint.y <= windowRect.top)
|
||||||
{
|
{
|
||||||
row = viewport.Top;
|
row = viewport.Top;
|
||||||
|
@ -184,7 +184,7 @@ void UiaTextRangeBase::Initialize(_In_ const UiaPoint point)
|
||||||
_degenerate = true;
|
_degenerate = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
UiaTextRangeBase::UiaTextRangeBase(const UiaTextRangeBase& a) noexcept:
|
UiaTextRangeBase::UiaTextRangeBase(const UiaTextRangeBase& a) noexcept :
|
||||||
_cRefs{ 1 },
|
_cRefs{ 1 },
|
||||||
_pProvider{ a._pProvider },
|
_pProvider{ a._pProvider },
|
||||||
_start{ a._start },
|
_start{ a._start },
|
||||||
|
@ -288,7 +288,7 @@ IFACEMETHODIMP UiaTextRangeBase::QueryInterface(_In_ REFIID riid, _COM_Outptr_re
|
||||||
IFACEMETHODIMP UiaTextRangeBase::Compare(_In_opt_ ITextRangeProvider* pRange, _Out_ BOOL* pRetVal) noexcept
|
IFACEMETHODIMP UiaTextRangeBase::Compare(_In_opt_ ITextRangeProvider* pRange, _Out_ BOOL* pRetVal) noexcept
|
||||||
{
|
{
|
||||||
_pData->LockConsole();
|
_pData->LockConsole();
|
||||||
auto Unlock = wil::scope_exit([&]() noexcept{
|
auto Unlock = wil::scope_exit([&]() noexcept {
|
||||||
_pData->UnlockConsole();
|
_pData->UnlockConsole();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -327,26 +327,10 @@ IFACEMETHODIMP UiaTextRangeBase::CompareEndpoints(_In_ TextPatternRangeEndpoint
|
||||||
}
|
}
|
||||||
|
|
||||||
// get endpoint value that we're comparing to
|
// get endpoint value that we're comparing to
|
||||||
Endpoint theirValue;
|
const Endpoint theirValue = targetEndpoint == TextPatternRangeEndpoint::TextPatternRangeEndpoint_Start ? range->GetStart() : range->GetEnd() + 1;
|
||||||
if (targetEndpoint == TextPatternRangeEndpoint::TextPatternRangeEndpoint_Start)
|
|
||||||
{
|
|
||||||
theirValue = range->GetStart();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
theirValue = range->GetEnd() + 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// get the values of our endpoint
|
// get the values of our endpoint
|
||||||
Endpoint ourValue;
|
const Endpoint ourValue = endpoint == TextPatternRangeEndpoint::TextPatternRangeEndpoint_Start ? _start : _end + 1;
|
||||||
if (endpoint == TextPatternRangeEndpoint::TextPatternRangeEndpoint_Start)
|
|
||||||
{
|
|
||||||
ourValue = _start;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ourValue = _end + 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// compare them
|
// compare them
|
||||||
*pRetVal = std::clamp(static_cast<int>(ourValue) - static_cast<int>(theirValue), -1, 1);
|
*pRetVal = std::clamp(static_cast<int>(ourValue) - static_cast<int>(theirValue), -1, 1);
|
||||||
|
@ -481,7 +465,7 @@ IFACEMETHODIMP UiaTextRangeBase::GetBoundingRectangles(_Outptr_result_maybenull_
|
||||||
{
|
{
|
||||||
return E_OUTOFMEMORY;
|
return E_OUTOFMEMORY;
|
||||||
}
|
}
|
||||||
HRESULT hr;
|
HRESULT hr = E_UNEXPECTED;
|
||||||
for (LONG i = 0; i < gsl::narrow<LONG>(coords.size()); ++i)
|
for (LONG i = 0; i < gsl::narrow<LONG>(coords.size()); ++i)
|
||||||
{
|
{
|
||||||
hr = SafeArrayPutElement(*ppRetVal, &i, &coords.at(i));
|
hr = SafeArrayPutElement(*ppRetVal, &i, &coords.at(i));
|
||||||
|
@ -549,7 +533,7 @@ IFACEMETHODIMP UiaTextRangeBase::GetText(_In_ int maxLength, _Out_ BSTR* pRetVal
|
||||||
OutputDebugString(ss.str().c_str());
|
OutputDebugString(ss.str().c_str());
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
ScreenInfoRow currentScreenInfoRow;
|
ScreenInfoRow currentScreenInfoRow = 0;
|
||||||
for (unsigned int i = 0; i < totalRowsInRange; ++i)
|
for (unsigned int i = 0; i < totalRowsInRange; ++i)
|
||||||
{
|
{
|
||||||
currentScreenInfoRow = startScreenInfoRow + i;
|
currentScreenInfoRow = startScreenInfoRow + i;
|
||||||
|
@ -786,7 +770,7 @@ IFACEMETHODIMP UiaTextRangeBase::MoveEndpointByRange(_In_ TextPatternRangeEndpoi
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// get the value that we're updating to
|
// get the value that we're updating to
|
||||||
Endpoint targetEndpointValue;
|
Endpoint targetEndpointValue = 0;
|
||||||
if (targetEndpoint == TextPatternRangeEndpoint::TextPatternRangeEndpoint_Start)
|
if (targetEndpoint == TextPatternRangeEndpoint::TextPatternRangeEndpoint_Start)
|
||||||
{
|
{
|
||||||
targetEndpointValue = range->GetStart();
|
targetEndpointValue = range->GetStart();
|
||||||
|
@ -813,23 +797,15 @@ IFACEMETHODIMP UiaTextRangeBase::MoveEndpointByRange(_In_ TextPatternRangeEndpoi
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// convert then endpoints to screen info rows/columns
|
|
||||||
ScreenInfoRow startScreenInfoRow;
|
|
||||||
Column startColumn;
|
|
||||||
ScreenInfoRow endScreenInfoRow;
|
|
||||||
Column endColumn;
|
|
||||||
ScreenInfoRow targetScreenInfoRow;
|
|
||||||
Column targetColumn;
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
startScreenInfoRow = _endpointToScreenInfoRow(_pData, _start);
|
// convert then endpoints to screen info rows/columns
|
||||||
startColumn = _endpointToColumn(_pData, _start);
|
const auto startScreenInfoRow = _endpointToScreenInfoRow(_pData, _start);
|
||||||
endScreenInfoRow = _endpointToScreenInfoRow(_pData, _end);
|
const auto startColumn = _endpointToColumn(_pData, _start);
|
||||||
endColumn = _endpointToColumn(_pData, _end);
|
const auto endScreenInfoRow = _endpointToScreenInfoRow(_pData, _end);
|
||||||
targetScreenInfoRow = _endpointToScreenInfoRow(_pData, targetEndpointValue);
|
const auto endColumn = _endpointToColumn(_pData, _end);
|
||||||
targetColumn = _endpointToColumn(_pData, targetEndpointValue);
|
const auto targetScreenInfoRow = _endpointToScreenInfoRow(_pData, targetEndpointValue);
|
||||||
}
|
const auto targetColumn = _endpointToColumn(_pData, targetEndpointValue);
|
||||||
CATCH_RETURN();
|
|
||||||
|
|
||||||
// set endpoint value and check for crossed endpoints
|
// set endpoint value and check for crossed endpoints
|
||||||
bool crossedEndpoints = false;
|
bool crossedEndpoints = false;
|
||||||
|
@ -854,6 +830,8 @@ IFACEMETHODIMP UiaTextRangeBase::MoveEndpointByRange(_In_ TextPatternRangeEndpoi
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_degenerate = crossedEndpoints;
|
_degenerate = crossedEndpoints;
|
||||||
|
}
|
||||||
|
CATCH_RETURN();
|
||||||
|
|
||||||
// TODO GitHub #1914: Re-attach Tracing to UIA Tree
|
// TODO GitHub #1914: Re-attach Tracing to UIA Tree
|
||||||
//Tracing::s_TraceUia(this, ApiCall::MoveEndpointByRange, &apiMsg);
|
//Tracing::s_TraceUia(this, ApiCall::MoveEndpointByRange, &apiMsg);
|
||||||
|
@ -874,14 +852,10 @@ IFACEMETHODIMP UiaTextRangeBase::Select()
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
COORD coordStart;
|
const COORD coordStart{ gsl::narrow<SHORT>(_endpointToColumn(_pData, _start)),
|
||||||
COORD coordEnd;
|
gsl::narrow<SHORT>(_endpointToScreenInfoRow(_pData, _start)) };
|
||||||
|
const COORD coordEnd{ gsl::narrow<SHORT>(_endpointToColumn(_pData, _end)),
|
||||||
coordStart.X = gsl::narrow<SHORT>(_endpointToColumn(_pData, _start));
|
gsl::narrow<SHORT>(_endpointToScreenInfoRow(_pData, _end)) };
|
||||||
coordStart.Y = gsl::narrow<SHORT>(_endpointToScreenInfoRow(_pData, _start));
|
|
||||||
|
|
||||||
coordEnd.X = gsl::narrow<SHORT>(_endpointToColumn(_pData, _end));
|
|
||||||
coordEnd.Y = gsl::narrow<SHORT>(_endpointToScreenInfoRow(_pData, _end));
|
|
||||||
|
|
||||||
_pData->SelectNewRegion(coordStart, coordEnd);
|
_pData->SelectNewRegion(coordStart, coordEnd);
|
||||||
}
|
}
|
||||||
|
@ -914,26 +888,17 @@ IFACEMETHODIMP UiaTextRangeBase::ScrollIntoView(_In_ BOOL alignToTop)
|
||||||
_pData->UnlockConsole();
|
_pData->UnlockConsole();
|
||||||
});
|
});
|
||||||
|
|
||||||
SMALL_RECT oldViewport;
|
|
||||||
unsigned int viewportHeight;
|
|
||||||
// range rows
|
|
||||||
ScreenInfoRow startScreenInfoRow;
|
|
||||||
ScreenInfoRow endScreenInfoRow;
|
|
||||||
// screen buffer rows
|
|
||||||
ScreenInfoRow topRow;
|
|
||||||
ScreenInfoRow bottomRow;
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
oldViewport = _pData->GetViewport().ToInclusive();
|
|
||||||
viewportHeight = _getViewportHeight(oldViewport);
|
const auto oldViewport = _pData->GetViewport().ToInclusive();
|
||||||
|
const auto viewportHeight = _getViewportHeight(oldViewport);
|
||||||
// range rows
|
// range rows
|
||||||
startScreenInfoRow = _endpointToScreenInfoRow(_pData, _start);
|
const auto startScreenInfoRow = _endpointToScreenInfoRow(_pData, _start);
|
||||||
endScreenInfoRow = _endpointToScreenInfoRow(_pData, _end);
|
const auto endScreenInfoRow = _endpointToScreenInfoRow(_pData, _end);
|
||||||
// screen buffer rows
|
// screen buffer rows
|
||||||
topRow = _getFirstScreenInfoRowIndex();
|
const auto topRow = _getFirstScreenInfoRowIndex();
|
||||||
bottomRow = _getLastScreenInfoRowIndex(_pData);
|
const auto bottomRow = _getLastScreenInfoRowIndex(_pData);
|
||||||
}
|
|
||||||
CATCH_RETURN();
|
|
||||||
|
|
||||||
SMALL_RECT newViewport = oldViewport;
|
SMALL_RECT newViewport = oldViewport;
|
||||||
|
|
||||||
|
@ -979,18 +944,15 @@ IFACEMETHODIMP UiaTextRangeBase::ScrollIntoView(_In_ BOOL alignToTop)
|
||||||
FAIL_FAST_IF(!(newViewport.Bottom <= gsl::narrow<SHORT>(bottomRow)));
|
FAIL_FAST_IF(!(newViewport.Bottom <= gsl::narrow<SHORT>(bottomRow)));
|
||||||
FAIL_FAST_IF(!(_getViewportHeight(oldViewport) == _getViewportHeight(newViewport)));
|
FAIL_FAST_IF(!(_getViewportHeight(oldViewport) == _getViewportHeight(newViewport)));
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
_ChangeViewport(newViewport);
|
_ChangeViewport(newViewport);
|
||||||
}
|
|
||||||
CATCH_RETURN();
|
|
||||||
|
|
||||||
// TODO GitHub #1914: Re-attach Tracing to UIA Tree
|
// TODO GitHub #1914: Re-attach Tracing to UIA Tree
|
||||||
// tracing
|
// tracing
|
||||||
/*ApiMsgScrollIntoView apiMsg;
|
/*ApiMsgScrollIntoView apiMsg;
|
||||||
apiMsg.AlignToTop = !!alignToTop;
|
apiMsg.AlignToTop = !!alignToTop;
|
||||||
Tracing::s_TraceUia(this, ApiCall::ScrollIntoView, &apiMsg);*/
|
Tracing::s_TraceUia(this, ApiCall::ScrollIntoView, &apiMsg);*/
|
||||||
|
}
|
||||||
|
CATCH_RETURN();
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1278,8 +1240,8 @@ void UiaTextRangeBase::_addScreenInfoRowBoundaries(IUiaData* pData,
|
||||||
{
|
{
|
||||||
const COORD currentFontSize = _getScreenFontSize();
|
const COORD currentFontSize = _getScreenFontSize();
|
||||||
|
|
||||||
POINT topLeft;
|
POINT topLeft{ 0 };
|
||||||
POINT bottomRight;
|
POINT bottomRight{ 0 };
|
||||||
|
|
||||||
if (_endpointToScreenInfoRow(pData, _start) == screenInfoRow)
|
if (_endpointToScreenInfoRow(pData, _start) == screenInfoRow)
|
||||||
{
|
{
|
||||||
|
@ -1653,8 +1615,8 @@ UiaTextRangeBase::_moveEndpointByUnitCharacterForward(IUiaData* pData,
|
||||||
THROW_HR_IF_NULL(E_INVALIDARG, pAmountMoved);
|
THROW_HR_IF_NULL(E_INVALIDARG, pAmountMoved);
|
||||||
*pAmountMoved = 0;
|
*pAmountMoved = 0;
|
||||||
const int count = moveCount;
|
const int count = moveCount;
|
||||||
ScreenInfoRow currentScreenInfoRow;
|
ScreenInfoRow currentScreenInfoRow = 0;
|
||||||
Column currentColumn;
|
Column currentColumn = 0;
|
||||||
|
|
||||||
// set current location vars
|
// set current location vars
|
||||||
if (endpoint == TextPatternRangeEndpoint::TextPatternRangeEndpoint_Start)
|
if (endpoint == TextPatternRangeEndpoint::TextPatternRangeEndpoint_Start)
|
||||||
|
@ -1744,8 +1706,8 @@ UiaTextRangeBase::_moveEndpointByUnitCharacterBackward(IUiaData* pData,
|
||||||
THROW_HR_IF_NULL(E_INVALIDARG, pAmountMoved);
|
THROW_HR_IF_NULL(E_INVALIDARG, pAmountMoved);
|
||||||
*pAmountMoved = 0;
|
*pAmountMoved = 0;
|
||||||
const int count = moveCount;
|
const int count = moveCount;
|
||||||
ScreenInfoRow currentScreenInfoRow;
|
ScreenInfoRow currentScreenInfoRow = 0;
|
||||||
Column currentColumn;
|
Column currentColumn = 0;
|
||||||
|
|
||||||
// set current location vars
|
// set current location vars
|
||||||
if (endpoint == TextPatternRangeEndpoint::TextPatternRangeEndpoint_Start)
|
if (endpoint == TextPatternRangeEndpoint::TextPatternRangeEndpoint_Start)
|
||||||
|
@ -1845,8 +1807,8 @@ std::tuple<Endpoint, Endpoint, bool> UiaTextRangeBase::_moveEndpointByUnitLine(I
|
||||||
THROW_HR_IF(E_INVALIDARG, pAmountMoved == nullptr);
|
THROW_HR_IF(E_INVALIDARG, pAmountMoved == nullptr);
|
||||||
*pAmountMoved = 0;
|
*pAmountMoved = 0;
|
||||||
int count = moveCount;
|
int count = moveCount;
|
||||||
ScreenInfoRow currentScreenInfoRow;
|
ScreenInfoRow currentScreenInfoRow = 0;
|
||||||
Column currentColumn;
|
Column currentColumn = 0;
|
||||||
bool forceDegenerate = false;
|
bool forceDegenerate = false;
|
||||||
Endpoint start = _screenInfoRowToEndpoint(pData, moveState.StartScreenInfoRow) + moveState.StartColumn;
|
Endpoint start = _screenInfoRowToEndpoint(pData, moveState.StartScreenInfoRow) + moveState.StartColumn;
|
||||||
Endpoint end = _screenInfoRowToEndpoint(pData, moveState.EndScreenInfoRow) + moveState.EndColumn;
|
Endpoint end = _screenInfoRowToEndpoint(pData, moveState.EndScreenInfoRow) + moveState.EndColumn;
|
||||||
|
@ -2005,8 +1967,8 @@ std::tuple<Endpoint, Endpoint, bool> UiaTextRangeBase::_moveEndpointByUnitDocume
|
||||||
THROW_HR_IF(E_INVALIDARG, pAmountMoved == nullptr);
|
THROW_HR_IF(E_INVALIDARG, pAmountMoved == nullptr);
|
||||||
*pAmountMoved = 0;
|
*pAmountMoved = 0;
|
||||||
|
|
||||||
Endpoint start;
|
Endpoint start = 0;
|
||||||
Endpoint end;
|
Endpoint end = 0;
|
||||||
bool degenerate = false;
|
bool degenerate = false;
|
||||||
if (endpoint == TextPatternRangeEndpoint::TextPatternRangeEndpoint_Start)
|
if (endpoint == TextPatternRangeEndpoint::TextPatternRangeEndpoint_Start)
|
||||||
{
|
{
|
||||||
|
|
|
@ -450,7 +450,7 @@ bool Viewport::WalkInBoundsCircular(COORD& pos, const WalkDir dir) const noexcep
|
||||||
// if using this same viewport with the `WalkInBounds` methods.
|
// if using this same viewport with the `WalkInBounds` methods.
|
||||||
COORD Viewport::GetWalkOrigin(const WalkDir dir) const noexcept
|
COORD Viewport::GetWalkOrigin(const WalkDir dir) const noexcept
|
||||||
{
|
{
|
||||||
COORD origin;
|
COORD origin{ 0 };
|
||||||
origin.X = dir.x == XWalk::LeftToRight ? Left() : RightInclusive();
|
origin.X = dir.x == XWalk::LeftToRight ? Left() : RightInclusive();
|
||||||
origin.Y = dir.y == YWalk::TopToBottom ? Top() : BottomInclusive();
|
origin.Y = dir.y == YWalk::TopToBottom ? Top() : BottomInclusive();
|
||||||
return origin;
|
return origin;
|
||||||
|
|
Loading…
Reference in a new issue