[Kde-bindings] strange behavior with qobject_cast
Stefano Crocco
stefano.crocco at alice.it
Mon Aug 11 21:10:37 UTC 2008
The qobject_cast method, while allowing to use the DocumentExtension
interfaces of KTextEditor (for example KTextEditor::AnnotationInterface) seems
to interact in a strange way with the object it's called upon. In particular,
I found that methods ending in ? seems to disappear after a call to
qobject_cast. Lowercased methods, instead, remain. Here's a little program
which produces this behavior:
require 'korundum4'
require 'ktexteditor'
data = KDE::AboutData.new "kruby", "", KDE::ki18n("KRuby"), "0.0.1"
KDE::CmdLineArgs.init [], data
app = KDE::Application.new
doc = KTextEditor::EditorChooser.editor('katepart').create_document nil
puts "Empty (before): #{doc.empty?}"
puts "Modified (before): #{doc.modified?}"
am = doc.qobject_cast(KTextEditor::AnnotationInterface).annotation_model
puts "Empty (after): #{doc.empty?}"
puts "Modified (after): #{doc.modified?}"
The error message is:
Empty (before): true
Modified (before): false
./prova.rb:14:in `method_missing': undefined method `empty?' for
#<KTextEditor::Document:0xb582c700 objectName=""> (NoMethodError)
from ./prova.rb:14
Replacing the calls to empty? and modified? with calls to is_empty and
is_modified shows that the latter still work.
Stefano
More information about the Kde-bindings
mailing list