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

Generate code for new from_glib_borrow signature #895

Merged
merged 1 commit into from
Apr 5, 2020

Conversation

sdroege
Copy link
Member

@sdroege sdroege commented Apr 5, 2020

See gtk-rs/glib#605


This works fine for glib, gio, gdk, gdk-pixbuf, pango, pangocairo and gtk (I have local branches for all of them that I will submit once this is merged). Please review but don't merge until I've also checked GStreamer :)

@sdroege
Copy link
Member Author

sdroege commented Apr 5, 2020

CC @EPashkin @GuillaumeGomez

@GuillaumeGomez
Copy link
Member

Seems correct to me. :)

@sdroege
Copy link
Member Author

sdroege commented Apr 5, 2020

Good to go for me, GStreamer builds. Just need to clean up some more things there.

@EPashkin
Copy link
Member

EPashkin commented Apr 5, 2020

Git part looks good, but glib#605 IMHO need rebase and fix

From ba8dd46c1731b0e897aaddb3eb799c303731c240 Mon Sep 17 00:00:00 2001
From: Evgenii Pashkin <eapashkin@gmail.com>
Date: Sun, 5 Apr 2020 16:16:26 +0300
Subject: [PATCH] tmp

---
 src/log.rs                  | 12 ++++++------
 src/main_context_futures.rs |  4 ++--
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/src/log.rs b/src/log.rs
index 2edd728..54eabdd 100644
--- a/src/log.rs
+++ b/src/log.rs
@@ -128,8 +128,8 @@ pub fn log_set_handler<P: Fn(&str, LogLevel, &str) + Send + Sync + 'static>(
         message: *const libc::c_char,
         user_data: glib_sys::gpointer,
     ) {
-        let log_domain: GString = from_glib_borrow(log_domain);
-        let message: GString = from_glib_borrow(message);
+        let log_domain: Borrowed<GString> = from_glib_borrow(log_domain);
+        let message: Borrowed<GString> = from_glib_borrow(message);
         let callback: &P = &*(user_data as *mut _);
         (*callback)(log_domain.as_str(), from_glib(log_level), message.as_str());
     }
@@ -192,7 +192,7 @@ pub fn set_print_handler<P: Fn(&str) + Send + Sync + 'static>(func: P) {
             Some(ref handler) => Some(Arc::clone(handler)),
             None => None,
         } {
-            let string: GString = from_glib_borrow(string);
+            let string: Borrowed<GString> = from_glib_borrow(string);
             (*callback)(string.as_str())
         }
     }
@@ -223,7 +223,7 @@ pub fn set_printerr_handler<P: Fn(&str) + Send + Sync + 'static>(func: P) {
             Some(ref handler) => Some(Arc::clone(handler)),
             None => None,
         } {
-            let string: GString = from_glib_borrow(string);
+            let string: Borrowed<GString> = from_glib_borrow(string);
             (*callback)(string.as_str())
         }
     }
@@ -260,8 +260,8 @@ pub fn log_set_default_handler<P: Fn(&str, LogLevel, &str) + Send + Sync + 'stat
             Some(ref handler) => Some(Arc::clone(handler)),
             None => None,
         } {
-            let log_domain: GString = from_glib_borrow(log_domain);
-            let message: GString = from_glib_borrow(message);
+            let log_domain: Borrowed<GString> = from_glib_borrow(log_domain);
+            let message: Borrowed<GString> = from_glib_borrow(message);
             (*callback)(log_domain.as_str(), from_glib(log_levels), message.as_str());
         }
     }
diff --git a/src/main_context_futures.rs b/src/main_context_futures.rs
index 33fe809..5df38bb 100644
--- a/src/main_context_futures.rs
+++ b/src/main_context_futures.rs
@@ -10,7 +10,7 @@ use glib_sys;
 use std::mem;
 use std::pin;
 use std::ptr;
-use translate::{from_glib_borrow, from_glib_full, mut_override, ToGlib};
+use translate::{from_glib_borrow, from_glib_full, mut_override, ToGlib, Borrowed};
 use ThreadGuard;
 
 use MainContext;
@@ -194,7 +194,7 @@ impl TaskSource {
 
     fn poll(&mut self) -> Poll<()> {
         let source = &self.source as *const _;
-        let executor: MainContext =
+        let executor: Borrowed<MainContext> =
             unsafe { from_glib_borrow(glib_sys::g_source_get_context(mut_override(source))) };
 
         assert!(
-- 
2.25.1

@sdroege
Copy link
Member Author

sdroege commented Apr 5, 2020

Git part looks good, but glib#605 IMHO need rebase and fix

Yes, I'm going to update that and all the other crates once this is merged.

@EPashkin
Copy link
Member

EPashkin commented Apr 5, 2020

Not need to wait CI, it will fail anyway.

@EPashkin EPashkin merged commit 997cbcb into gtk-rs:master Apr 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants