Skip to content

Instantly share code, notes, and snippets.

@wez wez/treemap.diff
Created Jun 26, 2011

Embed
What would you like to do?
tweaks for qcachegrind
Index: libviews/treemap.cpp
===================================================================
--- libviews/treemap.cpp (revision 1238414)
+++ libviews/treemap.cpp (working copy)
@@ -368,9 +368,12 @@
while(qAbs(maxWidth - usedWidth) > 3 * fm->maxWidth()) {
int halfPos = (bottomPos + breakPos)/2;
int halfWidth = fm->width(text, halfPos);
- if (halfWidth < maxWidth)
+ if (halfWidth < maxWidth) {
bottomPos = halfPos;
- else {
+ if (usedWidth > maxWidth) {
+ usedWidth--;
+ }
+ } else {
breakPos = halfPos;
usedWidth = halfWidth;
}
@wez

This comment has been minimized.

Copy link
Owner Author

wez commented Jun 26, 2011

The binary search algorithm in treemap.cpp doesn't make progress in the case where the computed width is larger than the available width; this simple patch slowly brings this back to within bounds.
There may be better ways to do this; I am not a qt developer.

@wez

This comment has been minimized.

Copy link
Owner Author

wez commented Jun 26, 2011

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.