Skip to content

Instantly share code, notes, and snippets.

@wez
Created June 26, 2011 18:25
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wez/1047826 to your computer and use it in GitHub Desktop.
Save wez/1047826 to your computer and use it in GitHub Desktop.
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
Copy link
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
Copy link
Author

wez commented Jun 26, 2011

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment