Skip to content

QObjectBox struct is redundant? #170

Open
@ratijas

Description

@ratijas

QObjectBox is only ever used for the old kefia example in a form of a patch.

Seems like the functionality was superseded by QObjectPinned, except there is no lifetime, and content is owned. I wonder, if there is any use for it?

Searching 73 files for "QObjectBox"

/qt/qmetaobject-rs/examples/kefia/0002-Port-to-qmetaobject-rs.patch:
   91   
   92  -    let qpckgs = QPackages::new(Packages {
   93: +    let qpckgs = QObjectBox::new(Packages {
   94           vec: gathered,
   95           list: list,

/qt/qmetaobject-rs/qmetaobject/src/lib.rs:
  214      pub use crate::{
  215          qml_register_type, qrc, qt_base_class, qt_method, qt_plugin, qt_property, qt_signal,
  216:         QAbstractListModel, QByteArray, QColor, QDate, QDateTime, QModelIndex, QObject, QObjectBox,
  217          QPointer, QQmlExtensionPlugin, QQuickItem, QQuickView, QRectF, QString, QTime, QVariant,
  218          QmlEngine,
  ...
  543  
  544  /// A wrapper around RefCell<T>, whose content cannot be move in memory
  545: pub struct QObjectBox<T: QObject + ?Sized>(Box<RefCell<T>>);
  546  
  547: impl<T: QObject> QObjectBox<T> {
  548      pub fn new(obj: T) -> Self {
  549:         QObjectBox(Box::new(RefCell::new(obj)))
  550      }
  551  }
  552  
  553: impl<T: QObject + Default> Default for QObjectBox<T> {
  554      fn default() -> Self {
  555          Self::new(Default::default())
  ...
  557  }
  558  
  559: impl<T: QObject + ?Sized> QObjectBox<T> {
  560      pub fn pinned(&self) -> QObjectPinned<T> {
  561          unsafe { QObjectPinned::new(&self.0) }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions