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
|
||||
// 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:
|
||||
// https://docs.microsoft.com/en-us/windows/desktop/api/dwrite_2/ns-dwrite_2-dwrite_color_glyph_run
|
||||
if (colorRun->paletteIndex == 0xFFFF)
|
||||
|
|
|
@ -162,7 +162,7 @@ void UiaTextRangeBase::Initialize(_In_ const UiaPoint point)
|
|||
// get row that point resides in
|
||||
const RECT windowRect = _getTerminalRect();
|
||||
const SMALL_RECT viewport = _pData->GetViewport().ToInclusive();
|
||||
ScreenInfoRow row;
|
||||
ScreenInfoRow row = 0;
|
||||
if (clientPoint.y <= windowRect.top)
|
||||
{
|
||||
row = viewport.Top;
|
||||
|
@ -184,7 +184,7 @@ void UiaTextRangeBase::Initialize(_In_ const UiaPoint point)
|
|||
_degenerate = true;
|
||||
}
|
||||
|
||||
UiaTextRangeBase::UiaTextRangeBase(const UiaTextRangeBase& a) noexcept:
|
||||
UiaTextRangeBase::UiaTextRangeBase(const UiaTextRangeBase& a) noexcept :
|
||||
_cRefs{ 1 },
|
||||
_pProvider{ a._pProvider },
|
||||
_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
|
||||
{
|
||||
_pData->LockConsole();
|
||||
auto Unlock = wil::scope_exit([&]() noexcept{
|
||||
auto Unlock = wil::scope_exit([&]() noexcept {
|
||||
_pData->UnlockConsole();
|
||||
});
|
||||
|
||||
|
@ -327,26 +327,10 @@ IFACEMETHODIMP UiaTextRangeBase::CompareEndpoints(_In_ TextPatternRangeEndpoint
|
|||
}
|
||||
|
||||
// get endpoint value that we're comparing to
|
||||
Endpoint theirValue;
|
||||
if (targetEndpoint == TextPatternRangeEndpoint::TextPatternRangeEndpoint_Start)
|
||||
{
|
||||
theirValue = range->GetStart();
|
||||
}
|
||||
else
|
||||
{
|
||||
theirValue = range->GetEnd() + 1;
|
||||
}
|
||||
const Endpoint theirValue = targetEndpoint == TextPatternRangeEndpoint::TextPatternRangeEndpoint_Start ? range->GetStart() : range->GetEnd() + 1;
|
||||
|
||||
// get the values of our endpoint
|
||||
Endpoint ourValue;
|
||||
if (endpoint == TextPatternRangeEndpoint::TextPatternRangeEndpoint_Start)
|
||||
{
|
||||
ourValue = _start;
|
||||
}
|
||||
else
|
||||
{
|
||||
ourValue = _end + 1;
|
||||
}
|
||||
const Endpoint ourValue = endpoint == TextPatternRangeEndpoint::TextPatternRangeEndpoint_Start ? _start : _end + 1;
|
||||
|
||||
// compare them
|
||||
*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;
|
||||
}
|
||||
HRESULT hr;
|
||||
HRESULT hr = E_UNEXPECTED;
|
||||
for (LONG i = 0; i < gsl::narrow<LONG>(coords.size()); ++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());
|
||||
#endif
|
||||
|
||||
ScreenInfoRow currentScreenInfoRow;
|
||||
ScreenInfoRow currentScreenInfoRow = 0;
|
||||
for (unsigned int i = 0; i < totalRowsInRange; ++i)
|
||||
{
|
||||
currentScreenInfoRow = startScreenInfoRow + i;
|
||||
|
@ -786,7 +770,7 @@ IFACEMETHODIMP UiaTextRangeBase::MoveEndpointByRange(_In_ TextPatternRangeEndpoi
|
|||
#endif
|
||||
|
||||
// get the value that we're updating to
|
||||
Endpoint targetEndpointValue;
|
||||
Endpoint targetEndpointValue = 0;
|
||||
if (targetEndpoint == TextPatternRangeEndpoint::TextPatternRangeEndpoint_Start)
|
||||
{
|
||||
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
|
||||
{
|
||||
startScreenInfoRow = _endpointToScreenInfoRow(_pData, _start);
|
||||
startColumn = _endpointToColumn(_pData, _start);
|
||||
endScreenInfoRow = _endpointToScreenInfoRow(_pData, _end);
|
||||
endColumn = _endpointToColumn(_pData, _end);
|
||||
targetScreenInfoRow = _endpointToScreenInfoRow(_pData, targetEndpointValue);
|
||||
targetColumn = _endpointToColumn(_pData, targetEndpointValue);
|
||||
}
|
||||
CATCH_RETURN();
|
||||
// convert then endpoints to screen info rows/columns
|
||||
const auto startScreenInfoRow = _endpointToScreenInfoRow(_pData, _start);
|
||||
const auto startColumn = _endpointToColumn(_pData, _start);
|
||||
const auto endScreenInfoRow = _endpointToScreenInfoRow(_pData, _end);
|
||||
const auto endColumn = _endpointToColumn(_pData, _end);
|
||||
const auto targetScreenInfoRow = _endpointToScreenInfoRow(_pData, targetEndpointValue);
|
||||
const auto targetColumn = _endpointToColumn(_pData, targetEndpointValue);
|
||||
|
||||
// set endpoint value and check for crossed endpoints
|
||||
bool crossedEndpoints = false;
|
||||
|
@ -854,6 +830,8 @@ IFACEMETHODIMP UiaTextRangeBase::MoveEndpointByRange(_In_ TextPatternRangeEndpoi
|
|||
}
|
||||
}
|
||||
_degenerate = crossedEndpoints;
|
||||
}
|
||||
CATCH_RETURN();
|
||||
|
||||
// TODO GitHub #1914: Re-attach Tracing to UIA Tree
|
||||
//Tracing::s_TraceUia(this, ApiCall::MoveEndpointByRange, &apiMsg);
|
||||
|
@ -874,14 +852,10 @@ IFACEMETHODIMP UiaTextRangeBase::Select()
|
|||
}
|
||||
else
|
||||
{
|
||||
COORD coordStart;
|
||||
COORD coordEnd;
|
||||
|
||||
coordStart.X = gsl::narrow<SHORT>(_endpointToColumn(_pData, _start));
|
||||
coordStart.Y = gsl::narrow<SHORT>(_endpointToScreenInfoRow(_pData, _start));
|
||||
|
||||
coordEnd.X = gsl::narrow<SHORT>(_endpointToColumn(_pData, _end));
|
||||
coordEnd.Y = gsl::narrow<SHORT>(_endpointToScreenInfoRow(_pData, _end));
|
||||
const COORD coordStart{ gsl::narrow<SHORT>(_endpointToColumn(_pData, _start)),
|
||||
gsl::narrow<SHORT>(_endpointToScreenInfoRow(_pData, _start)) };
|
||||
const COORD coordEnd{ gsl::narrow<SHORT>(_endpointToColumn(_pData, _end)),
|
||||
gsl::narrow<SHORT>(_endpointToScreenInfoRow(_pData, _end)) };
|
||||
|
||||
_pData->SelectNewRegion(coordStart, coordEnd);
|
||||
}
|
||||
|
@ -914,26 +888,17 @@ IFACEMETHODIMP UiaTextRangeBase::ScrollIntoView(_In_ BOOL alignToTop)
|
|||
_pData->UnlockConsole();
|
||||
});
|
||||
|
||||
SMALL_RECT oldViewport;
|
||||
unsigned int viewportHeight;
|
||||
// range rows
|
||||
ScreenInfoRow startScreenInfoRow;
|
||||
ScreenInfoRow endScreenInfoRow;
|
||||
// screen buffer rows
|
||||
ScreenInfoRow topRow;
|
||||
ScreenInfoRow bottomRow;
|
||||
try
|
||||
{
|
||||
oldViewport = _pData->GetViewport().ToInclusive();
|
||||
viewportHeight = _getViewportHeight(oldViewport);
|
||||
|
||||
const auto oldViewport = _pData->GetViewport().ToInclusive();
|
||||
const auto viewportHeight = _getViewportHeight(oldViewport);
|
||||
// range rows
|
||||
startScreenInfoRow = _endpointToScreenInfoRow(_pData, _start);
|
||||
endScreenInfoRow = _endpointToScreenInfoRow(_pData, _end);
|
||||
const auto startScreenInfoRow = _endpointToScreenInfoRow(_pData, _start);
|
||||
const auto endScreenInfoRow = _endpointToScreenInfoRow(_pData, _end);
|
||||
// screen buffer rows
|
||||
topRow = _getFirstScreenInfoRowIndex();
|
||||
bottomRow = _getLastScreenInfoRowIndex(_pData);
|
||||
}
|
||||
CATCH_RETURN();
|
||||
const auto topRow = _getFirstScreenInfoRowIndex();
|
||||
const auto bottomRow = _getLastScreenInfoRowIndex(_pData);
|
||||
|
||||
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(!(_getViewportHeight(oldViewport) == _getViewportHeight(newViewport)));
|
||||
|
||||
try
|
||||
{
|
||||
_ChangeViewport(newViewport);
|
||||
}
|
||||
CATCH_RETURN();
|
||||
|
||||
// TODO GitHub #1914: Re-attach Tracing to UIA Tree
|
||||
// tracing
|
||||
/*ApiMsgScrollIntoView apiMsg;
|
||||
apiMsg.AlignToTop = !!alignToTop;
|
||||
Tracing::s_TraceUia(this, ApiCall::ScrollIntoView, &apiMsg);*/
|
||||
|
||||
}
|
||||
CATCH_RETURN();
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
@ -1278,8 +1240,8 @@ void UiaTextRangeBase::_addScreenInfoRowBoundaries(IUiaData* pData,
|
|||
{
|
||||
const COORD currentFontSize = _getScreenFontSize();
|
||||
|
||||
POINT topLeft;
|
||||
POINT bottomRight;
|
||||
POINT topLeft{ 0 };
|
||||
POINT bottomRight{ 0 };
|
||||
|
||||
if (_endpointToScreenInfoRow(pData, _start) == screenInfoRow)
|
||||
{
|
||||
|
@ -1653,8 +1615,8 @@ UiaTextRangeBase::_moveEndpointByUnitCharacterForward(IUiaData* pData,
|
|||
THROW_HR_IF_NULL(E_INVALIDARG, pAmountMoved);
|
||||
*pAmountMoved = 0;
|
||||
const int count = moveCount;
|
||||
ScreenInfoRow currentScreenInfoRow;
|
||||
Column currentColumn;
|
||||
ScreenInfoRow currentScreenInfoRow = 0;
|
||||
Column currentColumn = 0;
|
||||
|
||||
// set current location vars
|
||||
if (endpoint == TextPatternRangeEndpoint::TextPatternRangeEndpoint_Start)
|
||||
|
@ -1744,8 +1706,8 @@ UiaTextRangeBase::_moveEndpointByUnitCharacterBackward(IUiaData* pData,
|
|||
THROW_HR_IF_NULL(E_INVALIDARG, pAmountMoved);
|
||||
*pAmountMoved = 0;
|
||||
const int count = moveCount;
|
||||
ScreenInfoRow currentScreenInfoRow;
|
||||
Column currentColumn;
|
||||
ScreenInfoRow currentScreenInfoRow = 0;
|
||||
Column currentColumn = 0;
|
||||
|
||||
// set current location vars
|
||||
if (endpoint == TextPatternRangeEndpoint::TextPatternRangeEndpoint_Start)
|
||||
|
@ -1845,8 +1807,8 @@ std::tuple<Endpoint, Endpoint, bool> UiaTextRangeBase::_moveEndpointByUnitLine(I
|
|||
THROW_HR_IF(E_INVALIDARG, pAmountMoved == nullptr);
|
||||
*pAmountMoved = 0;
|
||||
int count = moveCount;
|
||||
ScreenInfoRow currentScreenInfoRow;
|
||||
Column currentColumn;
|
||||
ScreenInfoRow currentScreenInfoRow = 0;
|
||||
Column currentColumn = 0;
|
||||
bool forceDegenerate = false;
|
||||
Endpoint start = _screenInfoRowToEndpoint(pData, moveState.StartScreenInfoRow) + moveState.StartColumn;
|
||||
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);
|
||||
*pAmountMoved = 0;
|
||||
|
||||
Endpoint start;
|
||||
Endpoint end;
|
||||
Endpoint start = 0;
|
||||
Endpoint end = 0;
|
||||
bool degenerate = false;
|
||||
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.
|
||||
COORD Viewport::GetWalkOrigin(const WalkDir dir) const noexcept
|
||||
{
|
||||
COORD origin;
|
||||
COORD origin{ 0 };
|
||||
origin.X = dir.x == XWalk::LeftToRight ? Left() : RightInclusive();
|
||||
origin.Y = dir.y == YWalk::TopToBottom ? Top() : BottomInclusive();
|
||||
return origin;
|
||||
|
|
Loading…
Reference in a new issue