VirtualTreeView inside a hided TabSheet lazarus / 5-Lazarus Extra Components ---------------------------------------------------------------------- Shebuka · 2011-07-22 10:20 When a VirtualTreeView inside a hided TabSheet lose/gain focus or control if it has focus (don't really know what exactly) the whole content of TabSheet is repainted on top messing up whole interface. I'm developing on Mac OS X and I'v made a simple example project to easy reproduce the bug with this steps: 1. Click on Button1 2. Click to edit Edit2 text field 3. Position your mouse on VirtualTreeView1 and don't move it 4. Type something inside Edit2 5. After timer brings you back to TabSheet1 move your mouse and you can see the bug in the screen (sometimes it also happend when simply after pass 1. you move focus away from application and then after timer event move mouse over page control) Can you try to test on Win and Linux platforms to see if only Mac OS X platform is affected by this bug? ---------------------------------------------------------------------- IPguy · 2011-07-23 02:35 Shebuka, I could not reproduce the bleed through that you show on your image. 0.9.31-31292-2.4.4, Win32-Vista, VTV-4.8.7 ---------------------------------------------------------------------- Shebuka · 2011-07-25 10:48 I have tryed myself on win32 and it doesn't happen, seems like it unhide the mouse pointer automaticaly after tab changes, when on Mac OSX you must move your mouse to unhide it... Can anyone try to reproduce it on linux based os? ---------------------------------------------------------------------- Shebuka · 2011-07-25 16:31 Look at this errors that logs to 'Console' app as i launch the test application... Code: [Select]25/07/11 18.20.16 [0x0-0x127127].com.company.TabTest[12449] TCarbonTabsControl.SetFocus Error: SetKeyboardFocus  failed with result -30585 25/07/11 18.20.16 [0x0-0x127127].com.company.TabTest[12449] TCarbonTabsControl.SetFocus Error: SetKeyboardFocus  failed with result -30585 25/07/11 18.20.16 [0x0-0x127127].com.company.TabTest[12449] TCarbonTabsControl.SetFocus Error: SetKeyboardFocus  failed with result -30585 25/07/11 18.20.16 [0x0-0x127127].com.company.TabTest[12449] TCarbonTabsControl.SetFocus Error: SetKeyboardFocus  failed with result -30585 25/07/11 18.20.19 [0x0-0x127127].com.company.TabTest[12449] TCarbonWidgetSet.GetProp Error - invalid widget  = 33654112! 25/07/11 18.20.19 [0x0-0x127127].com.company.TabTest[12449] TCarbonWidgetSet.GetParent Error - invalid widget  = 33654112! 25/07/11 18.20.19 [0x0-0x127127].com.company.TabTest[12449] TCarbonWidgetSet.GetProp Error - invalid widget  = 33654112! 25/07/11 18.20.19 [0x0-0x127127].com.company.TabTest[12449] TCarbonWidgetSet.GetParent Error - invalid widget  = 33654112!I have also noticed that on windows when mouse pointer is hided when digiting something in an edit box, it's unhided if you click on mouse button, on Mac version it isn't, you must move it or trigger a popup. ---------------------------------------------------------------------- IPguy · 2011-07-25 17:42 What code versions are you using? Lazarus? FPC? VTV? ---------------------------------------------------------------------- Shebuka · 2011-07-26 08:11 Laz: 0.9.31.31572 FPC: 2.4.4 VTV: 4.8.7.1 Another error, this one on application activation after restoring from sleep Code: [Select]26/07/11 09.24.36 [0x0-0x135135].com.company.TabTest[13227] CarbonWindow_MouseProc Error: GetEventParameter kEventParamWindowMouseLocation failed with result -9870 btw also lazarus throw setfocus errors: Code: [Select]26/07/11 10.08.45 [0x0-0x13b13b].lazarus[13584] TCarbonTabsControl.SetFocus Error: SetKeyboardFocus  failed with result -30585 ---------------------------------------------------------------------- IPguy · 2011-07-26 12:20 I do not have a Mac to test on, so I can not help much more. Have you searched Bugtracker to see if someone else has reported a similar issue? If not, you might want to file a bug report. ---------------------------------------------------------------------- IPguy · 2011-07-27 02:53 Shebuka, I just noticed that a new version of VirtualTrees.pas was published in the svn (rev 1762?) I pulled down tonight and the changes appeared to focus on carbon (ie: Mac). branch: virtualtreeview-new-branches-4.8 There was no info in the file about the changes and I did not see anything in Bugtracker that mentioned a new version. ---------------------------------------------------------------------- LuizAmérico · 2011-07-27 03:58 QuoteI just noticed that a new version of VirtualTrees.pas was published in the svn (rev 1762?) Nope. It's not related Quote26/07/11 10.08.45   [0x0-0x13b13b].lazarus[13584]   TCarbonTabsControl.SetFocus Error: SetKeyboardFocus  failed with result -30585 Quote26/07/11 09.24.36   [0x0- 0x135135].com.company.TabTest[13227]   CarbonWindow_MouseProc Error: GetEventParameter kEventParamWindowMouseLocation failed with result -9870 Search the source location in Carbon intf that send these messages (TCarbonControl.SetFocus, TCarbonWidgetSet.GetProp) get the callstack and send. I'll see if i can help ---------------------------------------------------------------------- Shebuka · 2011-07-27 09:02 Quote from: LuizAmérico on July 27, 2011, 05:58:36 amQuote26/07/11 10.08.45   [0x0-0x13b13b].lazarus[13584]   TCarbonTabsControl.SetFocus Error: SetKeyboardFocus  failed with result -30585Search the source location in Carbon intf that send these messages (TCarbonControl.SetFocus, TCarbonWidgetSet.GetProp) get the callstack and send. I'll see if i can help Application Run Code: [Select]#0 TCARBONCONTROL__SETFOCUS((TCARBONCONTROL) 0x2010200) at ./carbon/carbonprivatecontrol.inc:861 #1 TCARBONWIDGETSET__SETFOCUS(33620480, (TCARBONWIDGETSET) 0x16f83e0) at ./carbon/carbonwinapi.inc:3260 #2 SETFOCUS(33620480) at ./include/winapi.inc:897 #3 TCUSTOMFORM__UPDATESHOWING((TCUSTOMFORM) 0x16bbf80) at ./include/customform.inc:2591 #4 TWINCONTROL__DOALLAUTOSIZE((TWINCONTROL) 0x16bbf80) at ./include/wincontrol.inc:3519 #5 TCONTROL__ENABLEAUTOSIZING((TCONTROL) 0x16bbf80) at ./include/control.inc:4855 #6 TCONTROL__SETVISIBLE(true, (TCONTROL) 0x16bbf80) at ./include/control.inc:3733 #7 TCUSTOMFORM__SETVISIBLE(true, (TCUSTOMFORM) 0x16bbf80) at ./include/customform.inc:404 #8 TCUSTOMFORM__SHOW((TCUSTOMFORM) 0x16bbf80) at ./include/customform.inc:2115 #9 TAPPLICATION__RUN((TAPPLICATION) 0x16b02f0) at ./include/application.inc:1384 #10 PASCALMAIN at TabTest.lpr:19 #11 SYSTEM_FPC_SYSTEMMAIN$LONGINT$PPCHAR$PPCHAR at :0 #12 _start at :0 #13 start at :0 Application Activate Code: [Select]#0 TCARBONCONTROL__SETFOCUS((TCARBONCONTROL) 0x2010200) at ./carbon/carbonprivatecontrol.inc:861 #1 TCARBONWIDGETSET__SETFOCUS(33620480, (TCARBONWIDGETSET) 0x16f83e0) at ./carbon/carbonwinapi.inc:3260 #2 SETFOCUS(33620480) at ./include/winapi.inc:897 #3 TCUSTOMFORM__SETWINDOWFOCUS((TCUSTOMFORM) 0x16bbf80) at ./include/customform.inc:439 #4 TCUSTOMFORM__SETACTIVE(true, (TCUSTOMFORM) 0x16bbf80) at ./include/customform.inc:932 #5 TCUSTOMFORM__WMACTIVATE({MSG = 6, ACTIVE = true (65535), MINIMIZED = false, ACTIVEWINDOW = 0, RESULT = 0}, (TCUSTOMFORM) 0x16bbf80) at ./include/customform.inc:484 #6 SYSTEM_TOBJECT_$__DISPATCH$formal at :0 #7 TWINCONTROL__WNDPROC({MSG = 6, WPARAM = 65535, LPARAM = 0, RESULT = 0, WPARAMLO = 65535, WPARAMHI = 0, LPARAMLO = 0, LPARAMHI = 0, RESULTLO = 0, RESULTHI = 0}, (TWINCONTROL) 0x16bbf80) at ./include/wincontrol.inc:5243 #8 TCUSTOMFORM__WNDPROC({MSG = 6, WPARAM = 65535, LPARAM = 0, RESULT = 0, WPARAMLO = 65535, WPARAMHI = 0, LPARAMLO = 0, LPARAMHI = 0, RESULTLO = 0, RESULTHI = 0}, (TCUSTOMFORM) 0x16bbf80) at ./include/customform.inc:1368 #9 DELIVERMESSAGE((^TOBJECT) 0x16bbf80, void) at lclmessageglue.pas:111 #10 LCLSENDACTIVATEMSG((^TCONTROL) 0x16bbf80, true, false, 0) at lclmessageglue.pas:173 #11 CARBONWINDOW_ACTIVATEPROC((CFSTRINGREF) 0xbfffe570, (CFSTRINGREF) 0x231f4c0, (^TCARBONWIDGET) 0x20f34f0) at ./carbon/carbonprivatewindow.inc:984 #12 DispatchEventToHandlers at :0 #13 SendEventToEventTargetInternal at :0 #14 SendEventToEventTargetWithOptions at :0 #15 PostActivateEvent at :0 #16 HiliteAndActivateWindow at :0 #17 AdjustToNewWindowActivation at :0 #18 PotentiallyAdjustToNewWindowActivation at :0 #19 BringToFrontAndActivateWindow at :0 #20 WindowData::SelectWindow at :0 #21 HandleWindowCommandEvent at :0 #22 StandardWindowEventHandler at :0 #23 DispatchEventToHandlers at :0 #24 SendEventToEventTargetInternal at :0 #25 SendEventToEventTarget at :0 #26 SendHICommandEvent at :0 #27 SendHICommandToTarget at :0 #28 _RequestWindowSelection at :0 #29 HIApplication::PerformWindowActivation at :0 #30 HIApplication::HandleActivated at :0 #31 HIApplication::EventObserver at :0 #32 _NotifyEventLoopObservers at :0 #33 AcquireEventFromQueue at :0 #34 ReceiveNextEventCommon at :0 #35 ReceiveNextEvent at :0 #36 TCARBONWIDGETSET__APPPROCESSMESSAGES((TCARBONWIDGETSET) 0x16f83e0) at ./carbon/carbonobject.inc:542 #37 TAPPLICATION__HANDLEMESSAGE((TAPPLICATION) 0x16b02f0) at ./include/application.inc:1264 #38 TAPPLICATION__RUNLOOP((TAPPLICATION) 0x16b02f0) at ./include/application.inc:1397 #39 EVENTLOOPEVENTHANDLER((PLONGINT) 0xbffff470, (PLONGINT) 0x2309c40, (POINTER) 0x16f83e0) at ./carbon/carbonobject.inc:126 #40 DispatchEventToHandlers at :0 #41 SendEventToEventTargetInternal at :0 #42 SendEventToEventTargetWithOptions at :0 #43 ToolboxEventDispatcherHandler at :0 #44 DispatchEventToHandlers at :0 #45 SendEventToEventTargetInternal at :0 #46 SendEventToEventTarget at :0 #47 ToolboxEventDispatcher at :0 #48 RunApplicationEventLoop at :0 #49 TCARBONWIDGETSET__APPRUN((TAPPLICATIONMAINLOOP) 0x40350 , (TCARBONWIDGETSET) 0x16f83e0) at ./carbon/carbonobject.inc:505 #50 TAPPLICATION__RUN((TAPPLICATION) 0x16b02f0) at ./include/application.inc:1385 #51 PASCALMAIN at TabTest.lpr:19 #52 SYSTEM_FPC_SYSTEMMAIN$LONGINT$PPCHAR$PPCHAR at :0 #53 _start at :0 #54 start at :0 Code: [Select]#0 TCARBONCONTROL__SETFOCUS((TCARBONCONTROL) 0x2010200) at ./carbon/carbonprivatecontrol.inc:861 #1 TCARBONWIDGETSET__SETFOCUS(33620480, (TCARBONWIDGETSET) 0x16f83e0) at ./carbon/carbonwinapi.inc:3260 #2 SETFOCUS(33620480) at ./include/winapi.inc:897 #3 TCUSTOMFORM__WNDPROC({MSG = 7, WPARAM = 0, LPARAM = 0, RESULT = 0, WPARAMLO = 0, WPARAMHI = 0, LPARAMLO = 0, LPARAMHI = 0, RESULTLO = 0, RESULTHI = 0}, (TCUSTOMFORM) 0x16bbf80) at ./include/customform.inc:1327 #4 DELIVERMESSAGE((^TOBJECT) 0x16bbf80, void) at lclmessageglue.pas:111 #5 SENDSIMPLEMESSAGE((^TCONTROL) 0x16bbf80, 7) at lclmessageglue.pas:142 #6 LCLSENDSETFOCUSMSG((^TCONTROL) 0x16bbf80) at lclmessageglue.pas:193 #7 TCARBONWIDGET__FOCUSSET((TCARBONWIDGET) 0x20f34f0) at ./carbon/carbondef.pp:528 #8 CARBONWINDOW_ACTIVATEPROC((CFSTRINGREF) 0xbfffe570, (CFSTRINGREF) 0x231f4c0, (^TCARBONWIDGET) 0x20f34f0) at ./carbon/carbonprivatewindow.inc:1000 #9 DispatchEventToHandlers at :0 #10 SendEventToEventTargetInternal at :0 #11 SendEventToEventTargetWithOptions at :0 #12 PostActivateEvent at :0 #13 HiliteAndActivateWindow at :0 #14 AdjustToNewWindowActivation at :0 #15 PotentiallyAdjustToNewWindowActivation at :0 #16 BringToFrontAndActivateWindow at :0 #17 WindowData::SelectWindow at :0 #18 HandleWindowCommandEvent at :0 #19 StandardWindowEventHandler at :0 #20 DispatchEventToHandlers at :0 #21 SendEventToEventTargetInternal at :0 #22 SendEventToEventTarget at :0 #23 SendHICommandEvent at :0 #24 SendHICommandToTarget at :0 #25 _RequestWindowSelection at :0 #26 HIApplication::PerformWindowActivation at :0 #27 HIApplication::HandleActivated at :0 #28 HIApplication::EventObserver at :0 #29 _NotifyEventLoopObservers at :0 #30 AcquireEventFromQueue at :0 #31 ReceiveNextEventCommon at :0 #32 ReceiveNextEvent at :0 #33 TCARBONWIDGETSET__APPPROCESSMESSAGES((TCARBONWIDGETSET) 0x16f83e0) at ./carbon/carbonobject.inc:542 #34 TAPPLICATION__HANDLEMESSAGE((TAPPLICATION) 0x16b02f0) at ./include/application.inc:1264 #35 TAPPLICATION__RUNLOOP((TAPPLICATION) 0x16b02f0) at ./include/application.inc:1397 #36 EVENTLOOPEVENTHANDLER((PLONGINT) 0xbffff470, (PLONGINT) 0x2309c40, (POINTER) 0x16f83e0) at ./carbon/carbonobject.inc:126 #37 DispatchEventToHandlers at :0 #38 SendEventToEventTargetInternal at :0 #39 SendEventToEventTargetWithOptions at :0 #40 ToolboxEventDispatcherHandler at :0 #41 DispatchEventToHandlers at :0 #42 SendEventToEventTargetInternal at :0 #43 SendEventToEventTarget at :0 #44 ToolboxEventDispatcher at :0 #45 RunApplicationEventLoop at :0 #46 TCARBONWIDGETSET__APPRUN((TAPPLICATIONMAINLOOP) 0x40350 , (TCARBONWIDGETSET) 0x16f83e0) at ./carbon/carbonobject.inc:505 #47 TAPPLICATION__RUN((TAPPLICATION) 0x16b02f0) at ./include/application.inc:1385 #48 PASCALMAIN at TabTest.lpr:19 #49 SYSTEM_FPC_SYSTEMMAIN$LONGINT$PPCHAR$PPCHAR at :0 #50 _start at :0 #51 start at :0 I can't get the forth error because i think it happens after application get focused, and i always loose focus cause debug... ---------------------------------------------------------------------- LuizAmérico · 2011-07-28 00:12 WARNING: no experience at all with Carbon Quote#0 TCARBONCONTROL__SETFOCUS((TCARBONCONTROL) 0x2010200) at ./carbon/carbonprivatecontrol.inc:861 #1 TCARBONWIDGETSET__SETFOCUS(33620480, (TCARBONWIDGETSET) 0x16f83e0) at ./carbon/carbonwinapi.inc:3260 #2 SETFOCUS(33620480) at ./include/winapi.inc:897 I tested under windows and here the focus of ActiveControl (in my case PageControl1) is set through LCLIntf.SetFocus First hint:: check if ActiveControl is PageControl1 (do a break point and evaluate Self.FACTIVECONTROL) Quote#0 TCARBONCONTROL__SETFOCUS((TCARBONCONTROL) 0x2010200) at ./carbon/carbonprivatecontrol.inc:861 Here a WindowRef is gotten through GetTopParentWindow Looking at the implementation, it will get the WindowRef from the TForm instead of the PageControl1 Please check if true and if the value is not nil. It uses the windowref in SetUserFocusWindow And also in GetKeyboardFocus (here Control is not initialized -> check to see is returns nil or try to set to nil before the call) Finally calls SetKeyboardFocus with the WindowRef and Widget Hint check value of Widget (nil?) Also look at SetKeyboardFocus and like function in carbon documentation to see if they are being used correctly. Check the error code to see if match with some ---------------------------------------------------------------------- Shebuka · 2011-07-29 08:56 Quote from: LuizAmérico on July 28, 2011, 02:12:13 amWARNING: no experience at all with Carbon Quote#0 TCARBONCONTROL__SETFOCUS((TCARBONCONTROL) 0x2010200) at ./carbon/carbonprivatecontrol.inc:861 #1 TCARBONWIDGETSET__SETFOCUS(33620480, (TCARBONWIDGETSET) 0x16f83e0) at ./carbon/carbonwinapi.inc:3260 #2 SETFOCUS(33620480) at ./include/winapi.inc:897 I tested under windows and here the focus of ActiveControl (in my case PageControl1) is set through LCLIntf.SetFocus First hint:: check if ActiveControl is PageControl1 (do a break point and evaluate Self.FACTIVECONTROL)I'v tried to make a breakpoint in three places and: In Create it's nil In Show it's nil On Button1Click it's PageControl1 QuoteQuote#0 TCARBONCONTROL__SETFOCUS((TCARBONCONTROL) 0x2010200) at ./carbon/carbonprivatecontrol.inc:861 Here a WindowRef is gotten through GetTopParentWindow Looking at the implementation, it will get the WindowRef from the TForm instead of the PageControl1 Please check if true and if the value is not nil.GetTopParentWindow calls LCLObject.GetTopParent and get Form reference and Window is TCustomForm is True, Result is cfstringref($0230D180) = -1609914696 QuoteIt uses the windowref in SetUserFocusWindow And also in GetKeyboardFocus (here Control is not initialized -> check to see is returns nil or try to set to nil before the call)it's cfstringref(nil), before and after GetKeyboardFocus QuoteFinally calls SetKeyboardFocus with the WindowRef and Widget Hint check value of Widget (nil?)No, it's cfstringref($0231B5E0) = -1609914696 (cfstringref is different but value is equal to WindowRef?) QuoteAlso look at SetKeyboardFocus and like function in carbon documentation to see if they are being used correctly. Check the error code to see if match with some It seem that they are used properly... but they are all system implemented (external name '_SetKeyboardFocus') btw QuoteTwo new APIs, HIWindowGetFocus and HIWindowSetFocus, replace the existing SetKeyboardFocus and GetKeyboardFocus APIs. These APIs also allow you more control over whether a view becomes focused without consideration of the user's current focusing preferences. ---------------------------------------------------------------------- LuizAmérico · 2011-07-29 21:21 Thanks for testing but i could not see a problem that could lead to problem you are seeing although clearly the SetFocus handling in Carbon needs some work to avoid those error messages. About the problem, it seems a bug in the carbon TabSheet implementation. My suggestion: i noticed that the Edit2 control is also show in the first tab so it's not specific to VirtualTreeView. Please correct me: the bug also occurs without VTV (try putting a StringGrid or TreeView)? If so create a bug report without the VirtualTreeView. This make easier to carbon developer work since minimizes variable number and not all use/has VirtualTreeView. One more tip, so the developer has more clue to find the problem: instead of using:   TabSheet1.TabVisible := True;   TabSheet1.Enabled := True; Try   PageControl1.TabIndex := 0; or   PageControl1.TabIndex := 1; See if the problem also occurs BTW: take a look at the bugreports you added. I updated some ---------------------------------------------------------------------- Shebuka · 2011-08-01 09:15 Quote from: LuizAmérico on July 29, 2011, 11:21:05 pmThanks for testing but i could not see a problem that could lead to problem you are seeing although clearly the SetFocus handling in Carbon needs some work to avoid those error messages. About the problem, it seems a bug in the carbon TabSheet implementation. My suggestion: i noticed that the Edit2 control is also show in the first tab so it's not specific to VirtualTreeView. Please correct me: the bug also occurs without VTV (try putting a StringGrid or TreeView)?No, the bug occurs only when the focus, before mouse cursor hide on typing, was on VST. (see steps to reproduce) I guess that when you move mouse after tab switch VST try to get focus from parent, that fails and VST force parent to repaint, and parent (TabSheet) repaints self, VST and all other controls he owns as children. I have tried some other controls, TreeView, ListView and an other EditBox and all works fine. So meybe there is something to work with TabSheet for get rid of errors (and it also can maybe resolve this bug), but other controls properly manage that error and not force parent to repaint/ivalidate. QuoteIf so create a bug report without the VirtualTreeView. This make easier to carbon developer work since minimizes variable number and not all use/has VirtualTreeView. One more tip, so the developer has more clue to find the problem: instead of using:   TabSheet1.TabVisible := True;   TabSheet1.Enabled := True; Try   PageControl1.TabIndex := 0; or   PageControl1.TabIndex := 1; See if the problem also occursNo, as reported only occurs with hided TabSheet, infact currently i commented the code to hide TabSheets in my application (wich was working well with TreeView) and use TabIndex. QuoteBTW: take a look at the bugreports you added. I updated some will see ---------------------------------------------------------------------- LuizAmérico · 2011-08-01 20:09 Try to put Exit; in the beginning of TBaseVirtualTree.MouseMove There are some suspicious calls like UpdateWindow and InvalidateRect there ---------------------------------------------------------------------- Shebuka · 2011-08-02 08:21 Quote from: LuizAmérico on August 01, 2011, 10:09:42 pmTry to put Exit; in the beginning of TBaseVirtualTree.MouseMove There are some suspicious calls like UpdateWindow and InvalidateRect there Nothing changed. Also I'v tried to follow steps 1-4, then cmd+tab to lazarus and put breakpoint on TBaseVirtualTree.MouseMove, cmd+tab back to TabTest and as i move mouse over the area of hided tab sheet, the bug happens but TBaseVirtualTree.MouseMove was not called. If i remove VST from form no bug. It can be also that tab sheet tries to get last focus from his childs and VST gives him something wrong?