[Kde-bindings] crash when using a KDE::PageDialog without Application#exec
Stefano Crocco
stefano.crocco at alice.it
Tue Aug 26 06:59:20 UTC 2008
On Monday 25 August 2008, Richard Dale wrote:
> In app.exec a flag gets set when the app terminates, to stop Ruby from
> deleting everything. So you could add this to the end of your script, but
> it's a bit ugly as it isn't really supposed to be in the public api:
>
> Qt::Internal.application_terminated = true
>
> Maybe there is better way of trapping when a qtruby or korundum script
> exits, but I can't think of one.
>
> -- Richard
Thanks for the information. The reason I run into this issue is that I'm using
rspec to write unit tests for my application and, given that they should run
without human intervention, I don't want the event loop to start. However,
right now this is not a great problem for me, since this was the only test
which gave me trouble.
As for how to trap the exit of the script, I tried putting the line you
suggested in a block passed to at_exit and add it to the example script I
posted in my first mail, like this:
require 'korundum4'
class Dlg < KDE::PageDialog
define_method(:add_page){puts "ADDED"}
private :add_page
def test_private
end
private :test_private
end
at_exit{Qt::Internal.application_terminated = true}
data = KDE::AboutData.new "test", "", KDE::ki18n("test"), "0.0.1"
KDE::CmdLineArgs.init [], data
app = KDE::Application.new
dlg = Dlg.new
w = Qt::Label.new "TEST"
it = KDE::PageWidgetItem.new w
dlg.add_page it
puts "created"
It worked correctly in this simple case, but I don't know whether it would
work in more complex cases and whether it would have unwanted side effects.
Stefano
More information about the Kde-bindings
mailing list