Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Fix infinite loop in __CreateDWriteTextLayout#1306

Merged
rajsesh merged 2 commits into
microsoft:developfrom
aballway:coretext
Nov 3, 2016
Merged

Fix infinite loop in __CreateDWriteTextLayout#1306
rajsesh merged 2 commits into
microsoft:developfrom
aballway:coretext

Conversation

@aballway

@aballway aballway commented Nov 2, 2016

Copy link
Copy Markdown
Contributor

Were not handling edge case where frames were being created with ranges not aligned with attributes in attributed strings.

Fixes #1294


This change is Reviewable

CFRelease(firstFrame);
CFRelease(secondFrame);
CFRelease(thirdFrame);
CFRelease(fullFrame);

@msft-Jeyaram msft-Jeyaram Nov 2, 2016

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

RAII? #WontFix

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A good pattern for future tests, but I don't believe it's necessary here

NSDictionary* attribs = [static_cast<NSAttributedString*>(string) attributesAtIndex:i + range.location
longestEffectiveRange:&attributeRange
inRange:{ i, [subString length] }];
inRange:{ i + range.location, [subString length] }];

@ms-jihua ms-jihua Nov 2, 2016

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

inRange:{ i + range.location, [subString length] }]; [](start = 84, length = 52)

Mm. This is kind of a big ask, but in retrospect, I would prefer if you relied on [NSAttributedString enumerateAttributesInRange:options:usingBlock:] to do the loop instead. You're a lot less likely to make a mistake that way. (Note that you'd have to declare incompatibleAttributeFlag and textLayout as __block if you do this) #WontFix

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll do this the next time I add an attribute we handle here or on any cleanup pass I make.

@ms-jihua

ms-jihua commented Nov 2, 2016

Copy link
Copy Markdown
Contributor

:shipit:

@rajsesh

rajsesh commented Nov 3, 2016

Copy link
Copy Markdown
Contributor

@aballway is this ready to merge?

@rajsesh rajsesh merged commit 62fe54b into microsoft:develop Nov 3, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants