Use QMetaObject::invokeMethod in libobs callbacks

Doing this ensures Qt thread safety when adding/removing sources and
scenes, because it will defer the function call to the main thread.
This commit is contained in:
jp9000
2014-02-02 17:03:55 -07:00
parent cfa62354cd
commit 37ed83acec
4 changed files with 54 additions and 49 deletions

View File

@@ -314,14 +314,14 @@ static void obs_sceneitem_destroy(obs_sceneitem_t item)
int obs_sceneitem_addref(obs_sceneitem_t item)
{
return ++item->ref;
return item ? ++item->ref : 0;
}
int obs_sceneitem_release(obs_sceneitem_t item)
{
int ref = 0;
if (item ) {
if (item) {
ref = --item->ref;
if (!ref)
obs_sceneitem_destroy(item);

View File

@@ -221,24 +221,18 @@ static void obs_source_destroy(obs_source_t source)
int obs_source_addref(obs_source_t source)
{
assert(source != NULL);
if (!source)
return 0;
return ++source->refs;
return source ? ++source->refs : 0;
}
int obs_source_release(obs_source_t source)
{
int refs;
int refs = 0;
assert(source != NULL);
if (!source)
return 0;
refs = --source->refs;
if (refs == 0)
obs_source_destroy(source);
if (source) {
refs = --source->refs;
if (refs == 0)
obs_source_destroy(source);
}
return refs;
}