Closed BlobCodes closed 2 years ago
Do you remember on what version it used to work? So will be easy to find what changed.
I just tried all recent commits:
Also, the code I posted with the issue doesn't actually work (needs to be wrapped in a Gtk;:Application#activate_signal
).
Here's working code:
require "gtk4"
app = Gtk::Application.new("test.test", :flags_none)
app.activate_signal.connect do
rect = Graphene::Rect.zero
snapshot = Gtk::Snapshot.new
texture = Gdk::Texture.new_from_filename("/path/to/image.ext")
snapshot.append_texture(texture, rect)
end
app.run
Interesting, because running ./bin/compare-api v0.9.0 v0.10.0
shows no difference in graphene-1.0/rect.cr
, so it needs more investigation... :thinking:
I get a:
$ crystal run snapshot.cr
**
Gtk:ERROR:../gtk/gtk/gtksnapshot.c:237:gtk_snapshot_get_current_state: assertion failed: (size > 0)
Bail out! Gtk:ERROR:../gtk/gtk/gtksnapshot.c:237:gtk_snapshot_get_current_state: assertion failed: (size > 0)
Program received and didn't handle signal IOT (6)
Errror when running this with a png file.
I just generated gtk from the two commits mentioned above. In all the relevant files, the only change was this:
@@ -43,20 +43,6 @@ module Gtk
LibGtk.gtk_snapshot_get_type
end
- # Creates a new `GtkSnapshot`.
- def initialize
- # gtk_snapshot_new: (Constructor)
- # Returns: (transfer full)
-
- # C call
- _retval = LibGtk.gtk_snapshot_new
-
- # Return value handling
-
- @pointer = _retval
- LibGObject.g_object_set_qdata(_retval, GICrystal::INSTANCE_QDATA_KEY, Pointer(Void).new(object_id))
- end
-
# Appends a stroked border rectangle inside the given @outline.
#
# The four sides of the border can have different widths and colors.
..so I went to the GTK git repo to find out how gtk_snapshot_new
is defined:
/**
* gtk_snapshot_new:
*
* Creates a new `GtkSnapshot`.
*
* Returns: a newly-allocated `GtkSnapshot`
*/
GtkSnapshot *
gtk_snapshot_new (void)
{
GtkSnapshot *snapshot;
snapshot = g_object_new (GTK_TYPE_SNAPSHOT, NULL);
gtk_snapshot_states_init (&snapshot->state_stack);
gtk_snapshot_nodes_init (&snapshot->nodes);
gtk_snapshot_push_state (snapshot,
NULL,
gtk_snapshot_collect_default,
NULL);
return snapshot;
}
It turns out the function gtk_snapshot_new
does a lot more than just g_object_new
.
I think the commit mentioned above should be partially reverted - constructors with empty params should be generated.
The following code:
Causes the program to crash with the following message:
This used to work in an older version of GI-Crystal.
GI-Crystal version: 0.12.0 Crystal version: 1.4.1