Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2011-09

TPageControl bug (or by desing)?

4 messages · 3 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Bart

Hi,

The value of PageCount inside TPageControl.DoChange (and therefore in the OnChange event) seems wrong (to me), when you remove a page from the control.

When I have n pages and then remove 1, in DoChange the value of PageCount still is n, when I would expect it to be n-1 at that moment. (Tested with Laz r32144).

I stumbled upon this, after hours of digging in entirely the wrong place <g>, because in my overriden DoChange I called a method that would check for PageCount > 0 and if so it would access a page. When I removed the last page, PageCount would still be 1, when in fact no more pages existed at that time, so any access to Pages[ActivePageIndex] would crash the program.

Is this really a bug, or is it by design?

Reply by email

Felipe Monteiro de Carvalho
to Bart

It looks a bug. It should be n in onchanging but n-1 in onchange. But it would be good to confirm in Delphi.

"Bart" wrote 24 lines
Hi, The value of PageCount inside TPageControl.DoChange (and therefore in the OnChange event) seems wrong (to me), when you remove a page from the control. When I have n pages and then remove 1, in DoChange the value of PageCount still is n, when I would expect it to be n-1 at that moment. (Tested with Laz r32144). I stumbled upon this, after hours of digging in entirely the wrong place <g>, because in my overriden DoChange I called a method that would check for PageCount > 0 and if so it would access a page. When I removed the last page, PageCount would still be 1, when in fact no more pages existed at that time, so any access to Pages[ActivePageIndex] would crash the program. Is this really a bug, or is it by design? -- _______________________________________________ Lazarus mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20110917/018e50e5/attachment-0001.html>

Reply by email

Hans-Peter Diettrich
to Bart: The value of PageCount inside TPageControl.DoChange (and therefore in the OnChange event)…
Show quoted text 5 lines
Hi, The value of PageCount inside TPageControl.DoChange (and therefore in the OnChange event) seems wrong (to me), when you remove a page from the control.

This may be a bug in the widgetset - which one did you use?

E.g. gtk2 creates a dummy page when all pages have been removed. When now the widgetset counts the pages, instead of the control, you can get any number of strange effects, depending on the widgetset.

I already complained about more such misfeatures in the wigetsets, but chances seem to be very low that we'll get a better (and Delphi compatible) interface and implementation :-(

Is this really a bug, or is it by design?

Make an bug report, perhaps it helps...

DoDi

Reply by email

Bart
to Hans-Peter Diettrich
Hans-Peter Diettrich wrote 8 lines
Bart schrieb: > Hi, > > The value of PageCount inside TPageControl.DoChange (and therefore in > the OnChange event) seems wrong (to me), when you remove a page from > the control. This may be a bug in the widgetset - which one did you use?

I tested this on Win32 and Linux/GTK2
On Windows however, change is not called when removing the last page (and this is why my program didn't crash on Windows).

Bart

Reply by email