Copy/Paste problems in dragdrop.rb

Windows XP Professional + SP3
ruby 1.8.6
wxRuby 1.9.9

The drag and drop sample results in segmentation faults.

Instructions to reproduce:

  1. Run dragdrop.rb (…/samples/dragdrop/dragdrop.rb)

  2. Click on Clipboard tab

  3. Click on Copy image button
    (Immediate segmentation fault on my system)

  4. Run dragdrop.rb

  5. Click on Clipboard tab

  6. Type some text in TextCtrl

  7. Click the Copy text button

  8. Click the Paste button 3 times
    (Segmentation fault 7 times in 10)

  9. Repeat 4. and 5.
    (Segmentation fault 10 times in 10 within a few iterations)

  10. Run dragdrop.rb

  11. Click on Clipboard tab

  12. Type some text in TextCtrl

  13. Click the Copy text button

  14. Resize the window

  15. Click the Paste button
    (Immediate segmentation fault)

I believe I installed wxSugar but am not using it
(no require ‘wxSugar’ in dragdrop.rb)
Interestingly, …/wx/accessors.rb seems to reference
wxSugar.

Anyone else able to reproduce?

Ridge

Hi Ridge

Ridge M. wrote:

Windows XP Professional + SP3
ruby 1.8.6
wxRuby 1.9.9

The drag and drop sample results in segmentation faults.

Thanks for the report. I hadn’t realised there was this problem in
1.9.9.

The development version of wxRuby contains a major rework of the classes
used in DnD and Clipboard, which have been very tricky to port because
of the way they’re designed in wxWidgets.

We’ve still got one problem with Clipboard on Windows, but this is a
blocking issue (actually, now the only one) for wxRuby 2.0, so it will
be fixed for the next release.

cheers
alex

Alex F. wrote:

Hi Ridge

Ridge M. wrote:

Windows XP Professional + SP3
ruby 1.8.6
wxRuby 1.9.9

The drag and drop sample results in segmentation faults.

Thanks for the report. I hadn’t realised there was this problem in
1.9.9.

The development version of wxRuby contains a major rework of the classes
used in DnD and Clipboard, which have been very tricky to port because
of the way they’re designed in wxWidgets.

We’ve still got one problem with Clipboard on Windows, but this is a
blocking issue (actually, now the only one) for wxRuby 2.0, so it will
be fixed for the next release.

cheers
alex

Hi Alex,

Just a note –
I repeated the above tests on 1.9.10.
The good news is that Problem #1 has disappeared.
The bad news is that Problems #2 and #3 still seg fault.
I didn’t know whether “next release” meant 1.9.10 or 2.0.

Ridge

1.9.10 is wxRuby 2.0 RC1, but RubyGems doesn’t like us using this kind
of
naming scheme, so we have to use 1.9.10 to satisfy RubyGems.

Hi Ridge,

2009/2/7 Ridge M. [email protected]:

I repeated the above tests on 1.9.10.
The good news is that Problem #1 has disappeared.
The bad news is that Problems #2 and #3 still seg fault.

  1. Run dragdrop.rb
  2. Click on Clipboard tab
  3. Type some text in TextCtrl
  4. Click the Copy text button
  5. Click the Paste button 3 times
    (Segmentation fault 7 times in 10)
  6. Repeat 4. and 5.
    (Segmentation fault 10 times in 10 within a few iterations)

I’ve been able to reproduce this issue with wxRuby-1.9.10, ruby-1.9.1
both on MinGW and Linux.
There is no need to repeat 4 but I have to click on the Paste button
many times.
On Linux, sometimes the text becomes corrupted, other times the app seg
faults.

  1. Run dragdrop.rb
  2. Click on Clipboard tab
  3. Type some text in TextCtrl
  4. Click the Copy text button
  5. Resize the window
  6. Click the Paste button
    (Immediate segmentation fault)

I’ve been able to reproduce this issue with wxRuby-1.9.10, ruby-1.9.1
both on MinGW and Linux.
Sometimes, the crash occurs after the first click on Paste button,
other times it occurs after several clicks on this button.
Also on Linux, sometimes the text becomes corrupted, other times the
app seg faults.

Chauk-Mean.

Ridge M. wrote:

Just a note –
I repeated the above tests on 1.9.10.
The good news is that Problem #1 has disappeared.

Thanks for the update on these problems.

The bad news is that Problems #2 and #3 still seg fault.

I can reproduce this on Linux. Fortunately I can see what the bug is,
and it’s not hard to fix.

If this is causing a problem in your own program, you can work round it
for now by retaining a reference to the data object being set in an
instance variable. For example, in the clipboard sample, tweak the
on_copy_text method to something like

@data_obj = Wx::TextDataObject.new(@text.value)
clipboard.data = @data_obj

For reference, what’s happening is that the ruby data object is getting
swept up by garbage collection, because it was only referenced by a
local variable which is out of scope. When the time comes to retrieve
the data to paste it, wxRuby tries to call ‘get_text’ on that object -
but it’s now disappeared so there’s a crash.

I didn’t know whether “next release” meant 1.9.10 or 2.0.

The only real issues outstanding for 2.0 are these ones relating to
clipboard. We decided to release 1.9.10 / RC1 as there were many other
fixes and improvements which were worth getting into circulation.

cheers
alex