From db7c4791bbbc1caf028d7a3d06e12e5ec8bdf67b Mon Sep 17 00:00:00 2001 From: X512 Date: Sat, 11 Jan 2020 04:29:17 +0900 Subject: [PATCH] Interface Kit: read reply before calling hooks. Part of #15548. Change-Id: I074d36717ef1e2fad4e8bc215448fa72f797ed7f Reviewed-on: https://review.haiku-os.org/c/haiku/+/2099 Reviewed-by: waddlesplash --- src/kits/interface/Window.cpp | 37 +++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/src/kits/interface/Window.cpp b/src/kits/interface/Window.cpp index ca4cdbd898..3f27e5ea55 100644 --- a/src/kits/interface/Window.cpp +++ b/src/kits/interface/Window.cpp @@ -1187,23 +1187,6 @@ FrameMoved(origin); float height; fLink->Read(&width); fLink->Read(&height); - if (origin != fFrame.LeftTop()) { - // TODO: remove code duplicatation with - // B_WINDOW_MOVED case... - //printf("window position was not up to date\n"); - fFrame.OffsetTo(origin); - FrameMoved(origin); - } - if (width != fFrame.Width() || height != fFrame.Height()) { - // TODO: remove code duplicatation with - // B_WINDOW_RESIZED case... - //printf("window size was not up to date\n"); - fFrame.right = fFrame.left + width; - fFrame.bottom = fFrame.top + height; - - _AdoptResize(); - FrameResized(width, height); - } // read tokens for views that need to be drawn // NOTE: we need to read the tokens completely @@ -1232,6 +1215,26 @@ FrameMoved(origin); if (error < B_OK) break; } + // Hooks should be called after finishing reading reply because + // they can access fLink. + if (origin != fFrame.LeftTop()) { + // TODO: remove code duplicatation with + // B_WINDOW_MOVED case... + //printf("window position was not up to date\n"); + fFrame.OffsetTo(origin); + FrameMoved(origin); + } + if (width != fFrame.Width() || height != fFrame.Height()) { + // TODO: remove code duplicatation with + // B_WINDOW_RESIZED case... + //printf("window size was not up to date\n"); + fFrame.right = fFrame.left + width; + fFrame.bottom = fFrame.top + height; + + _AdoptResize(); + FrameResized(width, height); + } + // draw int32 count = infos.CountItems(); for (int32 i = 0; i < count; i++) {