[Mono-dev] problem: Invalidate does not propagate correctly invalidation to nested controls (+patch)

matteot matteo.tesser at gmail.com
Fri Dec 18 08:24:07 EST 2009

Hi, I see the point, anyway It seems, that differently from Refresh,
Invalidate is called recursively!
As you suggested I wrote a test case and filed the following bug 


The test  calls Invalidate method on the topmost form and than tests if
Invalidate method have been called in a twice-nested control. 

The test work on MS.NET and mono but fails on mono 2.4.3 and 2.6 
(Invalidate is not called at all)

It seems to me that the patch I submitted may solve the problem, even if it
seems that invalidate is called twice in this case.

Best regards,

Ivan Zlatev-2 wrote:
> Hey,
> The reason that this code was changed is because on MS.NET Refresh
> isn't called recursively and some controls override it and do not
> expect that it will be called again and end up in an endless loop. I
> think this was also the case with some Mono WinForms controls
> especially in MDI forms.
> It would be best if you can write an unit test to verify that on
> MS.NET when you call Invalidate (true) it recursively calls the same
> on the child controls. While you are at it you can also write one that
> shows that Refresh() is not called recursively as well which I should
> have done myself (sorry). I am sure Calberto will be happy to review
> with a test that passes and a patch that also causes no fails on our
> test suite.
> Kind Regards,
> Ivan Zlatev
> http://ivanz.com
> On Thu, Dec 17, 2009 at 10:19 PM, matteo tesser <matteo.tesser at gmail.com>
> wrote:
>> Hi,
>> I noticed that both mono 2.6 and mono 2.4.3 introduce a problem in
>> windows.form apps (in  all versions linuxes and os x) : In some
>> situations, invalidate and subsequent painting is not propagated
>> correctly to nested controls.
>> The problem is due to the following change in the Control.Refresh method.
>> http://anonsvn.mono-project.com/viewvc/trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Control.cs?r1=140535&r2=141744&sortby=date
>> The old version called Control.Refresh method recursively for all
>> child controls . The new version  changes strategy and - correctly -
>> call Update  method  telling to invalidate  childrend  controls too.
>> The problem is in the implementation of method Control.Invalidate .  I
>> noticed that in mono 2.6 (2.4.3), when a control contains more than
>> one level of nested controls, only first level controls are
>> refreshed/painted.
>> I think that method invalidate,  when InvalidateChildren parameter is
>> true, should propagate recursively the invalidation  to all nested
>> controls.
>> I send  you a patch, which corrects the problem in the apps I'm working.
>> Thanks,
>> Matteo
>> _______________________________________________
>> Mono-devel-list mailing list
>> Mono-devel-list at lists.ximian.com
>> http://lists.ximian.com/mailman/listinfo/mono-devel-list
> _______________________________________________
> Mono-devel-list mailing list
> Mono-devel-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-devel-list

View this message in context: http://old.nabble.com/problem%3A-Invalidate-does-not-propagate-correctly-invalidation-to-nested-controls-%28%2Bpatch%29-tp26836703p26843207.html
Sent from the Mono - Dev mailing list archive at Nabble.com.

More information about the Mono-devel-list mailing list