[Kde-bindings] ruby binding and Qt::TextEdit::ExtraSelection

Melton, Ryan rmelton at ball.com
Thu Feb 11 20:10:54 UTC 2010


Richard -

 

I've found the root cause to Jason's problem in the email below, but I'm not sure how to fix it.   The root cause is that the memory address of a class is the same as the memory address of the first data member of that class.   

 

For example from qtextedit.h here is the definition of ExtraSelection:

 

    struct ExtraSelection

    {

        QTextCursor cursor;

        QTextCharFormat format;

    };

 

Now here is some ruby code that tries to use it:

 

my_object = Qt::TextEdit::ExtraSelection.new

puts my_object.cursor.class

 

Fails and returns my_object instead of a new ruby object wrapping the Qt::TextCursor.

 

But,

 

my_object = Qt::TextEdit::ExtraSelection.new

puts my_object.format.class

 

Works and returns a Qt::TextCharFormat because format is the second data member in the class and has a different memory address from the class itself.

 

The problem occurs in marshall_basetypes.h : void marshall_to_ruby<SmokeClassWrapper>(Marshall *m) when getPointerObject is called with a memory address that is the same as the memory address of the Qt::TextEdit::ExtraSelection class.

 

Any ideas?

 

Thanks,

Ryan

 

From: Thomas, Jason M (Software) [mailto:jmthomas at ball.com] 
Sent: Monday, February 08, 2010 2:40 PM
To: kde-bindings at kde.org
Subject: [Kde-bindings] ruby binding and Qt::TextEdit::ExtraSelection

 

I'm having problems using Qt::TextEdit::ExtraSelection under ruby. The following code shows the problem:

 

  class MyTextEdit < Qt::TextEdit

    def highlight

      selection = Qt::TextEdit::ExtraSelection.new

      selection.cursor = textCursor()

      STDOUT.puts "selection.cursor:#{selection.cursor} textCursor:#{textCursor()}"

    end

  end

 

When instantiating MyTextEdit and calling highlight the following output is printed:

    selection.cursor:#<Qt::TextEdit::ExtraSelection:0x36c1968> textCursor:#<Qt::TextCursor:0x36bebd8>

 

For some reason when I try to set the cursor property it runs but doesn't appear to actually change the underlying property. This class is different from most Qt classes in that it doesn't have explicit getter and setter methods. I don't know if that is playing a role or not. 

 

BTW: What I'm trying to accomplish is to highlight and unhighlight individual lines in the TextEdit and this looked like the recommended way to do it.

 

Jason

 
 
This message and any enclosures are intended only for the addressee.  Please  
notify the sender by email if you are not the intended recipient.  If you are  
not the intended recipient, you may not use, copy, disclose, or distribute this  
message or its contents or enclosures to any other person and any such actions  
may be unlawful.  Ball reserves the right to monitor and review all messages  
and enclosures sent to or from this email address.



This message and any enclosures are intended only for the addressee.  Please  
notify the sender by email if you are not the intended recipient.  If you are  
not the intended recipient, you may not use, copy, disclose, or distribute this  
message or its contents or enclosures to any other person and any such actions  
may be unlawful.  Ball reserves the right to monitor and review all messages  
and enclosures sent to or from this email address.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kde-bindings/attachments/20100211/b89f88d0/attachment.html>


More information about the Kde-bindings mailing list