Forum: wxRuby Copy/Paste problems in dragdrop.rb

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
2885208195c6ed44170cd47d97113503?d=identicon&s=25 Ridge McGhee (rmcghee)
on 2009-01-22 02:06
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)


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)


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 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
06f6780c99d4a8dd71f2b474082ea9ce?d=identicon&s=25 Alex Fenton (Guest)
on 2009-01-23 13:03
(Received via mailing list)
Hi Ridge

Ridge Mcghee 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
2885208195c6ed44170cd47d97113503?d=identicon&s=25 Ridge McGhee (rmcghee)
on 2009-02-07 04:56
Alex Fenton wrote:
> Hi Ridge
>
> Ridge Mcghee 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
3396e4a3df8a840faec520af8555a400?d=identicon&s=25 Mario Steele (Guest)
on 2009-02-07 07:35
(Received via mailing list)
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.
00109e19a784b64f81b483a5dbec690a?d=identicon&s=25 Chauk-Mean Proum (chauk-mean)
on 2009-02-07 10:42
(Received via mailing list)
Hi Ridge,

2009/2/7 Ridge Mcghee <lists@ruby-forum.com>:
> 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.
06f6780c99d4a8dd71f2b474082ea9ce?d=identicon&s=25 Alex Fenton (Guest)
on 2009-02-07 19:14
(Received via mailing list)
Ridge Mcghee 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
This topic is locked and can not be replied to.