Bug 100165 - qtruby Qt::Socket::connectToHost fails on open call
Summary: qtruby Qt::Socket::connectToHost fails on open call
Status: RESOLVED FIXED
Alias: None
Product: bindings
Classification: Developer tools
Component: general (show other bugs)
Version: unspecified
Platform: unspecified Linux
: NOR normal
Target Milestone: ---
Assignee: kde-bindings
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-02-24 15:13 UTC by Caleb Tennis
Modified: 2005-02-28 20:36 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Caleb Tennis 2005-02-24 15:13:18 UTC
Version:            (using KDE KDE 3.3.92)
OS:                Linux

It is a known problem:
http://rubyforge.org/forum/forum.php?thread_id=1832&forum_id=723

My workaround for this, which could probably be integrated into qtruby.rb somehow is to do this:


module Kernel
  
  def undef_open
    alias_method :aliased_open, :open 
    undef_method :open
  end
  
  def def_open
    alias_method :open, :aliased_open
    undef_method :aliased_open
  end
  
end

Then, anywhere where I do a connectToHost, I simply put an undef_open and def_open around it.

It may be possible to directly override connectToHost and provide this functionality as well.
Comment 1 Richard Dale 2005-02-25 09:36:19 UTC
On Thursday 24 February 2005 15:13, Caleb Tennis wrote:
> ------- You are receiving this mail because: -------
> You are the assignee for the bug, or are watching the assignee.
>
> http://bugs.kde.org/show_bug.cgi?id=100165
>            Summary: qtruby Qt::Socket::connectToHost fails on open call
>            Product: bindings
>            Version: unspecified
>           Platform: unspecified
>         OS/Version: Linux
>             Status: NEW
>           Severity: normal
>           Priority: NOR
>          Component: general
>         AssignedTo: kde-bindings mail kde org
>         ReportedBy: caleb gentoo org
>
>
> Version:            (using KDE KDE 3.3.92)
> OS:                Linux
>
> It is a known problem:
> http://rubyforge.org/forum/forum.php?thread_id=1832&forum_id=723
>
> My workaround for this, which could probably be integrated into qtruby.rb
> somehow is to do this:
>
>
> module Kernel
>
>   def undef_open
>     alias_method :aliased_open, :open
>     undef_method :open
>   end
>
>   def def_open
>     alias_method :open, :aliased_open
>     undef_method :aliased_open
>   end
>
> end
>
> Then, anywhere where I do a connectToHost, I simply put an undef_open and
> def_open around it.
>
> It may be possible to directly override connectToHost and provide this
> functionality as well. _______________________________________________
Which version of QtRuby are you using? I fixed this when the problem when it 
was first reported. Here is the code from qtruby.rb:

module Kernel
	alias_method :_exec, :exec
	undef_method :exec
	
	# Kernel has a method called open() which takes a String as
	# the first argument. When a call is made to an open() method
	# in the Qt classes, it messes up the method_missing()
	# logic to divert it to the Smoke library. This code
	# fixes that problem by calling the appropriate method based
	# on the type of the first arg.
	alias_method :_open, :open
	
	def open(*k)
		if k.length > 0 and k[0].kind_of? String
			_open(*k)
		else
			method_missing(:open, *k)
		end
	end
end

So it looks at the args passed to Kernel.open() and calls the standard ruby 
version if the first arg is a String.

-- Richard

Comment 2 Caleb Tennis 2005-02-25 13:37:26 UTC
Should be 3.3.2, is it only fixed in 3.4 ?
Comment 3 Richard Dale 2005-02-28 20:35:29 UTC
On Friday 25 February 2005 13:37, Caleb Tennis wrote:
> ------- You are receiving this mail because: -------
> You are the assignee for the bug, or are watching the assignee.
>
> http://bugs.kde.org/show_bug.cgi?id=100165
>
>
>
>
> ------- Additional Comments From caleb gentoo org  2005-02-25 13:37 -------
> Should be 3.3.2, is it only fixed in 3.4 ?
It's fixed in QtRuby 1.0.6 onwards - the change was added on Dec 30th last 
year.

-- Richard

Comment 4 Caleb Tennis 2005-02-28 20:36:21 UTC
Allrighty, let's mark it as fixed