提交 18026c36 编写于 作者: J jp9000

No need to initialize map value to 0 (bug fix)

There's no need to initialize the map value to 0.  What was happening is
that obs_scene_add was adding a ref to a non-existent value, which
simply created it and added 1, which is perfectly fine.  Then,
obs_add_source would set the ref to 0, overwriting the existing value.

So this meant that if you didn't call them in the right order, it
wouldn't work properly, and would break, which was pretty stupid.

Turns out that if you access a map value that doesn't exist, it'll
create one with the default constructor of that type.  In this case, int
will initialize to 0, which was exactly what we wanted in the first
place, and defeats the purpose of even needing to initialize the value
to 0.  So, there's no need to manually set it to 0 in
OBSBasic::SourceAdded, or worry about the order in which the functions
are called.

Just goes to show you have to be careful with reference counting.
上级 a01b59fb
......@@ -993,8 +993,6 @@ void OBSBasic::SourceAdded(void *data, calldata_t params)
QMetaObject::invokeMethod(window,
"AddScene",
Q_ARG(OBSSource, OBSSource(source)));
else
window->sourceSceneRefs[source] = 0;
}
void OBSBasic::SourceRemoved(void *data, calldata_t params)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册