Skip to content

Commit

Permalink
Fix compilation with rust nightly
Browse files Browse the repository at this point in the history
The size of TypeId has changed
  • Loading branch information
ogoffart committed Jun 17, 2023
1 parent f66077a commit 947a73b
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions qmetaobject/src/scenegraph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FO
OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
use cpp::cpp;

use super::*;
use cpp::cpp;
use std::hash::{Hash, Hasher};

/// A typed node in the scene graph
///
Expand Down Expand Up @@ -150,7 +150,7 @@ impl SGNode<ContainerNode> {
F: FnMut(<Iter as Iterator>::Item, SGNode<T>) -> SGNode<T>,
{
let mut raw = self.raw;
let type_id = std::any::TypeId::of::<T>();
let type_id = get_type_hash::<T>();
let len = iter.len();
assert!(len <= 64, "There is a limit of 64 child nodes");
let mut mask = 0u64;
Expand Down Expand Up @@ -213,7 +213,7 @@ impl SGNode<ContainerNode> {
/// # }
/// ```
pub fn update_static<A: 'static, T: UpdateNodeFnTuple<A>>(&mut self, info: T) {
let type_id = std::any::TypeId::of::<A>();
let type_id = get_type_hash::<A>();
let mut mask = 0u64;
if self.raw.is_null() {
self.raw = cpp!(unsafe [type_id as "quint64"] -> *mut c_void as "QSGNode*" {
Expand Down Expand Up @@ -283,6 +283,12 @@ impl SGNode<ContainerNode> {
}
}

fn get_type_hash<T: std::any::Any>() -> u64 {
let mut hasher = std::collections::hash_map::DefaultHasher::new();
std::any::TypeId::of::<T>().hash(&mut hasher);
hasher.finish()
}

/*
pub trait UpdateNodeInfo {
Expand Down

0 comments on commit 947a73b

Please sign in to comment.