Closed loloof64 closed 4 years ago
Hi,
qmake-qt5 --version
.Qt::Application
and then exits?Hello,
sudo apt-get install qtbase5-dev
(and the libqt5opengl5-dev package also)The program which I've been tested just with Qt::Application.exec()
require "qt5"
# Create the application first
qApp = Qt::Application.new
# And now, start it!
Qt::Application.exec
Regards
That behaviour is expected, as you're starting the event loop with the call to .exec
. This kicks off a Qt application and will only return after it has been exited, which usually also ends the process. Just remove that line and retry.
Also, I need the Qt version that is installed, not how you installed it.
For future reference, the version of Qt 5 in Mint 18.3/Ubuntu Xenial is 5.5.1.
EDIT: Oh wow, I timed that comment perfectly. 👌
@kirbyfan64 So kinda old, but the oldest version there are shipped bindings for, so that's fine. Thanks
Ok : this works perfectly
require "qt5"
# Create the application first
qApp = Qt::Application.new
# And now, start it!
Could it be that the order the finalizers are called is 'wrong'?
Try running the hello world sample without the last five lines:
# We're ready for showtime
window.show
# And now, start it!
Qt::Application.exec
I hope it still crashes?
Did you mean the following ?
require "qt5"
# Create the application first
qApp = Qt::Application.new
# We'll use a normal widget as window
window = Qt::Widget.new
window.window_title = "Hello, World!"
# We need to give it a layout
layout = Qt::VBoxLayout.new
window.layout = layout
# Create a label and a button, and push it into the layout
button = Qt::PushButton.new "Click me!"
label = Qt::Label.new "Click the button!"
layout << button << label
# On every press on `button`, we want to change the label.
counter = 0
button.on_pressed do # This is how you connect to the `pressed` signal
counter += 1
label.text = "You pressed #{counter} times!"
end
I've just tried this code and it returns immediately without crashing (but without showing any window).
Also I build the executable with the command crystal build hello_world.cr
. Maybe should I have used shard for this.
Yes that's what I meant. Kinda sucks that it doesn't crash though. Back to square 1.
You'd have to figure out what object lies at the address given in the log in your opening post. You can do that using gdb, maybe valgrind could also help to show what's going on, etc.. But that's nothing I could give you easy directions for in terms of this issue tracker.
I assume it has something to do with the garbage collector fighting with Qt under certain circumstances. One might delete
an object before the other tries to use it or delete
s it too. These kind of things are time consuming to figure out (My assumption might be totally wrong!), and probably tedious to fix afterwards as well.
Sorry to bring bad news on this.
Unfortunately I don't know how to use gdb nor valgrind. Anyway thank you very much for your patience and for having trying to help me.
Regards
@loloof64 Try building your application in debug mode and then running valgrind path-to-my-app
. Valgrind is a memory checker; it'll print out any potential wrong memory accesses.
Thank you :)
$ valgrind ./hello_world 2> errors
Produced me the errors file I've attached errors.zip
Otherwise
$ crystal run -d ./hello_world
Syntax error in hello_world:1: unknown token: '\u{7f}'
ELF>�Y@�lX@8
^
This may have been solved by a temporary workaround that now exists in bindgen (added in commit https://github.com/Papierkorb/bindgen/commit/01265f9c6c00df89a7bc26c1faf5b11df6c60bd8 and tracked for further refinement in https://github.com/Papierkorb/bindgen/issues/37)
I am going to close this ticket since in addition to the previous comment I have also tested myself and can't reproduce the issue. Please reopen or submit a new issue if the problem persists.
Hello, first congratulation for such a work and for the simplicity of your README. (The only drawback is that you don't mention the need to install the libgc-dev package).
I've built the HelloWorld sample on LinuxMint 18.3 64bit, but when exiting the application (reproduced after several compilation-launch), I get a segmentation fault. I don't know if this come from Crystal or from the qt binding
And again, great work.