summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2009-04-19 16:04:44 +0000
committerfrosch <frosch@openttd.org>2009-04-19 16:04:44 +0000
commit90ebf211dcc9997ea1f0bb627cac2f5593efcec1 (patch)
tree17c21e801bc3b1ca4bfeb5cfa0b05390109f53d7
parenta91ff2d5e8b0a65da160b93f2aa293d3c54c2ae3 (diff)
downloadopenttd-90ebf211dcc9997ea1f0bb627cac2f5593efcec1.tar.xz
(svn r16094) -Fix: AIDebug window profiled the blitters by invalidating itself unconditionally on repaint. OTOH it was not invalidated in other cases when needed.
-rw-r--r--src/ai/ai_gui.cpp21
1 files changed, 18 insertions, 3 deletions
diff --git a/src/ai/ai_gui.cpp b/src/ai/ai_gui.cpp
index 90e7b6394..635ca353f 100644
--- a/src/ai/ai_gui.cpp
+++ b/src/ai/ai_gui.cpp
@@ -727,8 +727,14 @@ struct AIDebugWindow : public Window {
AILog::LogData *log = (AILog::LogData *)AIObject::GetLogPointer();
_current_company = old_company;
- SetVScrollCount(this, (log == NULL) ? 0 : log->used);
- this->InvalidateWidget(AID_WIDGET_SCROLLBAR);
+ int scroll_count = (log == NULL) ? 0 : log->used;
+ if (this->vscroll.count != scroll_count) {
+ SetVScrollCount(this, scroll_count);
+
+ /* We need a repaint */
+ this->InvalidateWidget(AID_WIDGET_SCROLLBAR);
+ }
+
if (log == NULL) return;
/* Detect when the user scrolls the window. Enable autoscroll when the
@@ -736,7 +742,15 @@ struct AIDebugWindow : public Window {
if (this->last_vscroll_pos != this->vscroll.pos) {
this->autoscroll = this->vscroll.pos >= log->used - this->vscroll.cap;
}
- if (this->autoscroll) this->vscroll.pos = max(0, log->used - this->vscroll.cap);
+ if (this->autoscroll) {
+ int scroll_pos = max(0, log->used - this->vscroll.cap);
+ if (scroll_pos != this->vscroll.pos) {
+ this->vscroll.pos = scroll_pos;
+
+ /* We need a repaint */
+ this->InvalidateWidget(AID_WIDGET_SCROLLBAR);
+ }
+ }
last_vscroll_pos = this->vscroll.pos;
int y = 6;
@@ -799,6 +813,7 @@ struct AIDebugWindow : public Window {
virtual void OnResize(Point delta)
{
this->vscroll.cap += delta.y / (int)this->resize.step_height;
+ SetVScrollCount(this, this->vscroll.count); // vscroll.pos should be in a valid range
}
};