diff --git a/src/output.h b/src/output.h --- a/src/output.h +++ b/src/output.h @@ -169,6 +169,13 @@ void setClones(QList outputlist); void setEdid(const QByteArray &rawData); + + /** + * edid returns the output's EDID information if available. + * + * The output maintains ownership of the returned Edid, so the caller should not delete it. + * Note that the edid is only valid as long as the output is alive. + */ Edid* edid() const; /** diff --git a/src/output.cpp b/src/output.cpp --- a/src/output.cpp +++ b/src/output.cpp @@ -66,13 +66,14 @@ modeList.insert(otherMode->id(), otherMode->clone()); } if (other.edid) { - edid = other.edid->clone(); + edid.reset(other.edid->clone()); } } QString biggestMode(const ModeList& modes) const; bool compareModeList(const ModeList& before, const ModeList& after); + QScopedPointer edid; int id; QString name; Type type; @@ -461,12 +462,12 @@ void Output::setEdid(const QByteArray& rawData) { Q_ASSERT(d->edid.isNull()); - d->edid = new Edid(rawData); + d->edid.reset(new Edid(rawData)); } Edid *Output::edid() const { - return d->edid; + return d->edid.data(); } QSize Output::sizeMm() const @@ -564,8 +565,7 @@ // Non-notifyable changes if (other->d->edid) { - delete d->edid; - d->edid = other->d->edid->clone(); + d->edid.reset(other->d->edid->clone()); } blockSignals(keepBlocked);