mirror of
https://github.com/WarmUpTill/SceneSwitcher.git
synced 2026-09-07 09:05:57 -05:00
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d55bb6bc86 | ||
|
|
0583331bfd |
@@ -239,22 +239,26 @@ void SceneSelection::ResolveVariables()
|
|||||||
_type = Type::SCENE;
|
_type = Type::SCENE;
|
||||||
}
|
}
|
||||||
|
|
||||||
SceneSelection SceneSelectionWidget::CurrentSelection()
|
static obs_weak_canvas_t *getWeakRefToMainCanvas()
|
||||||
{
|
{
|
||||||
SceneSelection s;
|
static auto canvas = obs_get_main_canvas();
|
||||||
|
static auto weakCanvas = obs_canvas_get_weak_canvas(canvas);
|
||||||
static auto mainCanvas = obs_get_main_canvas();
|
|
||||||
static auto mainCanvasWeak = obs_canvas_get_weak_canvas(mainCanvas);
|
|
||||||
[[maybe_unused]] static const bool _ = []() {
|
[[maybe_unused]] static const bool _ = []() {
|
||||||
// Let's just hope we don't have to deal with selecting scenes
|
// Let's just hope we don't have to deal with selecting scenes
|
||||||
// when the OBS main canvas gets deleted and release the
|
// when the OBS main canvas gets deleted and release the
|
||||||
// references here already to avoid reporting leaks on shutdown
|
// references here already to avoid reporting leaks on shutdown
|
||||||
obs_canvas_release(mainCanvas);
|
obs_canvas_release(canvas);
|
||||||
obs_weak_canvas_release(mainCanvasWeak);
|
obs_weak_canvas_release(weakCanvas);
|
||||||
return true;
|
return true;
|
||||||
}();
|
}();
|
||||||
|
return weakCanvas;
|
||||||
|
}
|
||||||
|
|
||||||
s._canvas = _forceMainCanvas ? OBSWeakCanvas(mainCanvasWeak)
|
SceneSelection SceneSelectionWidget::CurrentSelection()
|
||||||
|
{
|
||||||
|
SceneSelection s;
|
||||||
|
|
||||||
|
s._canvas = _forceMainCanvas ? OBSWeakCanvas(getWeakRefToMainCanvas())
|
||||||
: _canvas->GetCanvas();
|
: _canvas->GetCanvas();
|
||||||
|
|
||||||
const int idx = _scenes->currentIndex();
|
const int idx = _scenes->currentIndex();
|
||||||
@@ -342,6 +346,10 @@ void SceneSelectionWidget::Reset()
|
|||||||
|
|
||||||
void SceneSelectionWidget::PopulateSceneSelection(obs_weak_canvas_t *canvas)
|
void SceneSelectionWidget::PopulateSceneSelection(obs_weak_canvas_t *canvas)
|
||||||
{
|
{
|
||||||
|
if (_forceMainCanvas) {
|
||||||
|
canvas = getWeakRefToMainCanvas();
|
||||||
|
}
|
||||||
|
|
||||||
_scenes->clear();
|
_scenes->clear();
|
||||||
if ((_current || _previous)) {
|
if ((_current || _previous)) {
|
||||||
const bool isMain = IsMainCanvas(canvas);
|
const bool isMain = IsMainCanvas(canvas);
|
||||||
@@ -418,7 +426,7 @@ SceneSelectionWidget::SceneSelectionWidget(QWidget *parent, bool variables,
|
|||||||
layout->setContentsMargins(0, 0, 0, 0);
|
layout->setContentsMargins(0, 0, 0, 0);
|
||||||
|
|
||||||
if (GetCanvasCount() <= 1) {
|
if (GetCanvasCount() <= 1) {
|
||||||
_canvas->hide();
|
LockToMainCanvas();
|
||||||
}
|
}
|
||||||
|
|
||||||
Resize();
|
Resize();
|
||||||
|
|||||||
@@ -199,7 +199,17 @@ std::chrono::high_resolution_clock::time_point GetLastSceneChangeTime()
|
|||||||
|
|
||||||
OBSWeakSource GetCurrentScene()
|
OBSWeakSource GetCurrentScene()
|
||||||
{
|
{
|
||||||
return switcher->currentScene;
|
if (switcher->currentScene) {
|
||||||
|
return switcher->currentScene;
|
||||||
|
}
|
||||||
|
|
||||||
|
// If there wasn't any scene switch yet switcher->currentScene will be
|
||||||
|
// null and we must use obs_frontend_get_current_scene() instead
|
||||||
|
OBSSourceAutoRelease currentSceneSource =
|
||||||
|
obs_frontend_get_current_scene();
|
||||||
|
OBSWeakSourceAutoRelease currentSceneWeakSource =
|
||||||
|
obs_source_get_weak_source(currentSceneSource);
|
||||||
|
return currentSceneWeakSource.Get();
|
||||||
}
|
}
|
||||||
|
|
||||||
OBSWeakSource GetPreviousScene()
|
OBSWeakSource GetPreviousScene()
|
||||||
|
|||||||
Reference in New Issue
Block a user