From 22b8ec313314be239a04741669fa3e7a19f8288e Mon Sep 17 00:00:00 2001 From: Neil Date: Tue, 31 Jul 2018 09:07:31 +1000 Subject: Change lifetime of textLayout for bidirectional so it is always released in ScreenLineLayout destructor. Allows multiple ScreenLineLayout calls and fixes a leak when only FindRangeIntervals called. --- win32/PlatWin.cxx | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'win32') diff --git a/win32/PlatWin.cxx b/win32/PlatWin.cxx index 9e03dec16..222eac26b 100644 --- a/win32/PlatWin.cxx +++ b/win32/PlatWin.cxx @@ -1844,6 +1844,10 @@ ScreenLineLayout::ScreenLineLayout(const IScreenLine *screenLine) { } ScreenLineLayout::~ScreenLineLayout() { + if (textLayout) { + textLayout->Release(); + textLayout = nullptr; + } } // Get the position from the provided x @@ -1888,7 +1892,6 @@ size_t ScreenLineLayout::PositionFromX(XYPOSITION xDistance, bool charPosition) ); } - textLayout->Release(); size_t pos; if (charPosition) { pos = isTrailingHit ? hitTestMetrics.textPosition : caretMetrics.textPosition; @@ -1921,8 +1924,6 @@ XYPOSITION ScreenLineLayout::XFromPosition(size_t caretPosition) { &caretMetrics ); - textLayout->Release(); - return pt.x; } -- cgit v1.2.3