UI: Improve properties view object safety
Use weak references on OBS objects that properties view reference in order to ensure that the objects are still valid. This fixes a crash where properties views would use objects without necessarily knowing whether they were still valid or not. Fixes obsproject/obs-studio#5862 Closes obsproject/obs-studio#5863
This commit is contained in:
@@ -97,7 +97,7 @@ private:
|
||||
QWidget *widget = nullptr;
|
||||
properties_t properties;
|
||||
OBSData settings;
|
||||
void *obj = nullptr;
|
||||
OBSWeakObjectAutoRelease weakObj;
|
||||
std::string type;
|
||||
PropertiesReloadCallback reloadCallback;
|
||||
PropertiesUpdateCallback callback = nullptr;
|
||||
@@ -163,6 +163,11 @@ public:
|
||||
|
||||
inline obs_data_t *GetSettings() const { return settings; }
|
||||
|
||||
inline void UpdateSettings() { callback(obj, nullptr, settings); }
|
||||
inline void UpdateSettings()
|
||||
{
|
||||
callback(OBSGetStrongRef(weakObj), nullptr, settings);
|
||||
}
|
||||
inline bool DeferUpdate() const { return deferUpdate; }
|
||||
|
||||
inline OBSObject GetObject() const { return OBSGetStrongRef(weakObj); }
|
||||
};
|
||||
|
Reference in New Issue
Block a user