nullptr checks to prevent crashes with no active sequence
This commit is contained in:
+39
-24
@@ -118,7 +118,8 @@ Timeline::Timeline(QWidget *parent) :
|
||||
Timeline::~Timeline() {}
|
||||
|
||||
void Timeline::previous_cut() {
|
||||
if (Olive::ActiveSequence->playhead > 0) {
|
||||
if (Olive::ActiveSequence != nullptr
|
||||
&& Olive::ActiveSequence->playhead > 0) {
|
||||
long p_cut = 0;
|
||||
for (int i=0;i<Olive::ActiveSequence->clips.size();i++) {
|
||||
Clip* c = Olive::ActiveSequence->clips.at(i);
|
||||
@@ -135,21 +136,23 @@ void Timeline::previous_cut() {
|
||||
}
|
||||
|
||||
void Timeline::next_cut() {
|
||||
bool seek_enabled = false;
|
||||
long n_cut = LONG_MAX;
|
||||
for (int i=0;i<Olive::ActiveSequence->clips.size();i++) {
|
||||
Clip* c = Olive::ActiveSequence->clips.at(i);
|
||||
if (c != nullptr) {
|
||||
if (c->timeline_in < n_cut && c->timeline_in > Olive::ActiveSequence->playhead) {
|
||||
n_cut = c->timeline_in;
|
||||
seek_enabled = true;
|
||||
} else if (c->timeline_out < n_cut && c->timeline_out > Olive::ActiveSequence->playhead) {
|
||||
n_cut = c->timeline_out;
|
||||
seek_enabled = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (seek_enabled) panel_sequence_viewer->seek(n_cut);
|
||||
if (Olive::ActiveSequence != nullptr) {
|
||||
bool seek_enabled = false;
|
||||
long n_cut = LONG_MAX;
|
||||
for (int i=0;i<Olive::ActiveSequence->clips.size();i++) {
|
||||
Clip* c = Olive::ActiveSequence->clips.at(i);
|
||||
if (c != nullptr) {
|
||||
if (c->timeline_in < n_cut && c->timeline_in > Olive::ActiveSequence->playhead) {
|
||||
n_cut = c->timeline_in;
|
||||
seek_enabled = true;
|
||||
} else if (c->timeline_out < n_cut && c->timeline_out > Olive::ActiveSequence->playhead) {
|
||||
n_cut = c->timeline_out;
|
||||
seek_enabled = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (seek_enabled) panel_sequence_viewer->seek(n_cut);
|
||||
}
|
||||
}
|
||||
|
||||
void ripple_clips(ComboAction* ca, Sequence *s, long point, long length, const QVector<int>& ignore) {
|
||||
@@ -512,17 +515,18 @@ void Timeline::repaint_timeline() {
|
||||
}
|
||||
}
|
||||
|
||||
zoom_just_changed = false;
|
||||
|
||||
if (draw) {
|
||||
headers->update();
|
||||
video_area->update();
|
||||
audio_area->update();
|
||||
|
||||
if (Olive::ActiveSequence != nullptr) {
|
||||
if (Olive::ActiveSequence != nullptr
|
||||
&& !zoom_just_changed) {
|
||||
set_sb_max();
|
||||
}
|
||||
}
|
||||
|
||||
zoom_just_changed = false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -740,15 +744,26 @@ void Timeline::delete_selection(QVector<Selection>& selections, bool ripple_dele
|
||||
}
|
||||
|
||||
void Timeline::set_zoom_value(double v) {
|
||||
// set zoom value
|
||||
zoom = v;
|
||||
zoom_just_changed = true;
|
||||
headers->update_zoom(zoom);
|
||||
|
||||
repaint_timeline();
|
||||
// update header zoom to match
|
||||
headers->update_zoom(zoom);
|
||||
|
||||
// set flag that zoom has just changed to prevent auto-scrolling since we change the scroll below
|
||||
zoom_just_changed = true;
|
||||
|
||||
// set scrollbar to center the playhead
|
||||
if (Olive::ActiveSequence != nullptr
|
||||
&& !horizontalScrollBar->is_resizing()) {
|
||||
// update scrollbar maximum value for new zoom
|
||||
set_sb_max();
|
||||
|
||||
// TODO find a way to gradually move towards target_scroll instead of just centering it?
|
||||
if (!horizontalScrollBar->is_resizing())
|
||||
center_scroll_to_playhead(horizontalScrollBar, zoom, Olive::ActiveSequence->playhead);
|
||||
}
|
||||
|
||||
// repaint the timeline for the new zoom/location
|
||||
repaint_timeline();
|
||||
}
|
||||
|
||||
void Timeline::multiply_zoom(double m) {
|
||||
|
||||
+15
-6
@@ -514,37 +514,46 @@ void Viewer::resizeEvent(QResizeEvent *e) {
|
||||
void Viewer::update_viewer() {
|
||||
update_header_zoom();
|
||||
viewer_widget->frame_update();
|
||||
if (seq != nullptr) update_playhead_timecode(seq->playhead);
|
||||
if (seq != nullptr) {
|
||||
update_playhead_timecode(seq->playhead);
|
||||
}
|
||||
update_end_timecode();
|
||||
}
|
||||
|
||||
void Viewer::clear_in() {
|
||||
if (seq->using_workarea) {
|
||||
if (seq != nullptr
|
||||
&& seq->using_workarea) {
|
||||
Olive::UndoStack.push(new SetTimelineInOutCommand(seq, true, 0, seq->workarea_out));
|
||||
update_parents();
|
||||
}
|
||||
}
|
||||
|
||||
void Viewer::clear_out() {
|
||||
if (seq->using_workarea) {
|
||||
if (seq != nullptr
|
||||
&& seq->using_workarea) {
|
||||
Olive::UndoStack.push(new SetTimelineInOutCommand(seq, true, seq->workarea_in, seq->getEndFrame()));
|
||||
update_parents();
|
||||
}
|
||||
}
|
||||
|
||||
void Viewer::clear_inout_point() {
|
||||
if (seq->using_workarea) {
|
||||
if (seq != nullptr
|
||||
&& seq->using_workarea) {
|
||||
Olive::UndoStack.push(new SetTimelineInOutCommand(seq, false, 0, 0));
|
||||
update_parents();
|
||||
}
|
||||
}
|
||||
|
||||
void Viewer::set_in_point() {
|
||||
headers->set_in_point(seq->playhead);
|
||||
if (seq != nullptr) {
|
||||
headers->set_in_point(seq->playhead);
|
||||
}
|
||||
}
|
||||
|
||||
void Viewer::set_out_point() {
|
||||
headers->set_out_point(seq->playhead);
|
||||
if (seq != nullptr) {
|
||||
headers->set_out_point(seq->playhead);
|
||||
}
|
||||
}
|
||||
|
||||
void Viewer::set_zoom(bool in) {
|
||||
|
||||
+3
-1
@@ -676,6 +676,8 @@ Cacher::Cacher(Clip* c) : clip(c) {}
|
||||
AVSampleFormat sample_format = AV_SAMPLE_FMT_S16;
|
||||
|
||||
void open_clip_worker(Clip* clip) {
|
||||
qint64 time_start = QDateTime::currentMSecsSinceEpoch();
|
||||
|
||||
if (clip->media == nullptr) {
|
||||
if (clip->track >= 0) {
|
||||
clip->frame = av_frame_alloc();
|
||||
@@ -942,7 +944,7 @@ void open_clip_worker(Clip* clip) {
|
||||
|
||||
clip->finished_opening = true;
|
||||
|
||||
qInfo() << "Clip opened on track" << clip->track;
|
||||
qInfo() << "Clip opened on track" << clip->track << "(took" << (QDateTime::currentMSecsSinceEpoch() - time_start) << "ms)";
|
||||
}
|
||||
|
||||
void cache_clip_worker(Clip* clip, long playhead, bool reset, bool scrubbing, QVector<Clip*> nests, int playback_speed) {
|
||||
|
||||
Reference in New Issue
Block a user