app: PlaybackController + playhead subscription migration (issues 0c, 1-4)
New app/playback/playbackcontroller.{h,cpp}: a lazily created
process-wide singleton whose set_playhead() forwards to
oakengine_viewer_set_playhead and re-broadcasts playhead_changed as a
plain Qt signal. Every app-side oakengine_viewer_set_playhead call site
(17 across viewer, timelinewidget, timelineview, import tool,
timebasedwidget, keyframecontrol, export dialog, mainwindow) now goes
through it.
Migrate the first four playhead subscribers off the raw C event
subscription / EngineEventBridge to the controller signal:
- TimeBasedView (issue 1)
- NodeParamViewWidgetBridge (issue 2)
- NodeParamViewKeyframeControl (issue 3)
- NodeParamViewConnectedLabel (issue 4)
Each stores a QMetaObject::Connection filtered on its viewer node and
disconnects on teardown; the viewer_sub_ members are gone. Plan docs
mark issues 0c and 1-4 as done.
Closes #30, closes #31, closes #32, closes #51, closes #52.
This commit is contained in:
@@ -28,6 +28,7 @@
|
||||
#include "oakengine/events.h"
|
||||
#include "oakengine/undo.h"
|
||||
#include "oakengine/viewer.h"
|
||||
#include "playback/playbackcontroller.h"
|
||||
#include "oakengine/node.h"
|
||||
#include "ui/icons/icons.h"
|
||||
|
||||
@@ -159,13 +160,9 @@ NodeParamViewKeyframeControl::NodeParamViewKeyframeControl(bool right_align,
|
||||
|
||||
NodeParamViewKeyframeControl::~NodeParamViewKeyframeControl()
|
||||
{
|
||||
// Raw C-API subscription carries `this` as userdata; it is not covered
|
||||
// by Qt's auto-disconnect. Without this, a playhead event delivered
|
||||
// after destruction calls update_state() on a dead object.
|
||||
if (viewer_sub_ > 0) {
|
||||
oakengine_event_unsubscribe(viewer_sub_);
|
||||
viewer_sub_ = 0;
|
||||
}
|
||||
// Qt auto-disconnect covers the PlaybackController connection; make it
|
||||
// explicit for symmetry with TimeTargetDisconnectEvent.
|
||||
disconnect(viewer_conn_);
|
||||
// Drop the keyframe_* bridge subscriptions too (same raw-userdata
|
||||
// mechanism underneath).
|
||||
set_input(oak::Input());
|
||||
@@ -211,22 +208,18 @@ void NodeParamViewKeyframeControl::set_input(const oak::Input &input)
|
||||
|
||||
void NodeParamViewKeyframeControl::TimeTargetDisconnectEvent(OakEngineNode *v)
|
||||
{
|
||||
if (viewer_sub_ > 0) {
|
||||
oakengine_event_unsubscribe(viewer_sub_);
|
||||
viewer_sub_ = 0;
|
||||
}
|
||||
disconnect(viewer_conn_);
|
||||
}
|
||||
|
||||
void NodeParamViewKeyframeControl::TimeTargetConnectEvent(OakEngineNode *v)
|
||||
{
|
||||
viewer_sub_ = oakengine_event_subscribe(
|
||||
v,
|
||||
OAKENGINE_EVENT_VIEWER_PLAYHEAD_CHANGED,
|
||||
[](const oakengine_event *, void *userdata) {
|
||||
static_cast<NodeParamViewKeyframeControl *>(userdata)
|
||||
->update_state();
|
||||
},
|
||||
this);
|
||||
viewer_conn_ = connect(
|
||||
PlaybackController::instance(), &PlaybackController::playhead_changed,
|
||||
this, [this, v](OakEngineNode *n, const core::Rational &) {
|
||||
if (n == v) {
|
||||
update_state();
|
||||
}
|
||||
});
|
||||
update_state();
|
||||
}
|
||||
|
||||
@@ -391,7 +384,7 @@ void NodeParamViewKeyframeControl::go_to_previous_key()
|
||||
&previous_time) &&
|
||||
get_time_target()) {
|
||||
Rational key_time = convert_to_viewer_time(previous_time);
|
||||
oakengine_viewer_set_playhead(
|
||||
PlaybackController::instance()->set_playhead(
|
||||
reinterpret_cast<OakEngineNode *>(get_time_target()),
|
||||
key_time.numerator(), key_time.denominator());
|
||||
}
|
||||
@@ -408,7 +401,7 @@ void NodeParamViewKeyframeControl::go_to_next_key()
|
||||
&next_time) &&
|
||||
get_time_target()) {
|
||||
Rational key_time = convert_to_viewer_time(next_time);
|
||||
oakengine_viewer_set_playhead(
|
||||
PlaybackController::instance()->set_playhead(
|
||||
reinterpret_cast<OakEngineNode *>(get_time_target()),
|
||||
key_time.numerator(), key_time.denominator());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user