woboq / qmetaobject-rs

Integrate Qml and Rust by building the QMetaObject at compile time.
MIT License
647 stars 89 forks source link

Add basic QSettings wrapper #285

Closed direc85 closed 1 year ago

direc85 commented 1 year ago

Upstream-compatible version of https://github.com/whisperfish/qmetaobject-rs/pull/2


Attempt of adding QSettings wrapper. This was a bit tricky because QSettings can't be copied, so we have to return QSettings * instead, and handle the dereference in the client. This leads into having these in the use-side implementation, but there's no obvious way to get rid of that to me:

fn inner(&self) -> &QSettings {
    unsafe { self.inner_ptr.as_ref().unwrap() }
}

fn inner_mut(&mut self) -> &mut QSettings {
    unsafe { self.inner_ptr.as_mut().unwrap() }
}
rubdos commented 1 year ago

https://github.com/woboq/qmetaobject-rs/actions/runs/4649514331/jobs/8227901989?pr=285 interesting.

direc85 commented 1 year ago

Interesting indeed. Something about Windows and tempfile, I guess. I have a Windows 'puter somewhere still, so I can see what's up with that.

direc85 commented 1 year ago

It turned out to be a combination of default file extension being .ini (on all platforms?) and Linux conveniently using IniFormat when set to NativeFormat.

I must also say that it would have been convenient to have all tests run to completion even if one test fails. Could that be changed in the future? Thanks...

direc85 commented 1 year ago

This just became a blocker to Whisperfish for using master now that we have Rust 1.72 - thanks to the marvelous efforts of @rubdos - so could this please be merged to master? Thanks!

ogoffart commented 1 year ago

sorry, i didn't see the updated patch.

direc85 commented 1 year ago

No worries! Thank you!