Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix callback userdata mutability #1902

Merged
merged 3 commits into from
Nov 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion gdk4-wayland/src/auto/versions.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
Generated by gir (https://github.com/gtk-rs/gir @ eeb346bf25ed)
Generated by gir (https://github.com/gtk-rs/gir @ e5ad53c3ad05)
from gir-files (https://github.com/gtk-rs/gir-files @ f7af0e711383)
2 changes: 1 addition & 1 deletion gdk4-wayland/sys/versions.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
Generated by gir (https://github.com/gtk-rs/gir @ eeb346bf25ed)
Generated by gir (https://github.com/gtk-rs/gir @ e5ad53c3ad05)
from gir-files (https://github.com/gtk-rs/gir-files @ f7af0e711383)
2 changes: 1 addition & 1 deletion gdk4-win32/src/auto/versions.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
Generated by gir (https://github.com/gtk-rs/gir @ eeb346bf25ed)
Generated by gir (https://github.com/gtk-rs/gir @ e5ad53c3ad05)
from gir-files (https://github.com/gtk-rs/gir-files @ f7af0e711383)
2 changes: 1 addition & 1 deletion gdk4-win32/sys/versions.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
Generated by gir (https://github.com/gtk-rs/gir @ eeb346bf25ed)
Generated by gir (https://github.com/gtk-rs/gir @ e5ad53c3ad05)
from gir-files (https://github.com/gtk-rs/gir-files @ f7af0e711383)
2 changes: 1 addition & 1 deletion gdk4-x11/src/auto/versions.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
Generated by gir (https://github.com/gtk-rs/gir @ eeb346bf25ed)
Generated by gir (https://github.com/gtk-rs/gir @ e5ad53c3ad05)
from gir-files (https://github.com/gtk-rs/gir-files @ f7af0e711383)
2 changes: 1 addition & 1 deletion gdk4-x11/sys/versions.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
Generated by gir (https://github.com/gtk-rs/gir @ eeb346bf25ed)
Generated by gir (https://github.com/gtk-rs/gir @ e5ad53c3ad05)
from gir-files (https://github.com/gtk-rs/gir-files @ f7af0e711383)
2 changes: 1 addition & 1 deletion gdk4/src/auto/versions.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
Generated by gir (https://github.com/gtk-rs/gir @ eeb346bf25ed)
Generated by gir (https://github.com/gtk-rs/gir @ e5ad53c3ad05)
from gir-files (https://github.com/gtk-rs/gir-files @ f7af0e711383)
2 changes: 1 addition & 1 deletion gdk4/sys/versions.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
Generated by gir (https://github.com/gtk-rs/gir @ eeb346bf25ed)
Generated by gir (https://github.com/gtk-rs/gir @ e5ad53c3ad05)
from gir-files (https://github.com/gtk-rs/gir-files @ f7af0e711383)
2 changes: 1 addition & 1 deletion gsk4/src/auto/versions.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
Generated by gir (https://github.com/gtk-rs/gir @ eeb346bf25ed)
Generated by gir (https://github.com/gtk-rs/gir @ e5ad53c3ad05)
from gir-files (https://github.com/gtk-rs/gir-files @ f7af0e711383)
8 changes: 4 additions & 4 deletions gsk4/src/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ impl Path {
flags: PathForeachFlags,
func: P,
) -> glib::ControlFlow {
let func_data: P = func;
let mut func_data: P = func;
unsafe extern "C" fn func_func<
P: FnMut(&PathOperation, &graphene::Point, usize, f32) -> glib::ControlFlow,
>(
Expand All @@ -23,17 +23,17 @@ impl Path {
) -> glib::ffi::gboolean {
let op = from_glib(op);
let pts = from_glib_borrow(pts);
let callback: *mut P = user_data as *const _ as usize as *mut P;
let callback = user_data as *mut P;
(*callback)(&op, &pts, n_pts, weight).into_glib()
}
let func = Some(func_func::<P> as _);
let super_callback0: &P = &func_data;
let super_callback0: &mut P = &mut func_data;
unsafe {
from_glib(ffi::gsk_path_foreach(
self.to_glib_none().0,
flags.into_glib(),
func,
super_callback0 as *const _ as usize as *mut _,
super_callback0 as *mut _ as *mut _,
))
}
}
Expand Down
8 changes: 4 additions & 4 deletions gsk4/src/render_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ impl RenderNode {
error_func: P,
) -> Option<Self> {
assert_initialized_main_thread!();
let error_func_data: P = error_func;
let mut error_func_data: P = error_func;
unsafe extern "C" fn error_func_func<
P: FnMut(&ParseLocation, &ParseLocation, &glib::Error),
>(
Expand All @@ -48,16 +48,16 @@ impl RenderNode {
let start = from_glib_borrow(start);
let end = from_glib_borrow(end);
let error = from_glib_borrow(error);
let callback: *mut P = user_data as *const _ as usize as *mut P;
let callback = user_data as *mut P;
(*callback)(&start, &end, &error);
}
let error_func = Some(error_func_func::<P> as _);
let super_callback0: &P = &error_func_data;
let super_callback0: &mut P = &mut error_func_data;
unsafe {
from_glib_full(ffi::gsk_render_node_deserialize(
bytes.to_glib_none().0,
error_func,
super_callback0 as *const _ as usize as *mut _,
super_callback0 as *mut _ as *mut _,
))
}
}
Expand Down
2 changes: 1 addition & 1 deletion gsk4/sys/versions.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
Generated by gir (https://github.com/gtk-rs/gir @ eeb346bf25ed)
Generated by gir (https://github.com/gtk-rs/gir @ e5ad53c3ad05)
from gir-files (https://github.com/gtk-rs/gir-files @ f7af0e711383)
12 changes: 6 additions & 6 deletions gtk4/src/auto/cell_area.rs
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ pub trait CellAreaExt: IsA<CellArea> + 'static {
#[allow(deprecated)]
#[doc(alias = "gtk_cell_area_foreach")]
fn foreach<P: FnMut(&CellRenderer) -> bool>(&self, callback: P) {
let callback_data: P = callback;
let mut callback_data: P = callback;
unsafe extern "C" fn callback_func<P: FnMut(&CellRenderer) -> bool>(
renderer: *mut ffi::GtkCellRenderer,
data: glib::ffi::gpointer,
Expand All @@ -236,12 +236,12 @@ pub trait CellAreaExt: IsA<CellArea> + 'static {
(*callback)(&renderer).into_glib()
}
let callback = Some(callback_func::<P> as _);
let super_callback0: &P = &callback_data;
let super_callback0: &mut P = &mut callback_data;
unsafe {
ffi::gtk_cell_area_foreach(
self.as_ref().to_glib_none().0,
callback,
super_callback0 as *const _ as *mut _,
super_callback0 as *mut _ as *mut _,
);
}
}
Expand All @@ -255,7 +255,7 @@ pub trait CellAreaExt: IsA<CellArea> + 'static {
background_area: &gdk::Rectangle,
callback: P,
) {
let callback_data: P = callback;
let mut callback_data: P = callback;
unsafe extern "C" fn callback_func<
P: FnMut(&CellRenderer, &gdk::Rectangle, &gdk::Rectangle) -> bool,
>(
Expand All @@ -271,7 +271,7 @@ pub trait CellAreaExt: IsA<CellArea> + 'static {
(*callback)(&renderer, &cell_area, &cell_background).into_glib()
}
let callback = Some(callback_func::<P> as _);
let super_callback0: &P = &callback_data;
let super_callback0: &mut P = &mut callback_data;
unsafe {
ffi::gtk_cell_area_foreach_alloc(
self.as_ref().to_glib_none().0,
Expand All @@ -280,7 +280,7 @@ pub trait CellAreaExt: IsA<CellArea> + 'static {
cell_area.to_glib_none().0,
background_area.to_glib_none().0,
callback,
super_callback0 as *const _ as *mut _,
super_callback0 as *mut _ as *mut _,
);
}
}
Expand Down
6 changes: 3 additions & 3 deletions gtk4/src/auto/flow_box.rs
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ impl FlowBox {

#[doc(alias = "gtk_flow_box_selected_foreach")]
pub fn selected_foreach<P: FnMut(&FlowBox, &FlowBoxChild)>(&self, func: P) {
let func_data: P = func;
let mut func_data: P = func;
unsafe extern "C" fn func_func<P: FnMut(&FlowBox, &FlowBoxChild)>(
box_: *mut ffi::GtkFlowBox,
child: *mut ffi::GtkFlowBoxChild,
Expand All @@ -244,12 +244,12 @@ impl FlowBox {
(*callback)(&box_, &child)
}
let func = Some(func_func::<P> as _);
let super_callback0: &P = &func_data;
let super_callback0: &mut P = &mut func_data;
unsafe {
ffi::gtk_flow_box_selected_foreach(
self.to_glib_none().0,
func,
super_callback0 as *const _ as *mut _,
super_callback0 as *mut _ as *mut _,
);
}
}
Expand Down
6 changes: 3 additions & 3 deletions gtk4/src/auto/icon_view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,7 @@
#[allow(deprecated)]
#[doc(alias = "gtk_icon_view_selected_foreach")]
pub fn selected_foreach<P: FnMut(&IconView, &TreePath)>(&self, func: P) {
let func_data: P = func;
let mut func_data: P = func;
unsafe extern "C" fn func_func<P: FnMut(&IconView, &TreePath)>(
icon_view: *mut ffi::GtkIconView,
path: *mut ffi::GtkTreePath,
Expand All @@ -555,12 +555,12 @@
(*callback)(&icon_view, &path)
}
let func = Some(func_func::<P> as _);
let super_callback0: &P = &func_data;
let super_callback0: &mut P = &mut func_data;
unsafe {
ffi::gtk_icon_view_selected_foreach(
self.to_glib_none().0,
func,
super_callback0 as *const _ as *mut _,
super_callback0 as *mut _ as *mut _,
);
}
}
Expand Down
6 changes: 3 additions & 3 deletions gtk4/src/auto/list_box.rs
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ impl ListBox {

#[doc(alias = "gtk_list_box_selected_foreach")]
pub fn selected_foreach<P: FnMut(&ListBox, &ListBoxRow)>(&self, func: P) {
let func_data: P = func;
let mut func_data: P = func;
unsafe extern "C" fn func_func<P: FnMut(&ListBox, &ListBoxRow)>(
box_: *mut ffi::GtkListBox,
row: *mut ffi::GtkListBoxRow,
Expand All @@ -257,12 +257,12 @@ impl ListBox {
(*callback)(&box_, &row)
}
let func = Some(func_func::<P> as _);
let super_callback0: &P = &func_data;
let super_callback0: &mut P = &mut func_data;
unsafe {
ffi::gtk_list_box_selected_foreach(
self.to_glib_none().0,
func,
super_callback0 as *const _ as *mut _,
super_callback0 as *mut _ as *mut _,
);
}
}
Expand Down
6 changes: 3 additions & 3 deletions gtk4/src/auto/print_settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ impl PrintSettings {

#[doc(alias = "gtk_print_settings_foreach")]
pub fn foreach<P: FnMut(&str, &str)>(&self, func: P) {
let func_data: P = func;
let mut func_data: P = func;
unsafe extern "C" fn func_func<P: FnMut(&str, &str)>(
key: *const std::ffi::c_char,
value: *const std::ffi::c_char,
Expand All @@ -95,12 +95,12 @@ impl PrintSettings {
(*callback)(key.as_str(), value.as_str())
}
let func = Some(func_func::<P> as _);
let super_callback0: &P = &func_data;
let super_callback0: &mut P = &mut func_data;
unsafe {
ffi::gtk_print_settings_foreach(
self.to_glib_none().0,
func,
super_callback0 as *const _ as *mut _,
super_callback0 as *mut _ as *mut _,
);
}
}
Expand Down
12 changes: 6 additions & 6 deletions gtk4/src/auto/text_iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ impl TextIter {
pred: P,
limit: Option<&TextIter>,
) -> bool {
let pred_data: P = pred;
let mut pred_data: P = pred;
unsafe extern "C" fn pred_func<P: FnMut(char) -> bool>(
ch: u32,
user_data: glib::ffi::gpointer,
Expand All @@ -75,12 +75,12 @@ impl TextIter {
(*callback)(ch).into_glib()
}
let pred = Some(pred_func::<P> as _);
let super_callback0: &P = &pred_data;
let super_callback0: &mut P = &mut pred_data;
unsafe {
from_glib(ffi::gtk_text_iter_backward_find_char(
self.to_glib_none_mut().0,
pred,
super_callback0 as *const _ as *mut _,
super_callback0 as *mut _ as *mut _,
limit.to_glib_none().0,
))
}
Expand Down Expand Up @@ -332,7 +332,7 @@ impl TextIter {
pred: P,
limit: Option<&TextIter>,
) -> bool {
let pred_data: P = pred;
let mut pred_data: P = pred;
unsafe extern "C" fn pred_func<P: FnMut(char) -> bool>(
ch: u32,
user_data: glib::ffi::gpointer,
Expand All @@ -343,12 +343,12 @@ impl TextIter {
(*callback)(ch).into_glib()
}
let pred = Some(pred_func::<P> as _);
let super_callback0: &P = &pred_data;
let super_callback0: &mut P = &mut pred_data;
unsafe {
from_glib(ffi::gtk_text_iter_forward_find_char(
self.to_glib_none_mut().0,
pred,
super_callback0 as *const _ as *mut _,
super_callback0 as *mut _ as *mut _,
limit.to_glib_none().0,
))
}
Expand Down
6 changes: 3 additions & 3 deletions gtk4/src/auto/text_tag_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ impl TextTagTable {

#[doc(alias = "gtk_text_tag_table_foreach")]
pub fn foreach<P: FnMut(&TextTag)>(&self, func: P) {
let func_data: P = func;
let mut func_data: P = func;
unsafe extern "C" fn func_func<P: FnMut(&TextTag)>(
tag: *mut ffi::GtkTextTag,
data: glib::ffi::gpointer,
Expand All @@ -48,12 +48,12 @@ impl TextTagTable {
(*callback)(&tag)
}
let func = Some(func_func::<P> as _);
let super_callback0: &P = &func_data;
let super_callback0: &mut P = &mut func_data;
unsafe {
ffi::gtk_text_tag_table_foreach(
self.to_glib_none().0,
func,
super_callback0 as *const _ as *mut _,
super_callback0 as *mut _ as *mut _,
);
}
}
Expand Down
6 changes: 3 additions & 3 deletions gtk4/src/auto/tree_model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ pub trait TreeModelExt: IsA<TreeModel> + 'static {
#[allow(deprecated)]
#[doc(alias = "gtk_tree_model_foreach")]
fn foreach<P: FnMut(&TreeModel, &TreePath, &TreeIter) -> bool>(&self, func: P) {
let func_data: P = func;
let mut func_data: P = func;
unsafe extern "C" fn func_func<P: FnMut(&TreeModel, &TreePath, &TreeIter) -> bool>(
model: *mut ffi::GtkTreeModel,
path: *mut ffi::GtkTreePath,
Expand All @@ -43,12 +43,12 @@ pub trait TreeModelExt: IsA<TreeModel> + 'static {
(*callback)(&model, &path, &iter).into_glib()
}
let func = Some(func_func::<P> as _);
let super_callback0: &P = &func_data;
let super_callback0: &mut P = &mut func_data;
unsafe {
ffi::gtk_tree_model_foreach(
self.as_ref().to_glib_none().0,
func,
super_callback0 as *const _ as *mut _,
super_callback0 as *mut _ as *mut _,
);
}
}
Expand Down
6 changes: 3 additions & 3 deletions gtk4/src/auto/tree_selection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ impl TreeSelection {
#[allow(deprecated)]
#[doc(alias = "gtk_tree_selection_selected_foreach")]
pub fn selected_foreach<P: FnMut(&TreeModel, &TreePath, &TreeIter)>(&self, func: P) {
let func_data: P = func;
let mut func_data: P = func;
unsafe extern "C" fn func_func<P: FnMut(&TreeModel, &TreePath, &TreeIter)>(
model: *mut ffi::GtkTreeModel,
path: *mut ffi::GtkTreePath,
Expand All @@ -167,12 +167,12 @@ impl TreeSelection {
(*callback)(&model, &path, &iter)
}
let func = Some(func_func::<P> as _);
let super_callback0: &P = &func_data;
let super_callback0: &mut P = &mut func_data;
unsafe {
ffi::gtk_tree_selection_selected_foreach(
self.to_glib_none().0,
func,
super_callback0 as *const _ as *mut _,
super_callback0 as *mut _ as *mut _,
);
}
}
Expand Down
6 changes: 3 additions & 3 deletions gtk4/src/auto/tree_view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1228,7 +1228,7 @@ pub trait TreeViewExt: IsA<TreeView> + 'static {
#[allow(deprecated)]
#[doc(alias = "gtk_tree_view_map_expanded_rows")]
fn map_expanded_rows<P: FnMut(&TreeView, &TreePath)>(&self, func: P) {
let func_data: P = func;
let mut func_data: P = func;
unsafe extern "C" fn func_func<P: FnMut(&TreeView, &TreePath)>(
tree_view: *mut ffi::GtkTreeView,
path: *mut ffi::GtkTreePath,
Expand All @@ -1240,12 +1240,12 @@ pub trait TreeViewExt: IsA<TreeView> + 'static {
(*callback)(&tree_view, &path)
}
let func = Some(func_func::<P> as _);
let super_callback0: &P = &func_data;
let super_callback0: &mut P = &mut func_data;
unsafe {
ffi::gtk_tree_view_map_expanded_rows(
self.as_ref().to_glib_none().0,
func,
super_callback0 as *const _ as *mut _,
super_callback0 as *mut _ as *mut _,
);
}
}
Expand Down
2 changes: 1 addition & 1 deletion gtk4/src/auto/versions.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
Generated by gir (https://github.com/gtk-rs/gir @ eeb346bf25ed)
Generated by gir (https://github.com/gtk-rs/gir @ e5ad53c3ad05)
from gir-files (https://github.com/gtk-rs/gir-files @ f7af0e711383)
Loading
Loading