Different (tree) event behaviors across platforms

Hi all,

I’m currently writing a simple outliner application as a tutorial on
wxRuby (both will be soon released :wink: )
I tested this application on Windows and Linux and found that the tree
event behavior :

  • is sometime strange on each platform
  • is also different on each platform

Even if I managed to take care of these differences in the
application, I’m just wondering if :

  • they revealed some wxRuby issues ? wxWindows issues ?
  • or it is normal ? In this case, I’d really appreciate some
    links/documentation on these cross-platforms issues.

You will find attached the source codes and captures of the
application on Windows and Linux (Fedora 8).

So the symptoms :
1/ Run outliner_wo_check.rb
Clicking on the ‘Add Root’ button, creates an item and allow the
edition of its label.
On Windows, this works as expected. You can click several times and
everything is fine.
On Linux, this does not work. Sometimes, the editing of the label is
not ended by the selection (through code) of another item. See the
outliner_linux_wo_check.jpg capture.

To fix this Linux issue, I added some checks to know if a label is
being edited and to ensure that the editing is ended before adding
items.

2/ Run outliner.rb
If I create a root article, there are 2 selection change events on
Windows (strange) and only one on Linux (as expected).
See outliner_linux.jpg and outliner_windows.jpg.

3/ Run again outliner.rb :

  • create two root articles, create a child within the first root as
    shown in outliner_windows.jpg
  • close the application afterwards

On Windows, you will see traces indicating that there are selection
change events occuring during the close of the application ! On Linux,
you don’t have these events.

This time for 2/ and 3/ I had to write code to face these strange
things on Windows.

Thanks in advance for any help/clarification.

Cheers.

Chauk-Mean.

Hi

Chauk-Mean P wrote:

I’m currently writing a simple outliner application as a tutorial on
wxRuby (both will be soon released :wink: )
I tested this application on Windows and Linux and found that the tree
event behavior :

  • is sometime strange on each platform
  • is also different on each platform

Thank you for the report and test cases. As you know wxWidgets wraps
native controls and the native event loop, and there are some subtle
differences sometimes. From experience I think there are more of these
in TreeCtrl than anywhere else - it’s probably because it’s the most
complex native-wrapped control.

Even if I managed to take care of these differences in the
application, I’m just wondering if :

  • they revealed some wxRuby issues ? wxWindows issues ?
  • or it is normal ? In this case, I’d really appreciate some
    links/documentation on these cross-platforms issues.

In most cases they’re wxWidgets issues, though ultimately the only way
to verify this is to write a C++ sample. As for official docs, we’re
limited to what’s in the wxWidgets docs, plus any annotations we make.
In the past I’ve turned up useful confirmations of subtler
cross-platform differences by searching for info on wxPython or C++ (eg
by searching for wxTreeCtrl). The wxWiki sometimes also has info.

But usually it’s just a question of coding round it, as you’ve done.
Happy to apply patches that note these differences in our ruby docs.

You will find attached the source codes and captures of the
application on Windows and Linux (Fedora 8).

I tried out your examples, and was able to reproduce the differences you
describe.

3/ Run again outliner.rb :

  • create two root articles, create a child within the first root as
    shown in outliner_windows.jpg
  • close the application afterwards

On Windows, you will see traces indicating that there are selection
change events occuring during the close of the application ! On Linux,
you don’t have these events.
This might possibly be something fixable in wxRuby, but I’m not sure.
There’s a few places I’ve been surprised by ObjectPreviouslyDeleted
errors where events are getting sent to destroyed objects. I wonder if
wxRuby should try to explicitly disconnect event handlers on window
deletion - but there’s nothing in the C++ docs that suggests this.

cheers
alex

Hi,

2008/3/13, Alex F. [email protected]:

Thank you for the report and test cases. As you know wxWidgets wraps
native controls and the native event loop, and there are some subtle
differences sometimes. From experience I think there are more of these
in TreeCtrl than anywhere else - it’s probably because it’s the most
complex native-wrapped control.

Unfortunately, it is also one of the most useful control :-).

In most cases they’re wxWidgets issues, though ultimately the only way
to verify this is to write a C++ sample. As for official docs, we’re
limited to what’s in the wxWidgets docs, plus any annotations we make.
In the past I’ve turned up useful confirmations of subtler
cross-platform differences by searching for info on wxPython or C++ (eg
by searching for wxTreeCtrl). The wxWiki sometimes also has info.

Thanks for the links. But after a quick search, I haven’t found a
place where cross-platforms subtleties are documented. I will try a
deeper search.

Happy to apply patches that note these differences in our ruby docs.

I’m glad to add another little contribution to wxRuby.
What do you think about having a general section on cross-platforms
issues, or having such a section in each Control (when it is relevant)
?

On Windows, you will see traces indicating that there are selection
change events occuring during the close of the application ! On Linux,
you don’t have these events.
This might possibly be something fixable in wxRuby, but I’m not sure.
There’s a few places I’ve been surprised by ObjectPreviouslyDeleted
errors where events are getting sent to destroyed objects. I wonder if
wxRuby should try to explicitly disconnect event handlers on window
deletion - but there’s nothing in the C++ docs that suggests this.

This is exactly the problem I had. In the code of selection change
event, I take and put the content of the textctrl (in the right pane)
based on the selected item. But during the close of the window, the
textctrl has been already destroyed. So I received this
ObjectPreviouslyDeleted error.

It would be really great if wxRuby can deal with this issue.
Indeed, unlike the 2 other issues, this one makes the application crash.

Cheers.

Chauk-Mean.

Hi Chauk-Mean

Chauk-Mean P wrote:

based on the selected item. But during the close of the window, the
textctrl has been already destroyed. So I received this
ObjectPreviouslyDeleted error.

It would be really great if wxRuby can deal with this issue.
Indeed, unlike the 2 other issues, this one makes the application crash.

I’ve just committed a patch (SVN:1664) to fix these
ObjectPreviouslyDeleted errors sending events to destroyed Wx::Windows.

It seems to fix the samples; if possible, please test SVN HEAD to see
whether the problem is resolved for you.

thanks
alex