diff --git a/debug.cpp b/debug.cpp index ed43cea42..405cb010a 100644 --- a/debug.cpp +++ b/debug.cpp @@ -65,7 +65,7 @@ void debug_message_handler(QtMsgType type, const QMessageLogContext &context, co fflush(stderr); abort(); } - if (debug_dialog->isVisible()) { + if (debug_dialog != nullptr && debug_dialog->isVisible()) { QMetaObject::invokeMethod(debug_dialog, "update_log", Qt::QueuedConnection); } debug_mutex.unlock(); diff --git a/dialogs/actionsearch.cpp b/dialogs/actionsearch.cpp index 3f5593dbe..1a30fb197 100644 --- a/dialogs/actionsearch.cpp +++ b/dialogs/actionsearch.cpp @@ -21,7 +21,7 @@ ActionSearch::ActionSearch(QWidget *parent) : ActionSearchEntry* entry_field = new ActionSearchEntry(); QFont entry_field_font = entry_field->font(); - entry_field_font.setPointSize(entry_field_font.pointSize()*1.2); + entry_field_font.setPointSize(qRound(entry_field_font.pointSize()*1.2)); entry_field->setFont(entry_field_font); entry_field->setPlaceholderText("Search for action..."); connect(entry_field, SIGNAL(textChanged(const QString&)), this, SLOT(search_update(const QString &))); @@ -32,7 +32,7 @@ ActionSearch::ActionSearch(QWidget *parent) : list_widget = new ActionSearchList(); QFont list_widget_font = list_widget->font(); - list_widget_font.setPointSize(list_widget_font.pointSize()*1.2); + list_widget_font.setPointSize(qRound(list_widget_font.pointSize()*1.2)); list_widget->setFont(list_widget_font); layout->addWidget(list_widget); connect(list_widget, SIGNAL(dbl_click()), this, SLOT(perform_action())); @@ -43,7 +43,7 @@ ActionSearch::ActionSearch(QWidget *parent) : } void ActionSearch::search_update(const QString &s, const QString &p, QMenu *parent) { - if (parent == NULL) { + if (parent == nullptr) { list_widget->clear(); QList menus = mainWindow->menuBar()->actions(); for (int i=0;iisSeparator()) { - if (a->menu() != NULL) { + if (a->menu() != nullptr) { search_update(s, menu_text, a->menu()); } else { QString comp = a->text().replace("&", ""); @@ -88,9 +88,9 @@ void ActionSearch::perform_action() { void ActionSearch::move_selection_up() { int lim = list_widget->count(); for (int i=1;iitem(i)->isSelected()) { + if (list_widget->item(i)->isSelected()) { list_widget->item(i-1)->setSelected(true); - list_widget->scrollToItem(list_widget->item(i-1)); + list_widget->scrollToItem(list_widget->item(i-1)); break; } } @@ -99,9 +99,9 @@ void ActionSearch::move_selection_up() { void ActionSearch::move_selection_down() { int lim = list_widget->count()-1; for (int i=0;iitem(i)->isSelected()) { + if (list_widget->item(i)->isSelected()) { list_widget->item(i+1)->setSelected(true); - list_widget->scrollToItem(list_widget->item(i+1)); + list_widget->scrollToItem(list_widget->item(i+1)); break; } } @@ -120,6 +120,6 @@ void ActionSearchEntry::keyPressEvent(QKeyEvent * event) { } } -void ActionSearchList::mouseDoubleClickEvent(QMouseEvent *event) { +void ActionSearchList::mouseDoubleClickEvent(QMouseEvent *) { emit dbl_click(); } diff --git a/dialogs/actionsearch.h b/dialogs/actionsearch.h index 72d7d7153..4147f8900 100644 --- a/dialogs/actionsearch.h +++ b/dialogs/actionsearch.h @@ -22,7 +22,7 @@ class ActionSearch : public QDialog public: ActionSearch(QWidget* parent = 0); private slots: - void search_update(const QString& s, const QString &p = 0, QMenu *parent = NULL); + void search_update(const QString& s, const QString &p = 0, QMenu *parent = nullptr); void perform_action(); void move_selection_up(); void move_selection_down(); diff --git a/dialogs/debugdialog.cpp b/dialogs/debugdialog.cpp index b70b24bab..4e4c16236 100644 --- a/dialogs/debugdialog.cpp +++ b/dialogs/debugdialog.cpp @@ -5,7 +5,7 @@ #include "debug.h" -DebugDialog* debug_dialog = NULL; +DebugDialog* debug_dialog = nullptr; DebugDialog::DebugDialog(QWidget *parent) : QDialog(parent) { setWindowTitle("Debug Log"); diff --git a/dialogs/exportdialog.cpp b/dialogs/exportdialog.cpp index edcafc1f9..bf558946b 100644 --- a/dialogs/exportdialog.cpp +++ b/dialogs/exportdialog.cpp @@ -292,16 +292,16 @@ void ExportDialog::format_changed(int index) AVCodec* codec_info; for (int i=0;iaddItem("NULL"); + if (codec_info == nullptr) { + vcodecCombobox->addItem("nullptr"); } else { vcodecCombobox->addItem(codec_info->long_name); } } for (int i=0;iaddItem("NULL"); + if (codec_info == nullptr) { + acodecCombobox->addItem("nullptr"); } else { acodecCombobox->addItem(codec_info->long_name); } diff --git a/dialogs/newsequencedialog.cpp b/dialogs/newsequencedialog.cpp index 0451aa886..2560b0908 100644 --- a/dialogs/newsequencedialog.cpp +++ b/dialogs/newsequencedialog.cpp @@ -29,7 +29,7 @@ NewSequenceDialog::NewSequenceDialog(QWidget *parent, Media *existing) : { setup_ui(); - if (existing != NULL) { + if (existing != nullptr) { existing_sequence = existing->to_sequence(); setWindowTitle("Editing \"" + existing_sequence->name + "\""); @@ -50,7 +50,7 @@ NewSequenceDialog::NewSequenceDialog(QWidget *parent, Media *existing) : } } } else { - existing_sequence = NULL; + existing_sequence = nullptr; setWindowTitle("New Sequence"); } } @@ -63,7 +63,7 @@ void NewSequenceDialog::set_sequence_name(const QString& s) { } void NewSequenceDialog::create() { - if (existing_sequence == NULL) { + if (existing_sequence == nullptr) { Sequence* s = new Sequence(); s->name = sequence_name_edit->text(); @@ -74,7 +74,7 @@ void NewSequenceDialog::create() { s->audio_layout = AV_CH_LAYOUT_STEREO; ComboAction* ca = new ComboAction(); - panel_project->new_sequence(ca, s, true, NULL); + panel_project->new_sequence(ca, s, true, nullptr); undo_stack.push(ca); } else { ComboAction* ca = new ComboAction(); @@ -92,7 +92,7 @@ void NewSequenceDialog::create() { for (int i=0;iclips.size();i++) { Clip* c = existing_sequence->clips.at(i); - if (c != NULL) { + if (c != nullptr) { c->refactor_frame_rate(ca, multiplier, true); } } diff --git a/dialogs/preferencesdialog.cpp b/dialogs/preferencesdialog.cpp index a730d6bb5..fa664c165 100644 --- a/dialogs/preferencesdialog.cpp +++ b/dialogs/preferencesdialog.cpp @@ -76,7 +76,7 @@ void PreferencesDialog::setup_kbd_shortcut_worker(QMenu* menu, QTreeWidgetItem* parent->addChild(item); - if (a->menu() != NULL) { + if (a->menu() != nullptr) { item->setChildIndicatorPolicy(QTreeWidgetItem::ShowIndicator); setup_kbd_shortcut_worker(a->menu(), item); } else { @@ -150,7 +150,7 @@ void PreferencesDialog::reset_all_shortcuts() { } bool PreferencesDialog::refine_shortcut_list(const QString &s, QTreeWidgetItem* parent) { - if (parent == NULL) { + if (parent == nullptr) { for (int i=0;itopLevelItemCount();i++) { refine_shortcut_list(s, keyboard_tree->topLevelItem(i)); } @@ -169,7 +169,7 @@ bool PreferencesDialog::refine_shortcut_list(const QString &s, QTreeWidgetItem* all_children_are_hidden = false; } else { QString shortcut; - if (keyboard_tree->itemWidget(item, 1) != NULL) { + if (keyboard_tree->itemWidget(item, 1) != nullptr) { shortcut = static_cast(keyboard_tree->itemWidget(item, 1))->keySequence().toString(); } if (item->text(0).contains(s, Qt::CaseInsensitive) || shortcut.contains(s, Qt::CaseInsensitive)) { diff --git a/dialogs/preferencesdialog.h b/dialogs/preferencesdialog.h index 0b1344c71..49758151f 100644 --- a/dialogs/preferencesdialog.h +++ b/dialogs/preferencesdialog.h @@ -39,7 +39,7 @@ private slots: void save(); void reset_default_shortcut(); void reset_all_shortcuts(); - bool refine_shortcut_list(const QString &, QTreeWidgetItem* parent = NULL); + bool refine_shortcut_list(const QString &, QTreeWidgetItem* parent = nullptr); void load_shortcut_file(); void save_shortcut_file(); void browse_css_file(); diff --git a/dialogs/replaceclipmediadialog.cpp b/dialogs/replaceclipmediadialog.cpp index 5243cc71c..2583830f6 100644 --- a/dialogs/replaceclipmediadialog.cpp +++ b/dialogs/replaceclipmediadialog.cpp @@ -82,7 +82,7 @@ void ReplaceClipMediaDialog::replace() { for (int i=0;iclips.size();i++) { Clip* c = sequence->clips.at(i); - if (c != NULL && c->media == media) { + if (c != nullptr && c->media == media) { rcmc->clips.append(c); } } diff --git a/dialogs/speeddialog.cpp b/dialogs/speeddialog.cpp index ff4c52a14..af3211b53 100644 --- a/dialogs/speeddialog.cpp +++ b/dialogs/speeddialog.cpp @@ -84,10 +84,10 @@ void SpeedDialog::run() { clip_percent = c->speed; if (c->track < 0) { bool process_video = true; - if (c->media != NULL && c->media->get_type() == MEDIA_TYPE_FOOTAGE) { + if (c->media != nullptr && c->media->get_type() == MEDIA_TYPE_FOOTAGE) { Footage* m = c->media->to_footage(); FootageStream* ms = m->get_stream_from_file_index(true, c->media_stream); - if (ms != NULL && ms->infinite_length) { + if (ms != nullptr && ms->infinite_length) { process_video = false; } } @@ -304,7 +304,7 @@ void set_speed(ComboAction* ca, Clip* c, double speed, bool ripple, long& ep, lo if (!ripple && proposed_out > c->timeline_out) { for (int i=0;isequence->clips.size();i++) { Clip* compare = c->sequence->clips.at(i); - if (compare != NULL + if (compare != nullptr && compare->track == c->track && compare->timeline_in >= c->timeline_out && compare->timeline_in < proposed_out) { proposed_out = compare->timeline_in; diff --git a/effects/internal/cornerpineffect.cpp b/effects/internal/cornerpineffect.cpp index 5be93b671..6febf3bd0 100644 --- a/effects/internal/cornerpineffect.cpp +++ b/effects/internal/cornerpineffect.cpp @@ -47,7 +47,7 @@ CornerPinEffect::CornerPinEffect(Clip *c, const EffectMeta *em) : Effect(c, em) fragPath = "cornerpin.frag"; } -void CornerPinEffect::process_coords(double timecode, GLTextureCoords &coords, int data) { +void CornerPinEffect::process_coords(double timecode, GLTextureCoords &coords, int) { coords.vertexTopLeftX += top_left_x->get_double_value(timecode); coords.vertexTopLeftY += top_left_y->get_double_value(timecode); @@ -69,7 +69,7 @@ void CornerPinEffect::process_shader(double timecode, GLTextureCoords &coords) { glslProgram->setUniformValue("perspective", perspective->get_bool_value(timecode)); } -void CornerPinEffect::gizmo_draw(double timecode, GLTextureCoords &coords) { +void CornerPinEffect::gizmo_draw(double, GLTextureCoords &coords) { top_left_gizmo->world_pos[0] = QPoint(coords.vertexTopLeftX, coords.vertexTopLeftY); top_right_gizmo->world_pos[0] = QPoint(coords.vertexTopRightX, coords.vertexTopRightY); bottom_right_gizmo->world_pos[0] = QPoint(coords.vertexBottomRightX, coords.vertexBottomRightY); diff --git a/effects/internal/crossdissolvetransition.cpp b/effects/internal/crossdissolvetransition.cpp index ef2d684ac..f792b379a 100644 --- a/effects/internal/crossdissolvetransition.cpp +++ b/effects/internal/crossdissolvetransition.cpp @@ -9,7 +9,7 @@ CrossDissolveTransition::CrossDissolveTransition(Clip* c, Clip* s, const EffectM } void CrossDissolveTransition::process_coords(double progress, GLTextureCoords&, int data) { - if (!(data == TA_CLOSING_TRANSITION && secondary_clip != NULL)) { + if (!(data == TA_CLOSING_TRANSITION && secondary_clip != nullptr)) { float color[4]; glGetFloatv(GL_CURRENT_COLOR, color); if (data == TA_CLOSING_TRANSITION) progress = 1.0 - progress; diff --git a/effects/internal/cubetransition.cpp b/effects/internal/cubetransition.cpp index e97cf0c66..a2058e230 100644 --- a/effects/internal/cubetransition.cpp +++ b/effects/internal/cubetransition.cpp @@ -3,11 +3,11 @@ #include "debug.h" CubeTransition::CubeTransition(Clip* c, Clip* s, const EffectMeta* em) : Transition(c, s, em) { - enable_coords = true; + enable_coords = true; } -void CubeTransition::process_coords(double progress, GLTextureCoords& coords, int data) { +void CubeTransition::process_coords(double, GLTextureCoords& coords, int) { - coords.vertexTopLeftZ = 1; - coords.vertexBottomLeftZ = 1; + coords.vertexTopLeftZ = 1; + coords.vertexBottomLeftZ = 1; } diff --git a/effects/internal/shakeeffect.cpp b/effects/internal/shakeeffect.cpp index 92975fe8a..968e6c3f5 100644 --- a/effects/internal/shakeeffect.cpp +++ b/effects/internal/shakeeffect.cpp @@ -40,7 +40,7 @@ ShakeEffect::ShakeEffect(Clip *c, const EffectMeta *em) : Effect(c, em) { } } -void ShakeEffect::process_coords(double timecode, GLTextureCoords& coords, int data) { +void ShakeEffect::process_coords(double timecode, GLTextureCoords& coords, int) { int lim = RANDOM_VAL_SIZE/6; double multiplier = intensity_val->get_double_value(timecode)/lim; diff --git a/effects/internal/transformeffect.cpp b/effects/internal/transformeffect.cpp index e1cf1dde7..e0d95d95c 100644 --- a/effects/internal/transformeffect.cpp +++ b/effects/internal/transformeffect.cpp @@ -134,7 +134,7 @@ void adjust_field(EffectField* field, double old_offset, double new_offset) { } void TransformEffect::refresh() { - if (parent_clip != NULL && parent_clip->sequence != NULL) { + if (parent_clip != nullptr && parent_clip->sequence != nullptr) { double new_default_pos_x = parent_clip->sequence->width/2; double new_default_pos_y = parent_clip->sequence->height/2; @@ -180,13 +180,13 @@ void TransformEffect::toggle_uniform_scale(bool enabled) { top_center_gizmo->y_field1 = enabled ? scale_x : scale_y; bottom_center_gizmo->y_field1 = enabled ? scale_x : scale_y; - top_left_gizmo->y_field1 = enabled ? NULL : scale_y; - top_right_gizmo->y_field1 = enabled ? NULL : scale_y; - bottom_left_gizmo->y_field1 = enabled ? NULL : scale_y; - bottom_right_gizmo->y_field1 = enabled ? NULL : scale_y; + top_left_gizmo->y_field1 = enabled ? nullptr : scale_y; + top_right_gizmo->y_field1 = enabled ? nullptr : scale_y; + bottom_left_gizmo->y_field1 = enabled ? nullptr : scale_y; + bottom_right_gizmo->y_field1 = enabled ? nullptr : scale_y; } -void TransformEffect::process_coords(double timecode, GLTextureCoords& coords, int data) { +void TransformEffect::process_coords(double timecode, GLTextureCoords& coords, int) { // position glTranslatef(position_x->get_double_value(timecode)-(parent_clip->sequence->width/2), position_y->get_double_value(timecode)-(parent_clip->sequence->height/2), 0); @@ -234,7 +234,7 @@ void TransformEffect::process_coords(double timecode, GLTextureCoords& coords, i glColor4f(1.0, 1.0, 1.0, color[3]*(opacity->get_double_value(timecode)*0.01)); } -void TransformEffect::gizmo_draw(double timecode, GLTextureCoords& coords) { +void TransformEffect::gizmo_draw(double, GLTextureCoords& coords) { top_left_gizmo->world_pos[0] = QPoint(coords.vertexTopLeftX, coords.vertexTopLeftY); top_center_gizmo->world_pos[0] = QPoint(lerp(coords.vertexTopLeftX, coords.vertexTopRightX, 0.5), lerp(coords.vertexTopLeftY, coords.vertexTopRightY, 0.5)); top_right_gizmo->world_pos[0] = QPoint(coords.vertexTopRightX, coords.vertexTopRightY); diff --git a/effects/internal/voideffect.cpp b/effects/internal/voideffect.cpp index 11a8c25ff..61c805ba9 100644 --- a/effects/internal/voideffect.cpp +++ b/effects/internal/voideffect.cpp @@ -7,7 +7,7 @@ #include "ui/collapsiblewidget.h" #include "debug.h" -VoidEffect::VoidEffect(Clip *c, const QString& n) : Effect(c, NULL) { +VoidEffect::VoidEffect(Clip *c, const QString& n) : Effect(c, nullptr) { name = n; QString display_name; if (n.isEmpty()) { diff --git a/effects/internal/vsthostwin.cpp b/effects/internal/vsthostwin.cpp index 302cb5d34..961564991 100644 --- a/effects/internal/vsthostwin.cpp +++ b/effects/internal/vsthostwin.cpp @@ -20,15 +20,13 @@ // C callbacks extern "C" { // Main host callback - VstIntPtr VSTCALLBACK hostCallback(AEffect *effect, int opcode, int index, long long value, void *ptr, float opt) { + VstIntPtr VSTCALLBACK hostCallback(AEffect *effect, int opcode, int, long long, void *, float) { switch(opcode) { case audioMasterVersion: return 2400; case audioMasterIdle: - effect->dispatcher(effect, effEditIdle, 0, 0, 0, 0); + effect->dispatcher(effect, effEditIdle, 0, 0, nullptr, 0); break; - case 6: // audioMasterWantMidi - return 0; case audioMasterGetCurrentProcessLevel: return 0; // Handle other opcodes here... there will be lots of them @@ -39,6 +37,7 @@ extern "C" { qInfo() << "Plugin requested unhandled opcode" << opcode; break; } + return 0; } } @@ -58,7 +57,7 @@ void VSTHostWin::loadPlugin() { LPCWSTR dll_fn_w = reinterpret_cast(dll_fn.utf16()); modulePtr = LoadLibrary(dll_fn_w); - if(modulePtr == NULL) { + if(modulePtr == nullptr) { DWORD dll_err = GetLastError(); qCritical() << "Failed to load VST" << dll_fn_w << "-" << dll_err; QString msg_err = "Failed to load VST plugin \"" + dll_fn + "\": " + QString::number(dll_err); @@ -74,16 +73,16 @@ void VSTHostWin::loadPlugin() { } vstPluginFuncPtr mainEntryPoint = - (vstPluginFuncPtr)GetProcAddress(modulePtr, "VSTPluginMain"); + reinterpret_cast(GetProcAddress(modulePtr, "VSTPluginMain")); // Instantiate the plugin plugin = mainEntryPoint(hostCallback); } void VSTHostWin::freePlugin() { - if (plugin != NULL) { + if (plugin != nullptr) { stopPlugin(); FreeLibrary(modulePtr); - plugin = NULL; + plugin = nullptr; } } @@ -98,22 +97,22 @@ bool VSTHostWin::configurePluginCallbacks() { } // Create dispatcher handle - dispatcher = (dispatcherFuncPtr)(plugin->dispatcher); + dispatcher = reinterpret_cast(plugin->dispatcher); // Set up plugin callback functions - plugin->getParameter = (getParameterFuncPtr)plugin->getParameter; - plugin->processReplacing = (processFuncPtr)plugin->processReplacing; - plugin->setParameter = (setParameterFuncPtr)plugin->setParameter; + plugin->getParameter = reinterpret_cast(plugin->getParameter); + plugin->processReplacing = reinterpret_cast(plugin->processReplacing); + plugin->setParameter = reinterpret_cast(plugin->setParameter); return true; } void VSTHostWin::startPlugin() { - dispatcher(plugin, effOpen, 0, 0, NULL, 0.0f); + dispatcher(plugin, effOpen, 0, 0, nullptr, 0.0f); // Set some default properties - dispatcher(plugin, effSetSampleRate, 0, 0, NULL, current_audio_freq()); - dispatcher(plugin, effSetBlockSize, 0, BLOCK_SIZE, NULL, 0.0f); + dispatcher(plugin, effSetSampleRate, 0, 0, nullptr, current_audio_freq()); + dispatcher(plugin, effSetBlockSize, 0, BLOCK_SIZE, nullptr, 0.0f); resumePlugin(); } @@ -121,19 +120,19 @@ void VSTHostWin::startPlugin() { void VSTHostWin::stopPlugin() { suspendPlugin(); - dispatcher(plugin, effClose, 0, 0, NULL, 0); + dispatcher(plugin, effClose, 0, 0, nullptr, 0); } void VSTHostWin::resumePlugin() { - dispatcher(plugin, effMainsChanged, 0, 1, NULL, 0.0f); + dispatcher(plugin, effMainsChanged, 0, 1, nullptr, 0.0f); } void VSTHostWin::suspendPlugin() { - dispatcher(plugin, effMainsChanged, 0, 0, NULL, 0.0f); + dispatcher(plugin, effMainsChanged, 0, 0, nullptr, 0.0f); } bool VSTHostWin::canPluginDo(char *canDoString) { - return (dispatcher(plugin, effCanDo, 0, 0, (void*)canDoString, 0.0f) > 0); + return (dispatcher(plugin, effCanDo, 0, 0, static_cast(canDoString), 0.0f) > 0); } void VSTHostWin::initializeIO() { @@ -158,11 +157,11 @@ void VSTHostWin::processAudio(long numFrames) { } VSTHostWin::VSTHostWin(Clip* c, const EffectMeta *em) : Effect(c, em) { - plugin = NULL; + plugin = nullptr; initializeIO(); - file_field = add_row("Plugin", true, false)->add_field(EFFECT_FIELD_FILE, "filename"); + file_field = add_row("Plugin", true, false)->add_field(EFFECT_FIELD_FILE, "filename", true); connect(file_field, SIGNAL(changed()), this, SLOT(change_plugin())); EffectRow* interface_row = add_row("Interface", false, false); @@ -183,8 +182,8 @@ VSTHostWin::~VSTHostWin() { freePlugin(); } -void VSTHostWin::process_audio(double timecode_start, double timecode_end, quint8* samples, int nb_bytes, int) { - if (plugin != NULL) { +void VSTHostWin::process_audio(double, double, quint8* samples, int nb_bytes, int) { + if (plugin != nullptr) { int interval = BLOCK_SIZE*4; for (int i=0;i>2; inputs[0][index] = float(left_sample) / float(INT16_MAX); @@ -207,13 +206,13 @@ void VSTHostWin::process_audio(double timecode_start, double timecode_end, quint for (int j=i;j>2; - qint16 left_sample = qRound(outputs[0][index] * INT16_MAX); - qint16 right_sample = qRound(outputs[1][index] * INT16_MAX); + qint16 left_sample = qint16(qRound(outputs[0][index] * INT16_MAX)); + qint16 right_sample = qint16(qRound(outputs[1][index] * INT16_MAX)); - samples[j+3] = (quint8) (right_sample >> 8); - samples[j+2] = (quint8) right_sample; - samples[j+1] = (quint8) (left_sample >> 8); - samples[j] = (quint8) left_sample; + samples[j+3] = quint8(right_sample >> 8); + samples[j+2] = quint8(right_sample); + samples[j+1] = quint8(left_sample >> 8); + samples[j] = quint8(left_sample); } } } @@ -223,18 +222,17 @@ void VSTHostWin::custom_load(QXmlStreamReader &stream) { if (stream.name() == "plugindata") { stream.readNext(); QByteArray b = QByteArray::fromBase64(stream.text().toUtf8()); - const char* data = b.constData(); - if (plugin != NULL) { - dispatcher(plugin, effSetChunk, 0, (VstInt32) b.size(), (void*) b.constData(), 0); + if (plugin != nullptr) { + dispatcher(plugin, effSetChunk, 0, VstInt32(b.size()), static_cast(b.data()), 0); } } } void VSTHostWin::save(QXmlStreamWriter &stream) { Effect::save(stream); - if (plugin != NULL) { - char* p = NULL; - VstInt32 length = dispatcher(plugin, effGetChunk, 0, 0, &p, 0); + if (plugin != nullptr) { + char* p = nullptr; + VstInt32 length = VstInt32(dispatcher(plugin, effGetChunk, 0, 0, &p, 0)); QByteArray b(p, length); stream.writeTextElement("plugindata", b.toBase64()); } @@ -251,18 +249,18 @@ void VSTHostWin::uncheck_show_button() { void VSTHostWin::change_plugin() { freePlugin(); loadPlugin(); - if (plugin != NULL) { + if (plugin != nullptr) { if (configurePluginCallbacks()) { startPlugin(); dispatcher(plugin, effEditOpen, 0, 0, reinterpret_cast(dialog->winId()), 0); - ERect* eRect = NULL; + ERect* eRect = nullptr; plugin->dispatcher(plugin, effEditGetRect, 0, 0, &eRect, 0); dialog->setFixedWidth(eRect->right); dialog->setFixedHeight(eRect->bottom); } else { FreeLibrary(modulePtr); - plugin = NULL; + plugin = nullptr; } } - show_interface_btn->setEnabled(plugin != NULL); + show_interface_btn->setEnabled(plugin != nullptr); } diff --git a/icons/icons.qrc b/icons/icons.qrc index 57624c16c..a2981fd4c 100644 --- a/icons/icons.qrc +++ b/icons/icons.qrc @@ -58,5 +58,6 @@ tri-up.png hand.png hand-disabled.png + olive64.png diff --git a/icons/olive64.png b/icons/olive64.png new file mode 100644 index 000000000..d5e31af4e Binary files /dev/null and b/icons/olive64.png differ diff --git a/io/clipboard.cpp b/io/clipboard.cpp index 1c3a8075b..344a4d6ce 100644 --- a/io/clipboard.cpp +++ b/io/clipboard.cpp @@ -2,13 +2,14 @@ #include "project/clip.h" #include "project/effect.h" +#include "project/transition.h" int clipboard_type = CLIPBOARD_TYPE_CLIP; QVector clipboard; QVector clipboard_transitions; void clear_clipboard() { - uint clipboard_size = clipboard.size(); + int clipboard_size = clipboard.size(); for (int i=0;i(clipboard.at(i)); diff --git a/io/exportthread.cpp b/io/exportthread.cpp index 5993f0316..9ec00ba0c 100644 --- a/io/exportthread.cpp +++ b/io/exportthread.cpp @@ -27,19 +27,19 @@ extern "C" { ExportThread::ExportThread() : continueEncode(true) { surface.create(); - fmt_ctx = NULL; - video_stream = NULL; - vcodec = NULL; - vcodec_ctx = NULL; - video_frame = NULL; - sws_frame = NULL; - sws_ctx = NULL; - audio_stream = NULL; - acodec = NULL; - audio_frame = NULL; - swr_frame = NULL; - acodec_ctx = NULL; - swr_ctx = NULL; + fmt_ctx = nullptr; + video_stream = nullptr; + vcodec = nullptr; + vcodec_ctx = nullptr; + video_frame = nullptr; + sws_frame = nullptr; + sws_ctx = nullptr; + audio_stream = nullptr; + acodec = nullptr; + audio_frame = nullptr; + swr_frame = nullptr; + acodec_ctx = nullptr; + swr_ctx = nullptr; vpkt_alloc = false; apkt_alloc = false; @@ -133,7 +133,7 @@ bool ExportThread::setupVideo() { } } - ret = avcodec_open2(vcodec_ctx, vcodec, NULL); + ret = avcodec_open2(vcodec_ctx, vcodec, nullptr); if (ret < 0) { qCritical() << "Could not open output video encoder." << ret; ed->export_error = "could not open output video encoder (" + QString::number(ret) + ")"; @@ -166,9 +166,9 @@ bool ExportThread::setupVideo() { video_height, vcodec_ctx->pix_fmt, SWS_FAST_BILINEAR, - NULL, - NULL, - NULL + nullptr, + nullptr, + nullptr ); sws_frame = av_frame_alloc(); @@ -228,7 +228,7 @@ bool ExportThread::setupAudio() { } // open encoder - ret = avcodec_open2(acodec_ctx, acodec, NULL); + ret = avcodec_open2(acodec_ctx, acodec, nullptr); if (ret < 0) { qCritical() << "Could not open output audio encoder." << ret; ed->export_error = "could not open output audio encoder (" + QString::number(ret) + ")"; @@ -245,7 +245,7 @@ bool ExportThread::setupAudio() { // init audio resampler context swr_ctx = swr_alloc_set_opts( - NULL, + nullptr, acodec_ctx->channel_layout, acodec_ctx->sample_fmt, acodec_ctx->sample_rate, @@ -253,7 +253,7 @@ bool ExportThread::setupAudio() { AV_SAMPLE_FMT_S16, sequence->audio_frequency, 0, - NULL + nullptr ); swr_init(swr_ctx); @@ -272,7 +272,7 @@ bool ExportThread::setupAudio() { ed->export_error = "could not allocate audio buffer (" + QString::number(ret) + ")"; return false; } - aframe_bytes = av_samples_get_buffer_size(NULL, audio_frame->channels, audio_frame->nb_samples, static_cast(audio_frame->format), 0); + aframe_bytes = av_samples_get_buffer_size(nullptr, audio_frame->channels, audio_frame->nb_samples, static_cast(audio_frame->format), 0); // init converted audio frame swr_frame = av_frame_alloc(); @@ -288,7 +288,7 @@ bool ExportThread::setupAudio() { } bool ExportThread::setupContainer() { - avformat_alloc_output_context2(&fmt_ctx, NULL, NULL, c_filename); + avformat_alloc_output_context2(&fmt_ctx, nullptr, nullptr, c_filename); if (!fmt_ctx) { qCritical() << "Could not create output context"; ed->export_error = "could not create output format context"; @@ -328,7 +328,7 @@ void ExportThread::run() { if (audio_enabled && continueEncode) continueEncode = setupAudio(); if (continueEncode) { - ret = avformat_write_header(fmt_ctx, NULL); + ret = avformat_write_header(fmt_ctx, nullptr); if (ret < 0) { qCritical() << "Could not write output file header." << ret; ed->export_error = "could not write output file header (" + QString::number(ret) + ")"; @@ -412,7 +412,7 @@ void ExportThread::run() { if (audio_enabled) apkt_alloc = true; } - panel_sequence_viewer->viewer_widget->default_fbo = NULL; + panel_sequence_viewer->viewer_widget->default_fbo = nullptr; rendering = false; fbo.release(); @@ -420,7 +420,7 @@ void ExportThread::run() { if (audio_enabled && continueEncode) { // flush swresample do { - swr_convert_frame(swr_ctx, swr_frame, NULL); + swr_convert_frame(swr_ctx, swr_frame, nullptr); if (swr_frame->nb_samples == 0) break; swr_frame->pts = file_audio_samples; if (!encode(fmt_ctx, acodec_ctx, swr_frame, &audio_pkt, audio_stream, true)) continueEncode = false; @@ -433,8 +433,8 @@ void ExportThread::run() { if (continueEncode) { // flush remaining packets while (continueVideo && continueAudio) { - if (continueVideo && video_enabled) continueVideo = encode(fmt_ctx, vcodec_ctx, NULL, &video_pkt, video_stream, false); - if (continueAudio && audio_enabled) continueAudio = encode(fmt_ctx, acodec_ctx, NULL, &audio_pkt, audio_stream, true); + if (continueVideo && video_enabled) continueVideo = encode(fmt_ctx, vcodec_ctx, nullptr, &video_pkt, video_stream, false); + if (continueAudio && audio_enabled) continueAudio = encode(fmt_ctx, acodec_ctx, nullptr, &audio_pkt, audio_stream, true); } ret = av_write_trailer(fmt_ctx); @@ -450,26 +450,26 @@ void ExportThread::run() { avio_closep(&fmt_ctx->pb); if (vpkt_alloc) av_packet_unref(&video_pkt); - if (video_frame != NULL) av_frame_free(&video_frame); - if (vcodec_ctx != NULL) { + if (video_frame != nullptr) av_frame_free(&video_frame); + if (vcodec_ctx != nullptr) { avcodec_close(vcodec_ctx); avcodec_free_context(&vcodec_ctx); } if (apkt_alloc) av_packet_unref(&audio_pkt); - if (audio_frame != NULL) av_frame_free(&audio_frame); - if (acodec_ctx != NULL) { + if (audio_frame != nullptr) av_frame_free(&audio_frame); + if (acodec_ctx != nullptr) { avcodec_close(acodec_ctx); avcodec_free_context(&acodec_ctx); } avformat_free_context(fmt_ctx); - if (sws_ctx != NULL) { + if (sws_ctx != nullptr) { sws_freeContext(sws_ctx); av_frame_free(&sws_frame); } - if (swr_ctx != NULL) { + if (swr_ctx != nullptr) { swr_free(&swr_ctx); av_frame_free(&swr_frame); } diff --git a/io/loadthread.cpp b/io/loadthread.cpp index a65942c70..147e4b6c7 100644 --- a/io/loadthread.cpp +++ b/io/loadthread.cpp @@ -43,7 +43,7 @@ const EffectMeta* get_meta_from_name(const QString& name) { return &effects.at(j); } } - return NULL; + return nullptr; } void LoadThread::load_effect(QXmlStreamReader& stream, Clip* c) { @@ -67,7 +67,7 @@ void LoadThread::load_effect(QXmlStreamReader& stream, Clip* c) { // wait for effects to be loaded panel_effect_controls->effects_loaded.lock(); - const EffectMeta* meta = NULL; + const EffectMeta* meta = nullptr; // find effect with this name if (!effect_name.isEmpty()) { @@ -168,7 +168,7 @@ bool LoadThread::load_worker(QFile& f, QXmlStreamReader& stream, int type) { switch (type) { case MEDIA_TYPE_FOLDER: { - Media* folder = panel_project->new_folder(0); + Media* folder = panel_project->new_folder(nullptr); folder->temp_id2 = 0; for (int j=0;jset_footage(m); if (folder == 0) { - project_model.appendChild(NULL, item); + project_model.appendChild(nullptr, item); } else { find_loaded_folder_by_id(folder)->appendChild(item); } @@ -250,7 +250,7 @@ bool LoadThread::load_worker(QFile& f, QXmlStreamReader& stream, int type) { break; case MEDIA_TYPE_SEQUENCE: { - Media* parent = NULL; + Media* parent = nullptr; Sequence* s = new Sequence(); // load attributes about sequence @@ -304,8 +304,8 @@ bool LoadThread::load_worker(QFile& f, QXmlStreamReader& stream, int type) { s->markers.append(m); } else if (stream.name() == "transition" && stream.isStartElement()) { TransitionData td; - td.otc = NULL; - td.ctc = NULL; + td.otc = nullptr; + td.ctc = nullptr; for (int j=0;jautoscale = false; - c->media = NULL; + c->media = nullptr; for (int j=0;jmedia = NULL; + c->media = nullptr; c->media_stream = attr.value().toInt(); loaded_clips.append(c); } @@ -468,16 +468,16 @@ bool LoadThread::load_worker(QFile& f, QXmlStreamReader& stream, int type) { const TransitionData& td = transition_data.at(i); Clip* primary = td.otc; Clip* secondary = td.ctc; - if (primary != NULL || secondary != NULL) { - if (primary == NULL) { + if (primary != nullptr || secondary != nullptr) { + if (primary == nullptr) { primary = secondary; - secondary = NULL; + secondary = nullptr; } const EffectMeta* meta = get_meta_from_name(td.name); - if (meta == NULL) { + if (meta == nullptr) { qWarning() << "Failed to link transition with name:" << td.name; - if (td.otc != NULL) td.otc->opening_transition = -1; - if (td.ctc != NULL) td.ctc->closing_transition = -1; + if (td.otc != nullptr) td.otc->opening_transition = -1; + if (td.ctc != nullptr) td.ctc->closing_transition = -1; } else { emit start_create_dual_transition(&td, primary, secondary, meta); @@ -486,7 +486,7 @@ bool LoadThread::load_worker(QFile& f, QXmlStreamReader& stream, int type) { } } - Media* m = panel_project->new_sequence(NULL, s, false, parent); + Media* m = panel_project->new_sequence(nullptr, s, false, parent); loaded_sequences.append(m); } @@ -503,14 +503,14 @@ bool LoadThread::load_worker(QFile& f, QXmlStreamReader& stream, int type) { } Media* LoadThread::find_loaded_folder_by_id(int id) { - if (id == 0) return NULL; + if (id == 0) return nullptr; for (int j=0;jtemp_id == id) { return parent_item; } } - return NULL; + return nullptr; } void LoadThread::run() { @@ -538,7 +538,7 @@ void LoadThread::run() { show_err = true; // temp variables for loading (unnecessary?) - open_seq = NULL; + open_seq = nullptr; loaded_folders.clear(); loaded_media_items.clear(); loaded_clips.clear(); @@ -573,7 +573,7 @@ void LoadThread::run() { Media* folder = loaded_folders.at(i); int parent = folder->temp_id2; if (folder->temp_id2 == 0) { - project_model.appendChild(NULL, folder); + project_model.appendChild(nullptr, folder); } else { find_loaded_folder_by_id(parent)->appendChild(folder); } @@ -601,7 +601,7 @@ void LoadThread::run() { // attach nested sequence clips to their sequences for (int i=0;imedia == NULL && loaded_clips.at(i)->media_stream == loaded_sequences.at(j)->to_sequence()->save_id) { + if (loaded_clips.at(i)->media == nullptr && loaded_clips.at(i)->media_stream == loaded_sequences.at(j)->to_sequence()->save_id) { loaded_clips.at(i)->media = loaded_sequences.at(j); loaded_clips.at(i)->refresh(); break; @@ -659,7 +659,7 @@ void LoadThread::success_func() { } mainWindow->setWindowModified(autorecovery); - if (open_seq != NULL) set_sequence(open_seq); + if (open_seq != nullptr) set_sequence(open_seq); update_ui(false); } @@ -695,7 +695,7 @@ void LoadThread::create_effect_ui( if (cancelled) return; if (type == TA_NO_TRANSITION) { - if (meta == NULL) { + if (meta == nullptr) { // create void effect VoidEffect* ve = new VoidEffect(c, *effect_name); ve->set_enabled(effect_enabled); @@ -709,7 +709,7 @@ void LoadThread::create_effect_ui( c->effects.append(e); } } else { - int transition_index = create_transition(c, NULL, meta); + int transition_index = create_transition(c, nullptr, meta); Transition* t = c->sequence->transitions.at(transition_index); if (effect_length > -1) t->set_length(effect_length); t->set_enabled(effect_enabled); @@ -728,7 +728,7 @@ void LoadThread::create_effect_ui( void LoadThread::create_dual_transition(const TransitionData* td, Clip* primary, Clip* secondary, const EffectMeta* meta) { int transition_index = create_transition(primary, secondary, meta); primary->sequence->transitions.at(transition_index)->set_length(td->length); - if (td->otc != NULL) td->otc->opening_transition = transition_index; - if (td->ctc != NULL) td->ctc->closing_transition = transition_index; + if (td->otc != nullptr) td->otc->opening_transition = transition_index; + if (td->ctc != nullptr) td->ctc->closing_transition = transition_index; waitCond.wakeAll(); } diff --git a/io/loadthread.h b/io/loadthread.h index e3ae55fe3..f591fb966 100644 --- a/io/loadthread.h +++ b/io/loadthread.h @@ -12,60 +12,60 @@ struct Footage; struct Clip; struct Sequence; class LoadDialog; -class TransitionData; +struct TransitionData; struct EffectMeta; class LoadThread : public QThread { - Q_OBJECT + Q_OBJECT public: - LoadThread(LoadDialog* l, bool a); - void run(); - void cancel(); + LoadThread(LoadDialog* l, bool a); + void run(); + void cancel(); signals: - void success(); + void success(); void error(); - void start_create_effect_ui(QXmlStreamReader* stream, Clip* c, int type, const QString *effect_name, const EffectMeta* meta, long effect_length, bool effect_enabled); + void start_create_effect_ui(QXmlStreamReader* stream, Clip* c, int type, const QString *effect_name, const EffectMeta* meta, long effect_length, bool effect_enabled); void start_create_dual_transition(const TransitionData* td, Clip* primary, Clip* secondary, const EffectMeta* meta); - void report_progress(int p); + void report_progress(int p); private slots: void error_func(); - void success_func(); - void create_effect_ui(QXmlStreamReader* stream, Clip* c, int type, const QString *effect_name, const EffectMeta* meta, long effect_length, bool effect_enabled); + void success_func(); + void create_effect_ui(QXmlStreamReader* stream, Clip* c, int type, const QString *effect_name, const EffectMeta* meta, long effect_length, bool effect_enabled); void create_dual_transition(const TransitionData* td, Clip* primary, Clip* secondary, const EffectMeta* meta); private: - LoadDialog* ld; - bool autorecovery; + LoadDialog* ld; + bool autorecovery; - bool load_worker(QFile& f, QXmlStreamReader& stream, int type); - void load_effect(QXmlStreamReader& stream, Clip* c); + bool load_worker(QFile& f, QXmlStreamReader& stream, int type); + void load_effect(QXmlStreamReader& stream, Clip* c); - void read_next(QXmlStreamReader& stream); - void read_next_start_element(QXmlStreamReader& stream); - void update_current_element_count(QXmlStreamReader& stream); + void read_next(QXmlStreamReader& stream); + void read_next_start_element(QXmlStreamReader& stream); + void update_current_element_count(QXmlStreamReader& stream); - Sequence* open_seq; - QVector loaded_media_items; - QDir proj_dir; - QDir internal_proj_dir; - QString internal_proj_url; - bool show_err; - QString error_str; + Sequence* open_seq; + QVector loaded_media_items; + QDir proj_dir; + QDir internal_proj_dir; + QString internal_proj_url; + bool show_err; + QString error_str; - bool is_element(QXmlStreamReader& stream); + bool is_element(QXmlStreamReader& stream); - QVector loaded_folders; - QVector loaded_clips; - QVector loaded_sequences; - Media* find_loaded_folder_by_id(int id); + QVector loaded_folders; + QVector loaded_clips; + QVector loaded_sequences; + Media* find_loaded_folder_by_id(int id); - int current_element_count; - int total_element_count; + int current_element_count; + int total_element_count; - QMutex mutex; - QWaitCondition waitCond; + QMutex mutex; + QWaitCondition waitCond; - bool cancelled; + bool cancelled; bool xml_error; }; diff --git a/io/previewgenerator.cpp b/io/previewgenerator.cpp index cbc386743..4755c77e9 100644 --- a/io/previewgenerator.cpp +++ b/io/previewgenerator.cpp @@ -31,7 +31,7 @@ QSemaphore sem(5); // only 5 preview generators can run at one time PreviewGenerator::PreviewGenerator(Media* i, Footage* m, bool r) : QThread(0), - fmt_ctx(NULL), + fmt_ctx(nullptr), media(i), footage(m), retrieve_duration(false), @@ -52,7 +52,7 @@ void PreviewGenerator::parse_media() { // detect video/audio streams in file for (int i=0;i<(int)fmt_ctx->nb_streams;i++) { // Find the decoder for the video stream - if (avcodec_find_decoder(fmt_ctx->streams[i]->codecpar->codec_id) == NULL) { + if (avcodec_find_decoder(fmt_ctx->streams[i]->codecpar->codec_id) == nullptr) { qCritical() << "Unsupported codec in stream" << i << "of file" << footage->name; } else { FootageStream ms; @@ -219,13 +219,13 @@ void PreviewGenerator::generate_waveform() { AVCodecContext** codec_ctx = new AVCodecContext* [fmt_ctx->nb_streams]; int64_t* media_lengths = new int64_t[fmt_ctx->nb_streams]{0}; for (unsigned int i=0;inb_streams;i++) { - codec_ctx[i] = NULL; + codec_ctx[i] = nullptr; if (fmt_ctx->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO || fmt_ctx->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) { AVCodec* codec = avcodec_find_decoder(fmt_ctx->streams[i]->codecpar->codec_id); - if (codec != NULL) { + if (codec != nullptr) { codec_ctx[i] = avcodec_alloc_context3(codec); avcodec_parameters_to_context(codec_ctx[i], fmt_ctx->streams[i]->codecpar); - avcodec_open2(codec_ctx[i], codec, NULL); + avcodec_open2(codec_ctx[i], codec, nullptr); if (fmt_ctx->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO && codec_ctx[i]->channel_layout == 0) { codec_ctx[i]->channel_layout = av_get_default_channel_layout(fmt_ctx->streams[i]->codecpar->channels); } @@ -241,11 +241,11 @@ void PreviewGenerator::generate_waveform() { // get the ball rolling do { av_read_frame(fmt_ctx, packet); - } while (codec_ctx[packet->stream_index] == NULL); + } while (codec_ctx[packet->stream_index] == nullptr); avcodec_send_packet(codec_ctx[packet->stream_index], packet); while (!end_of_file) { - while (codec_ctx[packet->stream_index] == NULL || avcodec_receive_frame(codec_ctx[packet->stream_index], temp_frame) == AVERROR(EAGAIN)) { + while (codec_ctx[packet->stream_index] == nullptr || avcodec_receive_frame(codec_ctx[packet->stream_index], temp_frame) == AVERROR(EAGAIN)) { av_packet_unref(packet); int read_ret = av_read_frame(fmt_ctx, packet); @@ -256,7 +256,7 @@ void PreviewGenerator::generate_waveform() { if (read_ret != AVERROR_EOF) qCritical() << "Failed to read packet for preview generation" << read_ret; break; } - if (codec_ctx[packet->stream_index] != NULL) { + if (codec_ctx[packet->stream_index] != nullptr) { int send_ret = avcodec_send_packet(codec_ctx[packet->stream_index], packet); if (send_ret < 0 && send_ret != AVERROR(EAGAIN)) { qCritical() << "Failed to send packet for preview generation - aborting" << send_ret; @@ -267,7 +267,7 @@ void PreviewGenerator::generate_waveform() { } if (!end_of_file) { FootageStream* s = footage->get_stream_from_file_index(fmt_ctx->streams[packet->stream_index]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO, packet->stream_index); - if (s != NULL) { + if (s != nullptr) { if (fmt_ctx->streams[packet->stream_index]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) { if (!s->preview_done) { int dstH = 120; @@ -282,9 +282,9 @@ void PreviewGenerator::generate_waveform() { dstH, static_cast(AV_PIX_FMT_RGBA), SWS_FAST_BILINEAR, - NULL, - NULL, - NULL + nullptr, + nullptr, + nullptr ); int linesize[AV_NUM_DATA_POINTERS]; @@ -304,7 +304,7 @@ void PreviewGenerator::generate_waveform() { if (!retrieve_duration) { avcodec_close(codec_ctx[packet->stream_index]); - codec_ctx[packet->stream_index] = NULL; + codec_ctx[packet->stream_index] = nullptr; } } media_lengths[packet->stream_index]++; @@ -317,7 +317,7 @@ void PreviewGenerator::generate_waveform() { swr_frame->format = AV_SAMPLE_FMT_S16P; swr_ctx = swr_alloc_set_opts( - NULL, + nullptr, temp_frame->channel_layout, static_cast(swr_frame->format), temp_frame->sample_rate, @@ -325,7 +325,7 @@ void PreviewGenerator::generate_waveform() { static_cast(temp_frame->format), temp_frame->sample_rate, 0, - NULL + nullptr ); swr_init(swr_ctx); @@ -394,7 +394,7 @@ void PreviewGenerator::generate_waveform() { av_frame_free(&temp_frame); av_packet_free(&packet); for (unsigned int i=0;inb_streams;i++) { - if (codec_ctx[i] != NULL) { + if (codec_ctx[i] != nullptr) { avcodec_close(codec_ctx[i]); } } @@ -422,8 +422,8 @@ QString PreviewGenerator::get_waveform_path(const QString& hash, const FootageSt } void PreviewGenerator::run() { - Q_ASSERT(footage != NULL); - Q_ASSERT(media != NULL); + Q_ASSERT(footage != nullptr); + Q_ASSERT(media != nullptr); QByteArray ba = footage->url.toUtf8(); char* filename = new char[ba.size()+1]; @@ -431,14 +431,14 @@ void PreviewGenerator::run() { QString errorStr; bool error = false; - int errCode = avformat_open_input(&fmt_ctx, filename, NULL, NULL); + int errCode = avformat_open_input(&fmt_ctx, filename, nullptr, nullptr); if(errCode != 0) { char err[1024]; av_strerror(errCode, err, 1024); errorStr = "Could not open file - " + QString(err); error = true; } else { - errCode = avformat_find_stream_info(fmt_ctx, NULL); + errCode = avformat_find_stream_info(fmt_ctx, nullptr); if (errCode < 0) { char err[1024]; av_strerror(errCode, err, 1024); @@ -490,7 +490,7 @@ void PreviewGenerator::run() { } delete [] filename; - footage->preview_gen = NULL; + footage->preview_gen = nullptr; } void PreviewGenerator::cancel() { diff --git a/io/qpainterwrapper.cpp b/io/qpainterwrapper.cpp index 024fac1b8..b86a05441 100644 --- a/io/qpainterwrapper.cpp +++ b/io/qpainterwrapper.cpp @@ -15,7 +15,7 @@ QColor get_color_from_string(const QString& s) { // workaround for alpha if (s.at(0) == '#' && s.length() == 9) { QColor color(s.left(7)); - color.setAlpha(s.mid(7).toInt(NULL, 16)); + color.setAlpha(s.mid(7).toInt(nullptr, 16)); return color; } else { return QColor(s); diff --git a/main.cpp b/main.cpp index 11668c0ae..f2806308e 100644 --- a/main.cpp +++ b/main.cpp @@ -25,19 +25,19 @@ int main(int argc, char *argv[]) { if (argc > 1) { for (int i=1;i actions = menu->actions(); for (int i=0;imenu() != NULL) { + if (a->menu() != nullptr) { kbd_shortcut_processor(file, a->menu(), save, first); } else if (!a->isSeparator()) { if (save) { @@ -415,7 +415,7 @@ void MainWindow::zoom_out() { } void MainWindow::export_dialog() { - if (sequence == NULL) { + if (sequence == nullptr) { QMessageBox::information(this, "No active sequence", "Please open the sequence you wish to export.", QMessageBox::Ok); } else { ExportDialog e(this); @@ -424,7 +424,7 @@ void MainWindow::export_dialog() { } void MainWindow::ripple_delete() { - if (sequence != NULL) panel_timeline->delete_selection(sequence->selections, true); + if (sequence != nullptr) panel_timeline->delete_selection(sequence->selections, true); } void MainWindow::editMenu_About_To_Be_Shown() { @@ -445,11 +445,11 @@ void MainWindow::redo() { } void MainWindow::open_speed_dialog() { - if (sequence != NULL) { + if (sequence != nullptr) { SpeedDialog s(this); for (int i=0;iclips.size();i++) { Clip* c = sequence->clips.at(i); - if (c != NULL && panel_timeline->is_clip_selected(c, true)) { + if (c != nullptr && panel_timeline->is_clip_selected(c, true)) { s.clips.append(c); } } @@ -458,7 +458,7 @@ void MainWindow::open_speed_dialog() { } void MainWindow::cut() { - if (sequence != NULL) { + if (sequence != nullptr) { QDockWidget* focused_panel = get_focused_panel(); if (panel_timeline == focused_panel) { panel_timeline->copy(true); @@ -469,7 +469,7 @@ void MainWindow::cut() { } void MainWindow::copy() { - if (sequence != NULL) { + if (sequence != nullptr) { QDockWidget* focused_panel = get_focused_panel(); if (panel_timeline == focused_panel) { panel_timeline->copy(false); @@ -481,7 +481,7 @@ void MainWindow::copy() { void MainWindow::paste() { QDockWidget* focused_panel = get_focused_panel(); - if ((panel_timeline == focused_panel || panel_effect_controls == focused_panel) && sequence != NULL) { + if ((panel_timeline == focused_panel || panel_effect_controls == focused_panel) && sequence != nullptr) { panel_timeline->paste(false); } } @@ -918,7 +918,7 @@ void MainWindow::closeEvent(QCloseEvent *e) { if (can_close_project()) { panel_effect_controls->clear_effects(true); - set_sequence(NULL); + set_sequence(nullptr); panel_footage_viewer->set_main_sequence(); @@ -1076,13 +1076,13 @@ void MainWindow::playpause() { } void MainWindow::prev_cut() { - if (sequence != NULL && (panel_timeline->focused() || panel_sequence_viewer->is_focused())) { + if (sequence != nullptr && (panel_timeline->focused() || panel_sequence_viewer->is_focused())) { panel_timeline->previous_cut(); } } void MainWindow::next_cut() { - if (sequence != NULL && (panel_timeline->focused() || panel_sequence_viewer->is_focused())) { + if (sequence != nullptr && (panel_timeline->focused() || panel_sequence_viewer->is_focused())) { panel_timeline->next_cut(); } } @@ -1352,16 +1352,16 @@ void MainWindow::set_tsa_custom() { } void MainWindow::set_marker() { - if (sequence != NULL) panel_timeline->set_marker(); + if (sequence != nullptr) panel_timeline->set_marker(); } void MainWindow::toggle_enable_clips() { - if (sequence != NULL) { + if (sequence != nullptr) { ComboAction* ca = new ComboAction(); bool push_undo = false; for (int i=0;iclips.size();i++) { Clip* c = sequence->clips.at(i); - if (c != NULL && panel_timeline->is_clip_selected(c, true)) { + if (c != nullptr && panel_timeline->is_clip_selected(c, true)) { ca->append(new SetEnableCommand(c, !c->enabled)); push_undo = true; } @@ -1384,14 +1384,14 @@ void MainWindow::edit_to_out_point() { } void MainWindow::nest() { - if (sequence != NULL) { + if (sequence != nullptr) { QVector selected_clips; long earliest_point = LONG_MAX; // get selected clips for (int i=0;iclips.size();i++) { Clip* c = sequence->clips.at(i); - if (c != NULL && panel_timeline->is_clip_selected(c, true)) { + if (c != nullptr && panel_timeline->is_clip_selected(c, true)) { selected_clips.append(i); earliest_point = qMin(c->timeline_in, earliest_point); } @@ -1424,7 +1424,7 @@ void MainWindow::nest() { } // add sequence to project - Media* m = panel_project->new_sequence(ca, s, false, NULL); + Media* m = panel_project->new_sequence(ca, s, false, nullptr); // add nested sequence to active sequence QVector media_list; @@ -1443,7 +1443,7 @@ void MainWindow::nest() { } void MainWindow::paste_insert() { - if (panel_timeline->focused() && sequence != NULL) { + if (panel_timeline->focused() && sequence != nullptr) { panel_timeline->paste(true); } } diff --git a/olive.pro b/olive.pro index 112eb4e83..e47ba1c0a 100644 --- a/olive.pro +++ b/olive.pro @@ -33,6 +33,8 @@ system("which git") { DEFINES += GITHASH=\\"\"$$GITHASHVAR\\"\" } +CONFIG += c++11 + SOURCES += \ main.cpp \ mainwindow.cpp \ @@ -221,9 +223,9 @@ FORMS += win32 { RC_FILE = packaging/windows/resources.rc LIBS += -lavutil -lavformat -lavcodec -lavfilter -lswscale -lswresample -lopengl32 -luser32 - - SOURCES += effects/internal/vsthostwin.cpp - HEADERS += effects/internal/vsthostwin.h + + SOURCES += effects/internal/vsthostwin.cpp + HEADERS += effects/internal/vsthostwin.h } mac { diff --git a/panels/effectcontrols.cpp b/panels/effectcontrols.cpp index aab9635a2..cb403d44a 100644 --- a/panels/effectcontrols.cpp +++ b/panels/effectcontrols.cpp @@ -78,14 +78,14 @@ void EffectControls::menu_select(QAction* q) { if ((c->track < 0) == (effect_menu_subtype == EFFECT_TYPE_VIDEO)) { const EffectMeta* meta = reinterpret_cast(q->data().value()); if (effect_menu_type == EFFECT_TYPE_TRANSITION) { - if (c->get_opening_transition() == NULL) { - ca->append(new AddTransitionCommand(c, NULL, NULL, meta, TA_OPENING_TRANSITION, 30)); + if (c->get_opening_transition() == nullptr) { + ca->append(new AddTransitionCommand(c, nullptr, nullptr, meta, TA_OPENING_TRANSITION, 30)); } - if (c->get_closing_transition() == NULL) { - ca->append(new AddTransitionCommand(c, NULL, NULL, meta, TA_CLOSING_TRANSITION, 30)); + if (c->get_closing_transition() == nullptr) { + ca->append(new AddTransitionCommand(c, nullptr, nullptr, meta, TA_CLOSING_TRANSITION, 30)); } } else { - ca->append(new AddEffectCommand(c, NULL, meta)); + ca->append(new AddEffectCommand(c, nullptr, meta)); } } } @@ -112,7 +112,7 @@ void EffectControls::copy(bool del) { bool cleared = false; ComboAction* ca = new ComboAction(); - EffectDeleteCommand* del_com = (del) ? new EffectDeleteCommand() : NULL; + EffectDeleteCommand* del_com = (del) ? new EffectDeleteCommand() : nullptr; for (int i=0;iclips.at(selected_clips.at(i)); for (int j=0;jeffects.size();j++) { @@ -124,16 +124,16 @@ void EffectControls::copy(bool del) { clipboard_type = CLIPBOARD_TYPE_EFFECT; } - clipboard.append(effect->copy(NULL)); + clipboard.append(effect->copy(nullptr)); - if (del_com != NULL) { + if (del_com != nullptr) { del_com->clips.append(c); del_com->fx.append(j); } } } } - if (del_com != NULL) { + if (del_com != nullptr) { if (del_com->clips.size() > 0) { ca->append(del_com); } else { @@ -168,7 +168,7 @@ void EffectControls::show_effect_menu(int type, int subtype) { bool found = false; for (int j=0;jmenu() != NULL) { + if (action->menu() != nullptr) { if (action->menu()->title() == em.category) { parent = action->menu(); found = true; @@ -214,20 +214,20 @@ void EffectControls::show_effect_menu(int type, int subtype) { void EffectControls::clear_effects(bool clear_cache) { // clear existing clips - deselect_all_effects(NULL); + deselect_all_effects(nullptr); // clear graph editor - if (panel_graph_editor != NULL) panel_graph_editor->set_row(NULL); + if (panel_graph_editor != nullptr) panel_graph_editor->set_row(nullptr); QVBoxLayout* video_layout = static_cast(video_effect_area->layout()); QVBoxLayout* audio_layout = static_cast(audio_effect_area->layout()); QLayoutItem* item; while ((item = video_layout->takeAt(0))) { - item->widget()->setParent(NULL); + item->widget()->setParent(nullptr); disconnect(static_cast(item->widget()), SIGNAL(deselect_others(QWidget*)), this, SLOT(deselect_all_effects(QWidget*))); } while ((item = audio_layout->takeAt(0))) { - item->widget()->setParent(NULL); + item->widget()->setParent(nullptr); disconnect(static_cast(item->widget()), SIGNAL(deselect_others(QWidget*)), this, SLOT(deselect_all_effects(QWidget*))); } lblMultipleClipsSelected->setVisible(false); @@ -455,9 +455,9 @@ void EffectControls::load_effects() { for (int j=0;jeffects.size();j++) { open_effect(layout, c->effects.at(j)); } - } else if (mode == TA_OPENING_TRANSITION && c->get_opening_transition() != NULL) { + } else if (mode == TA_OPENING_TRANSITION && c->get_opening_transition() != nullptr) { open_effect(layout, c->get_opening_transition()); - } else if (mode == TA_CLOSING_TRANSITION && c->get_closing_transition() != NULL) { + } else if (mode == TA_CLOSING_TRANSITION && c->get_closing_transition() != nullptr) { open_effect(layout, c->get_closing_transition()); } } @@ -533,14 +533,14 @@ bool EffectControls::is_focused() { if (this->hasFocus()) return true; for (int i=0;iclips.at(selected_clips.at(i)); - if (c != NULL) { + if (c != nullptr) { for (int j=0;jeffects.size();j++) { if (c->effects.at(j)->container->is_focused()) { return true; } } } else { - qWarning() << "Tried to check focus of a NULL clip"; + qWarning() << "Tried to check focus of a nullptr clip"; } } return false; diff --git a/panels/grapheditor.cpp b/panels/grapheditor.cpp index 2cb44f673..311b03b72 100644 --- a/panels/grapheditor.cpp +++ b/panels/grapheditor.cpp @@ -17,7 +17,7 @@ #include "panels.h" #include "debug.h" -GraphEditor::GraphEditor(QWidget* parent) : QDockWidget(parent), row(NULL) { +GraphEditor::GraphEditor(QWidget* parent) : QDockWidget(parent), row(nullptr) { setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); setWindowTitle("Graph Editor"); @@ -120,7 +120,7 @@ GraphEditor::GraphEditor(QWidget* parent) : QDockWidget(parent), row(NULL) { void GraphEditor::update_panel() { if (isVisible()) { - if (row != NULL) { + if (row != nullptr) { int slider_index = 0; for (int i=0;ifieldCount();i++) { EffectField* field = row->field(i); @@ -145,7 +145,7 @@ void GraphEditor::set_row(EffectRow *r) { slider_proxy_buttons.clear(); slider_proxy_sources.clear(); - if (row != NULL) { + if (row != nullptr) { // clear old row connections disconnect(keyframe_nav, SIGNAL(goto_previous_key()), row, SLOT(goto_previous_key())); disconnect(keyframe_nav, SIGNAL(toggle_key()), row, SLOT(toggle_key())); @@ -154,7 +154,7 @@ void GraphEditor::set_row(EffectRow *r) { bool found_vals = false; - if (r != NULL && r->isKeyframing()) { + if (r != nullptr && r->isKeyframing()) { for (int i=0;ifieldCount();i++) { EffectField* field = r->field(i); if (field->type == EFFECT_FIELD_DOUBLE) { @@ -191,7 +191,7 @@ void GraphEditor::set_row(EffectRow *r) { connect(keyframe_nav, SIGNAL(toggle_key()), row, SLOT(toggle_key())); connect(keyframe_nav, SIGNAL(goto_next_key()), row, SLOT(goto_next_key())); } else { - row = NULL; + row = nullptr; current_row_desc->setText(0); } view->set_row(row); diff --git a/panels/panels.cpp b/panels/panels.cpp index c5653a171..9a8d8b310 100644 --- a/panels/panels.cpp +++ b/panels/panels.cpp @@ -30,10 +30,10 @@ void update_effect_controls() { int aclip = -1; QVector selected_clips; int mode = TA_NO_TRANSITION; - if (sequence != NULL) { + if (sequence != nullptr) { for (int i=0;iclips.size();i++) { Clip* clip = sequence->clips.at(i); - if (clip != NULL) { + if (clip != nullptr) { for (int j=0;jselections.size();j++) { const Selection& s = sequence->selections.at(j); bool add = true; @@ -113,7 +113,7 @@ void update_ui(bool modified) { } QDockWidget *get_focused_panel() { - QDockWidget* w = NULL; + QDockWidget* w = nullptr; if (config.hover_focus) { if (panel_project->underMouse()) { w = panel_project; @@ -127,7 +127,7 @@ QDockWidget *get_focused_panel() { w = panel_timeline; } } - if (w == NULL) { + if (w == nullptr) { if (panel_project->is_focused()) { w = panel_project; } else if (panel_effect_controls->keyframe_focus() || panel_effect_controls->is_focused()) { @@ -162,15 +162,15 @@ void alloc_panels(QWidget* parent) { void free_panels() { delete panel_sequence_viewer; - panel_sequence_viewer = NULL; + panel_sequence_viewer = nullptr; delete panel_footage_viewer; - panel_footage_viewer = NULL; + panel_footage_viewer = nullptr; delete panel_project; - panel_project = NULL; + panel_project = nullptr; delete panel_effect_controls; - panel_effect_controls = NULL; + panel_effect_controls = nullptr; delete panel_timeline; - panel_timeline = NULL; + panel_timeline = nullptr; } void scroll_to_frame_internal(QScrollBar* bar, long frame, double zoom, int area_width) { diff --git a/panels/project.cpp b/panels/project.cpp index 66d40039c..a063b3fb1 100644 --- a/panels/project.cpp +++ b/panels/project.cpp @@ -236,7 +236,7 @@ Sequence* create_sequence_from_media(QVector& media_list) { const FootageStream& ms = m->video_tracks.at(j); s->width = ms.video_width; s->height = ms.video_height; - if (ms.video_frame_rate != 0) { + if (qFuzzyCompare(ms.video_frame_rate, 0.0)) { s->frame_rate = ms.video_frame_rate * m->speed; if (ms.video_interlacing != VIDEO_PROGRESSIVE) s->frame_rate *= 2; @@ -247,13 +247,10 @@ Sequence* create_sequence_from_media(QVector& media_list) { } } } - if (!got_audio_values) { - for (int j=0;jaudio_tracks.size();j++) { - const FootageStream& ms = m->audio_tracks.at(j); - s->audio_frequency = ms.audio_frequency; - got_audio_values = true; - break; - } + if (!got_audio_values && m->audio_tracks.size() > 0) { + const FootageStream& ms = m->audio_tracks.at(0); + s->audio_frequency = ms.audio_frequency; + got_audio_values = true; } } } @@ -301,7 +298,7 @@ void Project::replace_selected_file() { if (selected_items.size() == 1) { Media* item = item_to_media(selected_items.at(0)); if (item->get_type() == MEDIA_TYPE_FOOTAGE) { - replace_media(item, 0); + replace_media(item, nullptr); } } } @@ -317,7 +314,7 @@ void Project::replace_media(Media* item, QString filename) { } void Project::replace_clip_media() { - if (sequence == NULL) { + if (sequence == nullptr) { QMessageBox::critical(this, "No active sequence", "No sequence is active, please open the sequence you want to replace clips from.", QMessageBox::Ok); } else { QModelIndexList selected_items = get_current_selected(); @@ -364,11 +361,11 @@ void Project::open_properties() { } Media* Project::new_sequence(ComboAction *ca, Sequence *s, bool open, Media* parent) { - if (parent == NULL) parent = project_model.get_root(); + if (parent == nullptr) parent = project_model.get_root(); Media* item = new Media(parent); item->set_sequence(s); - if (ca != NULL) { + if (ca != nullptr) { ca->append(new NewSequenceCommand(item, parent)); if (open) ca->append(new ChangeSequenceAction(s)); } else { @@ -397,7 +394,7 @@ bool Project::is_focused() { } Media* Project::new_folder(QString name) { - Media* item = new Media(0); + Media* item = new Media(nullptr); item->set_folder(); item->set_name(name); return item; @@ -466,14 +463,14 @@ void Project::delete_selected_media() { Sequence* s = sequence_items.at(j)->to_sequence(); for (int k=0;kclips.size();k++) { Clip* c = s->clips.at(k); - if (c != NULL && c->media == item) { + if (c != nullptr && c->media == item) { if (!confirm_delete) { // we found a reference, so we know we'll need to ask if the user wants to delete it QMessageBox confirm(this); confirm.setWindowTitle("Delete media in use?"); confirm.setText("The media '" + media->name + "' is currently used in '" + s->name + "'. Deleting it will remove all instances in the sequence. Are you sure you want to do this?"); QAbstractButton* yes_button = confirm.addButton(QMessageBox::Yes); - QAbstractButton* skip_button = NULL; + QAbstractButton* skip_button = nullptr; if (items.size() > 1) skip_button = confirm.addButton("Skip", QMessageBox::NoRole); QAbstractButton* abort_button = confirm.addButton(QMessageBox::Cancel); confirm.exec(); @@ -484,7 +481,7 @@ void Project::delete_selected_media() { } else if (confirm.clickedButton() == skip_button) { // remove media item and any folders containing it from the remove list Media* parent = item; - while (parent != NULL) { + while (parent != nullptr) { parents.append(parent); // re-add item's siblings @@ -531,7 +528,7 @@ void Project::delete_selected_media() { // remove if (remove) { panel_effect_controls->clear_effects(true); - if (sequence != NULL) sequence->selections.clear(); + if (sequence != nullptr) sequence->selections.clear(); // remove media and parents for (int m=0;mto_sequence(); if (s == sequence) { - ca->append(new ChangeSequenceAction(NULL)); + ca->append(new ChangeSequenceAction(nullptr)); } if (s == panel_footage_viewer->seq) { - panel_footage_viewer->set_media(NULL); + panel_footage_viewer->set_media(nullptr); } } else if (items.at(i)->get_type() == MEDIA_TYPE_FOOTAGE) { - if (panel_footage_viewer->seq != NULL) { + if (panel_footage_viewer->seq != nullptr) { for (int j=0;jseq->clips.size();j++) { Clip* c = panel_footage_viewer->seq->clips.at(j); - if (c != NULL && c->media == items.at(i)) { - panel_footage_viewer->set_media(NULL); + if (c != nullptr && c->media == items.at(i)) { + panel_footage_viewer->set_media(nullptr); break; } } @@ -603,8 +600,8 @@ void Project::process_file_list(QStringList& files, bool recursive, Media* repla if (!recursive) last_imported_media.clear(); - bool create_undo_action = (!recursive && replace == NULL); - ComboAction* ca; + bool create_undo_action = (!recursive && replace == nullptr); + ComboAction* ca = nullptr; if (create_undo_action) ca = new ComboAction(); for (int i=0;iappend(new AddMediaCommand(folder, parent)); @@ -711,7 +708,7 @@ void Project::process_file_list(QStringList& files, bool recursive, Media* repla Media* item; Footage* m; - if (replace != NULL) { + if (replace != nullptr) { item = replace; m = replace->to_footage(); m->reset(); @@ -728,7 +725,7 @@ void Project::process_file_list(QStringList& files, bool recursive, Media* repla last_imported_media.append(item); - if (replace == NULL) { + if (replace == nullptr) { if (create_undo_action) { ca->append(new AddMediaCommand(item, parent)); } else { @@ -747,7 +744,7 @@ void Project::process_file_list(QStringList& files, bool recursive, Media* repla for (int i=0;iget_type() == MEDIA_TYPE_FOLDER) return m; } - return NULL; + return nullptr; } bool Project::reveal_media(Media *media, QModelIndex parent) { @@ -805,12 +802,12 @@ void Project::import_dialog() { if (fd.exec()) { QStringList files = fd.selectedFiles(); - process_file_list(files, false, NULL, get_selected_folder()); + process_file_list(files, false, nullptr, get_selected_folder()); } } void Project::delete_clips_using_selected_media() { - if (sequence == NULL) { + if (sequence == nullptr) { QMessageBox::critical(this, "No active sequence", "No sequence is active, please open the sequence you want to delete clips from.", QMessageBox::Ok); } else { ComboAction* ca = new ComboAction(); @@ -818,7 +815,7 @@ void Project::delete_clips_using_selected_media() { QModelIndexList items = get_current_selected(); for (int i=0;iclips.size();i++) { Clip* c = sequence->clips.at(i); - if (c != NULL) { + if (c != nullptr) { for (int j=0;jmedia == m) { @@ -849,7 +846,7 @@ void Project::clear() { QVector sequences = list_all_project_sequences(); for (int i=0;ito_sequence(); - sequences.at(i)->set_sequence(NULL); + sequences.at(i)->set_sequence(nullptr); } // delete everything else @@ -858,8 +855,8 @@ void Project::clear() { void Project::new_project() { // clear existing project - set_sequence(NULL); - panel_footage_viewer->set_media(NULL); + set_sequence(nullptr); + panel_footage_viewer->set_media(nullptr); clear(); mainWindow->setWindowModified(false); } @@ -895,7 +892,7 @@ void Project::save_folder(QXmlStreamWriter& stream, int type, bool set_ids_only, } // save_folder(stream, item, type, set_ids_only); } else { - int folder = (m->parentItem() != NULL) ? m->parentItem()->temp_id : 0; + int folder = (m->parentItem() != nullptr) ? m->parentItem()->temp_id : 0; if (type == MEDIA_TYPE_FOOTAGE) { Footage* f = m->to_footage(); f->save_id = media_id; @@ -955,7 +952,7 @@ void Project::save_folder(QXmlStreamWriter& stream, int type, bool set_ids_only, for (int j=0;jtransitions.size();j++) { Transition* t = s->transitions.at(j); - if (t != NULL) { + if (t != nullptr) { stream.writeStartElement("transition"); stream.writeAttribute("id", QString::number(j)); stream.writeAttribute("length", QString::number(t->get_true_length())); @@ -966,7 +963,7 @@ void Project::save_folder(QXmlStreamWriter& stream, int type, bool set_ids_only, for (int j=0;jclips.size();j++) { Clip* c = s->clips.at(j); - if (c != NULL) { + if (c != nullptr) { stream.writeStartElement("clip"); // clip stream.writeAttribute("id", QString::number(j)); stream.writeAttribute("enabled", QString::number(c->enabled)); @@ -987,7 +984,7 @@ void Project::save_folder(QXmlStreamWriter& stream, int type, bool set_ids_only, stream.writeAttribute("maintainpitch", QString::number(c->maintain_audio_pitch)); stream.writeAttribute("reverse", QString::number(c->reverse)); - if (c->media != NULL) { + if (c->media != nullptr) { stream.writeAttribute("type", QString::number(c->media->get_type())); switch (c->media->get_type()) { case MEDIA_TYPE_FOOTAGE: @@ -1184,7 +1181,7 @@ void Project::list_all_sequences_worker(QVector* list, Media* parent) { QVector Project::list_all_project_sequences() { QVector list; - list_all_sequences_worker(&list, NULL); + list_all_sequences_worker(&list, nullptr); return list; } @@ -1198,7 +1195,7 @@ QModelIndexList Project::get_current_selected() { #define THROBBER_LIMIT 20 #define THROBBER_SIZE 50 -MediaThrobber::MediaThrobber(Media *i) : pixmap(":/icons/throbber.png"), animation(0), item(i), animator(NULL) {} +MediaThrobber::MediaThrobber(Media *i) : pixmap(":/icons/throbber.png"), animation(0), item(i), animator(nullptr) {} void MediaThrobber::start() { // set up throbber @@ -1218,7 +1215,7 @@ void MediaThrobber::animation_update() { } void MediaThrobber::stop(int icon_type, bool replace) { - if (animator != NULL) { + if (animator != nullptr) { animator->stop(); delete animator; } @@ -1236,7 +1233,7 @@ void MediaThrobber::stop(int icon_type, bool replace) { Sequence* s = sequences.at(i)->to_sequence(); for (int j=0;jclips.size();j++) { Clip* c = s->clips.at(j); - if (c != NULL) { + if (c != nullptr) { c->refresh(); } } @@ -1246,6 +1243,6 @@ void MediaThrobber::stop(int icon_type, bool replace) { update_ui(replace); panel_project->tree_view->viewport()->update(); - item->throbber = NULL; + item->throbber = nullptr; deleteLater(); } diff --git a/panels/project.h b/panels/project.h index 00e2b0bb7..25eace33a 100644 --- a/panels/project.h +++ b/panels/project.h @@ -48,7 +48,7 @@ public: void clear(); Media* new_sequence(ComboAction *ca, Sequence* s, bool open, Media* parent); QString get_next_sequence_name(QString start = 0); - void process_file_list(QStringList& files, bool recursive = false, Media* replace = NULL, Media *parent = NULL); + void process_file_list(QStringList& files, bool recursive = false, Media* replace = nullptr, Media *parent = nullptr); void replace_media(Media* item, QString filename); Media *get_selected_folder(); bool reveal_media(Media *media, QModelIndex parent = QModelIndex()); diff --git a/panels/timeline.cpp b/panels/timeline.cpp index c03d61f12..4bf1a2953 100644 --- a/panels/timeline.cpp +++ b/panels/timeline.cpp @@ -112,7 +112,7 @@ void Timeline::previous_cut() { long p_cut = 0; for (int i=0;iclips.size();i++) { Clip* c = sequence->clips.at(i); - if (c != NULL) { + if (c != nullptr) { if (c->timeline_out > p_cut && c->timeline_out < sequence->playhead) { p_cut = c->timeline_out; } else if (c->timeline_in > p_cut && c->timeline_in < sequence->playhead) { @@ -129,7 +129,7 @@ void Timeline::next_cut() { long n_cut = LONG_MAX; for (int i=0;iclips.size();i++) { Clip* c = sequence->clips.at(i); - if (c != NULL) { + if (c != nullptr) { if (c->timeline_in < n_cut && c->timeline_in > sequence->playhead) { n_cut = c->timeline_in; seek_enabled = true; @@ -164,10 +164,10 @@ void Timeline::create_ghosts_from_media(Sequence* seq, long entry_point, QVector bool can_import = true; Media* medium = media_list.at(i); - Footage* m = NULL; - Sequence* s = NULL; - void* media = NULL; - long sequence_length; + Footage* m = nullptr; + Sequence* s = nullptr; + void* media = nullptr; + long sequence_length = 0; long default_clip_in = 0; long default_clip_out = 0; @@ -186,7 +186,7 @@ void Timeline::create_ghosts_from_media(Sequence* seq, long entry_point, QVector case MEDIA_TYPE_SEQUENCE: s = medium->to_sequence(); sequence_length = s->getEndFrame(); - if (seq != NULL) sequence_length = refactor_frame_number(sequence_length, s->frame_rate, seq->frame_rate); + if (seq != nullptr) sequence_length = refactor_frame_number(sequence_length, s->frame_rate, seq->frame_rate); media = s; can_import = (s != seq && sequence_length != 0); if (s->using_workarea) { @@ -205,7 +205,7 @@ void Timeline::create_ghosts_from_media(Sequence* seq, long entry_point, QVector g.old_clip_in = g.clip_in = default_clip_in; g.media = medium; g.in = entry_point; - g.transition = NULL; + g.transition = nullptr; switch (medium->get_type()) { case MEDIA_TYPE_FOOTAGE: @@ -240,7 +240,7 @@ void Timeline::create_ghosts_from_media(Sequence* seq, long entry_point, QVector case MEDIA_TYPE_SEQUENCE: g.out = entry_point + sequence_length - default_clip_in; - if (s->using_workarea && s->enable_workarea) { + if (s->using_workarea && s->enable_workarea) { g.out -= (sequence_length - default_clip_out); } @@ -354,13 +354,13 @@ void Timeline::add_transition() { for (int i=0;iclips.size();i++) { Clip* c = sequence->clips.at(i); - if (c != NULL && is_clip_selected(c, true)) { - if (c->get_opening_transition() == NULL) { - ca->append(new AddTransitionCommand(c, NULL, NULL, get_internal_meta(TRANSITION_INTERNAL_LINEARFADE, EFFECT_TYPE_TRANSITION), TA_OPENING_TRANSITION, 30)); + if (c != nullptr && is_clip_selected(c, true)) { + if (c->get_opening_transition() == nullptr) { + ca->append(new AddTransitionCommand(c, nullptr, nullptr, get_internal_meta(TRANSITION_INTERNAL_LINEARFADE, EFFECT_TYPE_TRANSITION), TA_OPENING_TRANSITION, 30)); adding = true; } - if (c->get_closing_transition() == NULL) { - ca->append(new AddTransitionCommand(c, NULL, NULL, get_internal_meta(TRANSITION_INTERNAL_LINEARFADE, EFFECT_TYPE_TRANSITION), TA_OPENING_TRANSITION, 30)); + if (c->get_closing_transition() == nullptr) { + ca->append(new AddTransitionCommand(c, nullptr, nullptr, get_internal_meta(TRANSITION_INTERNAL_LINEARFADE, EFFECT_TYPE_TRANSITION), TA_OPENING_TRANSITION, 30)); adding = true; } } @@ -388,7 +388,7 @@ int Timeline::calculate_track_height(int track, int value) { } void Timeline::update_sequence() { - bool null_sequence = (sequence == NULL); + bool null_sequence = (sequence == nullptr); for (int i=0;isetEnabled(!null_sequence); @@ -413,14 +413,14 @@ int Timeline::get_snap_range() { } bool Timeline::focused() { - return (sequence != NULL && (headers->hasFocus() || video_area->hasFocus() || audio_area->hasFocus())); + return (sequence != nullptr && (headers->hasFocus() || video_area->hasFocus() || audio_area->hasFocus())); } void Timeline::repaint_timeline() { if (!block_repaints) { bool draw = true; - if (sequence != NULL + if (sequence != nullptr && !horizontalScrollBar->isSliderDown() && !horizontalScrollBar->is_resizing() && panel_sequence_viewer->playing @@ -446,7 +446,7 @@ void Timeline::repaint_timeline() { video_area->update(); audio_area->update(); - if (sequence != NULL) { + if (sequence != nullptr) { set_sb_max(); if (last_frame != sequence->playhead) { @@ -459,11 +459,11 @@ void Timeline::repaint_timeline() { } void Timeline::select_all() { - if (sequence != NULL) { + if (sequence != nullptr) { sequence->selections.clear(); for (int i=0;iclips.size();i++) { Clip* c = sequence->clips.at(i); - if (c != NULL) { + if (c != nullptr) { Selection s; s.in = c->timeline_in; s.out = c->timeline_out; @@ -476,31 +476,31 @@ void Timeline::select_all() { } void Timeline::scroll_to_frame(long frame) { - scroll_to_frame_internal(horizontalScrollBar, frame, zoom, timeline_area->width()); + scroll_to_frame_internal(horizontalScrollBar, frame, zoom, timeline_area->width()); } void Timeline::select_from_playhead() { - sequence->selections.clear(); - for (int i=0;iclips.size();i++) { - Clip* c = sequence->clips.at(i); - if (c != NULL - && c->timeline_in <= sequence->playhead - && c->timeline_out > sequence->playhead) { - Selection s; - s.in = c->timeline_in; - s.out = c->timeline_out; - s.track = c->track; - sequence->selections.append(s); - } - } + sequence->selections.clear(); + for (int i=0;iclips.size();i++) { + Clip* c = sequence->clips.at(i); + if (c != nullptr + && c->timeline_in <= sequence->playhead + && c->timeline_out > sequence->playhead) { + Selection s; + s.in = c->timeline_in; + s.out = c->timeline_out; + s.track = c->track; + sequence->selections.append(s); + } + } } -void Timeline::resizeEvent(QResizeEvent *event) { - if (sequence != NULL) set_sb_max(); +void Timeline::resizeEvent(QResizeEvent *) { + if (sequence != nullptr) set_sb_max(); } void Timeline::delete_in_out(bool ripple) { - if (sequence != NULL && sequence->using_workarea) { + if (sequence != nullptr && sequence->using_workarea) { QVector areas; int video_tracks = 0, audio_tracks = 0; sequence->getTrackLimits(&video_tracks, &audio_tracks); @@ -545,7 +545,7 @@ void Timeline::delete_selection(QVector& selections, bool ripple_dele bool can_ripple = true; for (int i=0;iclips.size();i++) { Clip* c = sequence->clips.at(i); - if (c != NULL && c->timeline_in < ripple_point && c->timeline_out > ripple_point) { + if (c != nullptr && c->timeline_in < ripple_point && c->timeline_out > ripple_point) { // conflict detected, but this clip may be getting deleted so let's check bool deleted = false; for (int j=0;j& selections, bool ripple_dele if (!deleted) { for (int j=0;jclips.size();j++) { Clip* cc = sequence->clips.at(j); - if (cc != NULL + if (cc != nullptr && cc->track == c->track && cc->timeline_in > c->timeline_out && cc->timeline_in < c->timeline_out + ripple_length) { @@ -646,7 +646,7 @@ Clip* Timeline::split_clip(ComboAction* ca, int p, long frame) { Clip* Timeline::split_clip(ComboAction* ca, int p, long frame, long post_in) { Clip* pre = sequence->clips.at(p); - if (pre != NULL && pre->timeline_in < frame && pre->timeline_out > frame) { // guard against attempts to split at in/out points + if (pre != nullptr && pre->timeline_in < frame && pre->timeline_out > frame) { // guard against attempts to split at in/out points Clip* post = pre->copy(sequence); long new_clip_length = frame - pre->timeline_in; @@ -656,11 +656,11 @@ Clip* Timeline::split_clip(ComboAction* ca, int p, long frame, long post_in) { move_clip(ca, pre, pre->timeline_in, frame, pre->clip_in, pre->track); - if (pre->get_opening_transition() != NULL) { - /*if (frame < pre->timeline_in + pre->get_opening_transition()->length && pre->get_opening_transition()->secondary_clip != NULL) { + if (pre->get_opening_transition() != nullptr) { + /*if (frame < pre->timeline_in + pre->get_opening_transition()->length && pre->get_opening_transition()->secondary_clip != nullptr) { // separate shared transition - ca->append(new SetPointer((void**) &pre->get_opening_transition()->secondary_clip, NULL)); - pre->get_opening_transition()->secondary_clip->closing_transition = pre->get_opening_transition()->copy(pre->get_opening_transition()->secondary_clip, NULL); + ca->append(new SetPointer((void**) &pre->get_opening_transition()->secondary_clip, nullptr)); + pre->get_opening_transition()->secondary_clip->closing_transition = pre->get_opening_transition()->copy(pre->get_opening_transition()->secondary_clip, nullptr); }*/ if (pre->get_opening_transition()->get_true_length() > new_clip_length) { @@ -669,14 +669,14 @@ Clip* Timeline::split_clip(ComboAction* ca, int p, long frame, long post_in) { post->sequence->hard_delete_transition(post, TA_OPENING_TRANSITION); } - if (pre->get_closing_transition() != NULL) { + if (pre->get_closing_transition() != nullptr) { ca->append(new DeleteTransitionCommand(pre->sequence, pre->closing_transition)); - if (pre->get_closing_transition()->secondary_clip == NULL) post->get_closing_transition()->set_length(qMin((long) post->get_closing_transition()->get_true_length(), post->getLength())); + if (pre->get_closing_transition()->secondary_clip == nullptr) post->get_closing_transition()->set_length(qMin((long) post->get_closing_transition()->get_true_length(), post->getLength())); } return post; } - return NULL; + return nullptr; } bool Timeline::has_clip_been_split(int c) { @@ -697,14 +697,14 @@ bool Timeline::split_clip_and_relink(ComboAction *ca, int clip, long frame, bool split_cache.append(clip); Clip* c = sequence->clips.at(clip); - if (c != NULL) { + if (c != nullptr) { QVector pre_clips; QVector post_clips; Clip* post = split_clip(ca, clip, frame); // if alt is not down, split clips links too - if (post == NULL) { + if (post == nullptr) { return false; } else { post_clips.append(post); @@ -721,7 +721,7 @@ bool Timeline::split_clip_and_relink(ComboAction *ca, int clip, long frame, bool if ((original_clip_is_selected && is_clip_selected(link, true)) || !original_clip_is_selected) { split_cache.append(l); Clip* s = split_clip(ca, l, frame); - if (s != NULL) { + if (s != nullptr) { pre_clips.append(l); post_clips.append(s); } @@ -770,15 +770,15 @@ void Timeline::clean_up_selections(QVector& areas) { bool selection_contains_transition(const Selection& s, Clip* c, int type) { if (type == TA_OPENING_TRANSITION) { - return c->get_opening_transition() != NULL + return c->get_opening_transition() != nullptr && s.out == c->timeline_in + c->get_opening_transition()->get_true_length() - && ((c->get_opening_transition()->secondary_clip == NULL && s.in == c->timeline_in) - || (c->get_opening_transition()->secondary_clip != NULL && s.in == c->timeline_in - c->get_opening_transition()->get_true_length())); + && ((c->get_opening_transition()->secondary_clip == nullptr && s.in == c->timeline_in) + || (c->get_opening_transition()->secondary_clip != nullptr && s.in == c->timeline_in - c->get_opening_transition()->get_true_length())); } else { - return c->get_closing_transition() != NULL + return c->get_closing_transition() != nullptr && s.in == c->timeline_out - c->get_closing_transition()->get_true_length() - && ((c->get_closing_transition()->secondary_clip == NULL && s.out == c->timeline_out) - || (c->get_closing_transition()->secondary_clip != NULL && s.out == c->timeline_out + c->get_closing_transition()->get_true_length())); + && ((c->get_closing_transition()->secondary_clip == nullptr && s.out == c->timeline_out) + || (c->get_closing_transition()->secondary_clip != nullptr && s.out == c->timeline_out + c->get_closing_transition()->get_true_length())); } } @@ -792,7 +792,7 @@ void Timeline::delete_areas_and_relink(ComboAction* ca, QVector& area const Selection& s = areas.at(i); for (int j=0;jclips.size();j++) { Clip* c = sequence->clips.at(j); - if (c != NULL && c->track == s.track && !c->undeletable) { + if (c != nullptr && c->track == s.track && !c->undeletable) { if (selection_contains_transition(s, c, TA_OPENING_TRANSITION)) { // delete opening transition ca->append(new DeleteTransitionCommand(c->sequence, c->opening_transition)); @@ -814,7 +814,7 @@ void Timeline::delete_areas_and_relink(ComboAction* ca, QVector& area // only out point is in deletion area move_clip(ca, c, c->timeline_in, s.in, c->clip_in, c->track); - if (c->get_closing_transition() != NULL) { + if (c->get_closing_transition() != nullptr) { if (s.in < c->timeline_out - c->get_closing_transition()->get_true_length()) { ca->append(new DeleteTransitionCommand(c->sequence, c->closing_transition)); } else { @@ -825,7 +825,7 @@ void Timeline::delete_areas_and_relink(ComboAction* ca, QVector& area // only in point is in deletion area move_clip(ca, c, s.out, c->timeline_out, c->clip_in + (s.out - c->timeline_in), c->track); - if (c->get_opening_transition() != NULL) { + if (c->get_opening_transition() != nullptr) { if (s.out > c->timeline_in + c->get_opening_transition()->get_true_length()) { ca->append(new DeleteTransitionCommand(c->sequence, c->opening_transition)); } else { @@ -848,7 +848,7 @@ void Timeline::copy(bool del) { for (int i=0;iclips.size();i++) { Clip* c = sequence->clips.at(i); - if (c != NULL) { + if (c != nullptr) { for (int j=0;jselections.size();j++) { const Selection& s = sequence->selections.at(j); if (s.track == c->track && !((c->timeline_in <= s.in && c->timeline_out <= s.in) || (c->timeline_in >= s.out && c->timeline_out >= s.out))) { @@ -858,7 +858,7 @@ void Timeline::copy(bool del) { clipboard_type = CLIPBOARD_TYPE_CLIP; } - Clip* copied_clip = c->copy(NULL); + Clip* copied_clip = c->copy(nullptr); // copy linked IDs (we correct these later in paste()) copied_clip->linked = c->linked; @@ -993,7 +993,7 @@ void Timeline::paste(bool insert) { for (int i=0;iclips.size();i++) { Clip* c = sequence->clips.at(i); - if (c != NULL && is_clip_selected(c, true)) { + if (c != nullptr && is_clip_selected(c, true)) { for (int j=0;j(clipboard.at(j)); if ((c->track < 0) == (e->meta->subtype == EFFECT_TYPE_VIDEO)) { @@ -1039,10 +1039,10 @@ void Timeline::paste(bool insert) { delcom->fx.append(found); ca->append(delcom); - ca->append(new AddEffectCommand(c, e->copy(c), NULL, found)); + ca->append(new AddEffectCommand(c, e->copy(c), nullptr, found)); push = true; } else { - ca->append(new AddEffectCommand(c, e->copy(c), NULL)); + ca->append(new AddEffectCommand(c, e->copy(c), nullptr)); push = true; } } @@ -1061,7 +1061,7 @@ void Timeline::paste(bool insert) { } void Timeline::ripple_to_in_point(bool in, bool ripple) { - if (sequence != NULL) { + if (sequence != nullptr) { if (sequence->clips.size() > 0) { // get track count int track_min = INT_MAX; @@ -1076,7 +1076,7 @@ void Timeline::ripple_to_in_point(bool in, bool ripple) { // find closest in point to playhead for (int i=0;iclips.size();i++) { Clip* c = sequence->clips.at(i); - if (c != NULL) { + if (c != nullptr) { track_min = qMin(track_min, c->track); track_max = qMax(track_max, c->track); @@ -1180,7 +1180,7 @@ bool Timeline::split_selection(ComboAction* ca) { // find clips within selection and split for (int j=0;jclips.size();j++) { Clip* clip = sequence->clips.at(j); - if (clip != NULL) { + if (clip != nullptr) { for (int i=0;iselections.size();i++) { const Selection& s = sequence->selections.at(i); if (s.track == clip->track) { @@ -1197,12 +1197,12 @@ bool Timeline::split_selection(ComboAction* ca) { split_B->timeline_in = s.out; secondary_post_splits.append(split_B); - if (clip->get_opening_transition() != NULL) { + if (clip->get_opening_transition() != nullptr) { split_B->sequence->hard_delete_transition(split_B, TA_OPENING_TRANSITION); split_A->sequence->hard_delete_transition(split_A, TA_OPENING_TRANSITION); } - if (clip->get_closing_transition() != NULL) { + if (clip->get_closing_transition() != nullptr) { ca->append(new DeleteTransitionCommand(clip->sequence, clip->closing_transition)); split_A->sequence->hard_delete_transition(split_A, TA_CLOSING_TRANSITION); @@ -1213,13 +1213,13 @@ bool Timeline::split_selection(ComboAction* ca) { } else { Clip* post_a = split_clip(ca, j, s.in); Clip* post_b = split_clip(ca, j, s.out); - if (post_a != NULL) { + if (post_a != nullptr) { pre_splits.append(j); post_splits.append(post_a); split = true; } - if (post_b != NULL) { - if (post_a != NULL) { + if (post_b != nullptr) { + if (post_a != nullptr) { pre_splits.append(j); post_splits.append(post_b); } else { @@ -1249,7 +1249,7 @@ bool Timeline::split_all_clips_at_point(ComboAction* ca, long point) { bool split = false; for (int j=0;jclips.size();j++) { Clip* c = sequence->clips.at(j); - if (c != NULL) { + if (c != nullptr) { // always relinks if (split_clip_and_relink(ca, j, point, true)) { split = true; @@ -1270,9 +1270,9 @@ void Timeline::split_at_playhead() { QVector post_clips; for (int j=0;jclips.size();j++) { Clip* clip = sequence->clips.at(j); - if (clip != NULL && is_clip_selected(clip, true)) { + if (clip != nullptr && is_clip_selected(clip, true)) { Clip* s = split_clip(ca, j, sequence->playhead); - if (s != NULL) { + if (s != nullptr) { pre_clips.append(j); post_clips.append(s); split_selected = true; @@ -1368,15 +1368,15 @@ bool Timeline::snap_to_timeline(long* l, bool use_playhead, bool use_markers, bo // snap to clip/transition for (int i=0;iclips.size();i++) { Clip* c = sequence->clips.at(i); - if (c != NULL) { + if (c != nullptr) { if (snap_to_point(c->timeline_in, l)) { return true; } else if (snap_to_point(c->timeline_out, l)) { return true; - } else if (c->get_opening_transition() != NULL + } else if (c->get_opening_transition() != nullptr && snap_to_point(c->timeline_in + c->get_opening_transition()->get_true_length(), l)) { return true; - } else if (c->get_closing_transition() != NULL + } else if (c->get_closing_transition() != nullptr && snap_to_point(c->timeline_out - c->get_closing_transition()->get_true_length(), l)) { return true; } @@ -1410,7 +1410,7 @@ void Timeline::toggle_links() { command->s = sequence; for (int i=0;iclips.size();i++) { Clip* c = sequence->clips.at(i); - if (c != NULL && is_clip_selected(c, true)) { + if (c != nullptr && is_clip_selected(c, true)) { if (!command->clips.contains(i)) command->clips.append(i); if (c->linked.size() > 0) { @@ -1822,16 +1822,16 @@ void move_clip(ComboAction* ca, Clip *c, long iin, long iout, long iclip_in, int ca->append(new MoveClipAction(c, iin, iout, iclip_in, itrack, relative)); if (verify_transitions) { - if (c->get_opening_transition() != NULL && c->get_opening_transition()->secondary_clip != NULL && c->get_opening_transition()->secondary_clip->timeline_out != iin) { + if (c->get_opening_transition() != nullptr && c->get_opening_transition()->secondary_clip != nullptr && c->get_opening_transition()->secondary_clip->timeline_out != iin) { // separate transition - ca->append(new SetPointer((void**) &c->get_opening_transition()->secondary_clip, NULL)); - ca->append(new AddTransitionCommand(c->get_opening_transition()->secondary_clip, NULL, c->get_opening_transition(), NULL, TA_CLOSING_TRANSITION, 0)); + ca->append(new SetPointer((void**) &c->get_opening_transition()->secondary_clip, nullptr)); + ca->append(new AddTransitionCommand(c->get_opening_transition()->secondary_clip, nullptr, c->get_opening_transition(), nullptr, TA_CLOSING_TRANSITION, 0)); } - if (c->get_closing_transition() != NULL && c->get_closing_transition()->secondary_clip != NULL && c->get_closing_transition()->parent_clip->timeline_in != iout) { + if (c->get_closing_transition() != nullptr && c->get_closing_transition()->secondary_clip != nullptr && c->get_closing_transition()->parent_clip->timeline_in != iout) { // separate transition - ca->append(new SetPointer((void**) &c->get_closing_transition()->secondary_clip, NULL)); - ca->append(new AddTransitionCommand(c, NULL, c->get_closing_transition(), NULL, TA_CLOSING_TRANSITION, 0)); + ca->append(new SetPointer((void**) &c->get_closing_transition()->secondary_clip, nullptr)); + ca->append(new AddTransitionCommand(c, nullptr, c->get_closing_transition(), nullptr, TA_CLOSING_TRANSITION, 0)); } } } diff --git a/panels/viewer.cpp b/panels/viewer.cpp index be165cfd7..b6ed06df5 100644 --- a/panels/viewer.cpp +++ b/panels/viewer.cpp @@ -40,8 +40,8 @@ Viewer::Viewer(QWidget *parent) : QDockWidget(parent), playing(false), just_played(false), - media(NULL), - seq(NULL), + media(nullptr), + seq(nullptr), created_sequence(false), cue_recording_internal(false), panel_name("Viewer: "), @@ -57,7 +57,7 @@ Viewer::Viewer(QWidget *parent) : viewer_container->viewer = this; viewer_widget = viewer_container->child; viewer_widget->viewer = this; - set_media(NULL); + set_media(nullptr); currentTimecode->setEnabled(false); currentTimecode->set_minimum_value(0); @@ -101,13 +101,13 @@ void Viewer::set_main_sequence() { void Viewer::reset_all_audio() { // reset all clip audio - if (seq != NULL) { + if (seq != nullptr) { audio_ibuffer_frame = seq->playhead; audio_ibuffer_timecode = (double) audio_ibuffer_frame / seq->frame_rate; for (int i=0;iclips.size();i++) { Clip* c = seq->clips.at(i); - if (c != NULL) c->reset_audio(); + if (c != nullptr) c->reset_audio(); } } clear_audio_ibuffer(); @@ -257,19 +257,19 @@ void Viewer::seek(long p) { } void Viewer::go_to_start() { - if (seq != NULL) seek(0); + if (seq != nullptr) seek(0); } void Viewer::go_to_end() { - if (seq != NULL) seek(seq->getEndFrame()); + if (seq != nullptr) seek(seq->getEndFrame()); } void Viewer::close_media() { - set_media(NULL); + set_media(nullptr); } void Viewer::go_to_in() { - if (seq != NULL) { + if (seq != nullptr) { if (seq->using_workarea && seq->enable_workarea) { seek(seq->workarea_in); } else { @@ -279,15 +279,15 @@ void Viewer::go_to_in() { } void Viewer::previous_frame() { - if (seq != NULL && seq->playhead > 0) seek(seq->playhead-1); + if (seq != nullptr && seq->playhead > 0) seek(seq->playhead-1); } void Viewer::next_frame() { - if (seq != NULL) seek(seq->playhead+1); + if (seq != nullptr) seek(seq->playhead+1); } void Viewer::go_to_out() { - if (seq != NULL) { + if (seq != nullptr) { if (seq->using_workarea && seq->enable_workarea) { seek(seq->workarea_out); } else { @@ -327,7 +327,7 @@ void Viewer::play() { if (panel_sequence_viewer->playing) panel_sequence_viewer->pause(); if (panel_footage_viewer->playing) panel_footage_viewer->pause(); - if (seq != NULL) { + if (seq != nullptr) { if (!is_recording_cued() && seq->playhead >= get_seq_out() && (config.loop || !main_sequence)) { @@ -352,7 +352,7 @@ void Viewer::play_wake() { if (just_played) { start_msecs = QDateTime::currentMSecsSinceEpoch(); playback_updater.start(); - if (audio_thread != NULL) audio_thread->notifyReceiver(); + if (audio_thread != nullptr) audio_thread->notifyReceiver(); just_played = false; } } @@ -406,11 +406,11 @@ void Viewer::update_playhead_timecode(long p) { } void Viewer::update_end_timecode() { - endTimecode->setText((seq == NULL) ? frame_to_timecode(0, config.timecode_view, 30) : frame_to_timecode(seq->getEndFrame(), config.timecode_view, seq->frame_rate)); + endTimecode->setText((seq == nullptr) ? frame_to_timecode(0, config.timecode_view, 30) : frame_to_timecode(seq->getEndFrame(), config.timecode_view, seq->frame_rate)); } void Viewer::update_header_zoom() { - if (seq != NULL) { + if (seq != nullptr) { long sequenceEndFrame = seq->getEndFrame(); if (cached_end_frame != sequenceEndFrame) { minimum_zoom = (sequenceEndFrame > 0) ? ((double) headers->width() / (double) sequenceEndFrame) : 1; @@ -431,8 +431,8 @@ void Viewer::update_parents(bool reload_fx) { } } -void Viewer::resizeEvent(QResizeEvent *event) { - if (seq != NULL) { +void Viewer::resizeEvent(QResizeEvent *) { + if (seq != nullptr) { set_sb_max(); } } @@ -440,7 +440,7 @@ void Viewer::resizeEvent(QResizeEvent *event) { void Viewer::update_viewer() { update_header_zoom(); viewer_widget->update(); - if (seq != NULL) update_playhead_timecode(seq->playhead); + if (seq != nullptr) update_playhead_timecode(seq->playhead); update_end_timecode(); } @@ -466,7 +466,7 @@ void Viewer::clear_inout_point() { } void Viewer::toggle_enable_inout() { - if (seq != NULL && seq->using_workarea) { + if (seq != nullptr && seq->using_workarea) { undo_stack.push(new SetBool(&seq->enable_workarea, !seq->enable_workarea)); update_parents(); } @@ -481,7 +481,7 @@ void Viewer::set_out_point() { } void Viewer::set_zoom(bool in) { - if (seq != NULL) { + if (seq != nullptr) { set_zoom_value(in ? headers->get_zoom()*2 : qMax(minimum_zoom, headers->get_zoom()*0.5)); } } @@ -492,7 +492,7 @@ void Viewer::set_zoom_value(double d) { viewer_widget->waveform_zoom = d; viewer_widget->update(); } - if (seq != NULL) { + if (seq != nullptr) { set_sb_max(); if (!horizontal_bar->is_resizing()) center_scroll_to_playhead(horizontal_bar, headers->get_zoom(), seq->playhead); @@ -617,7 +617,7 @@ void Viewer::set_media(Media* m) { main_sequence = false; media = m; clean_created_seq(); - if (media != NULL) { + if (media != nullptr) { switch (media->get_type()) { case MEDIA_TYPE_FOOTAGE: { @@ -741,7 +741,7 @@ void Viewer::clean_created_seq() { }*/ delete seq; - seq = NULL; + seq = nullptr; created_sequence = false; } } @@ -751,14 +751,14 @@ void Viewer::set_sequence(bool main, Sequence *s) { reset_all_audio(); - if (seq != NULL) { + if (seq != nullptr) { closeActiveClips(seq); } main_sequence = main; seq = (main) ? sequence : s; - bool null_sequence = (seq == NULL); + bool null_sequence = (seq == nullptr); headers->setEnabled(!null_sequence); currentTimecode->setEnabled(!null_sequence); diff --git a/playback/audio.cpp b/playback/audio.cpp index 71c71b81b..eaa03137b 100644 --- a/playback/audio.cpp +++ b/playback/audio.cpp @@ -27,7 +27,7 @@ QIODevice* audio_io_device; bool audio_device_set = false; bool audio_scrub = false; QMutex audio_write_lock; -QAudioInput* audio_input = NULL; +QAudioInput* audio_input = nullptr; QFile output_recording; bool recording = false; @@ -36,7 +36,7 @@ int audio_ibuffer_read = 0; long audio_ibuffer_frame = 0; double audio_ibuffer_timecode = 0; -AudioSenderThread* audio_thread = NULL; +AudioSenderThread* audio_thread = nullptr; bool is_audio_device_set() { return audio_device_set; @@ -60,7 +60,7 @@ void init_audio() { dout << " " << devs.at(i).deviceName(); } if (info.isNull() && devs.size() > 0) { - qWarning() << "Default audio returned NULL, attempting to use first device found..."; + qWarning() << "Default audio returned nullptr, attempting to use first device found..."; info = devs.at(0); } qInfo() << "Using audio device" << info.deviceName(); @@ -76,8 +76,8 @@ void init_audio() { // connect audio_io_device = audio_output->start(); - if (audio_io_device == NULL) { - qWarning() << "Received NULL audio device. No compatible audio output was found."; + if (audio_io_device == nullptr) { + qWarning() << "Received nullptr audio device. No compatible audio output was found."; } else { audio_device_set = true; @@ -101,10 +101,10 @@ void stop_audio() { } void clear_audio_ibuffer() { - if (audio_thread != NULL) audio_thread->lock.lock(); + if (audio_thread != nullptr) audio_thread->lock.lock(); memset(audio_ibuffer, 0, audio_ibuffer_size); audio_ibuffer_read = 0; - if (audio_thread != NULL) audio_thread->lock.unlock(); + if (audio_thread != nullptr) audio_thread->lock.unlock(); } int current_audio_freq() { @@ -169,14 +169,14 @@ int AudioSenderThread::send_audio_to_output(int offset, int max) { // send samples to audio monitor cache // TODO make this work for the footage viewer - currently, enabling it causes crash due to an ASSERT - Sequence* s = NULL; + Sequence* s = nullptr; /*if (panel_footage_viewer->playing) { s = panel_footage_viewer->seq; }*/ if (panel_sequence_viewer->playing) { s = panel_sequence_viewer->seq; } - if (s != NULL) { + if (s != nullptr) { if (panel_timeline->audio_monitor->sample_cache_offset == -1) { panel_timeline->audio_monitor->sample_cache_offset = s->playhead; } @@ -287,7 +287,7 @@ void write_wave_trailer(QFile& f) { } bool start_recording() { - if (sequence == NULL) { + if (sequence == nullptr) { qCritical() << "No active sequence to record into"; return false; } @@ -338,7 +338,7 @@ void stop_recording() { output_recording.close(); delete audio_input; - audio_input = NULL; + audio_input = nullptr; recording = false; } } diff --git a/playback/cacher.cpp b/playback/cacher.cpp index cc6cddd56..998f356c1 100644 --- a/playback/cacher.cpp +++ b/playback/cacher.cpp @@ -51,8 +51,8 @@ void apply_audio_effects(Clip* c, double timecode_start, AVFrame* frame, int nb_ Effect* e = c->effects.at(j); if (e->is_enabled()) e->process_audio(timecode_start, timecode_end, frame->data[0], nb_bytes, 2); } - if (c->get_opening_transition() != NULL) { - if (c->media != NULL && c->media->get_type() == MEDIA_TYPE_FOOTAGE) { + if (c->get_opening_transition() != nullptr) { + if (c->media != nullptr && c->media->get_type() == MEDIA_TYPE_FOOTAGE) { double transition_start = (c->get_clip_in_with_transition() / c->sequence->frame_rate); double transition_end = (c->get_clip_in_with_transition() + c->get_opening_transition()->get_length()) / c->sequence->frame_rate; if (timecode_end < transition_end) { @@ -63,8 +63,8 @@ void apply_audio_effects(Clip* c, double timecode_start, AVFrame* frame, int nb_ } } } - if (c->get_closing_transition() != NULL) { - if (c->media != NULL && c->media->get_type() == MEDIA_TYPE_FOOTAGE) { + if (c->get_closing_transition() != nullptr) { + if (c->media != nullptr && c->media->get_type() == MEDIA_TYPE_FOOTAGE) { long length_with_transitions = c->get_timeline_out_with_transition() - c->get_timeline_in_with_transition(); double transition_start = (c->get_clip_in_with_transition() + length_with_transitions - c->get_closing_transition()->get_length()) / c->sequence->frame_rate; double transition_end = (c->get_clip_in_with_transition() + length_with_transitions) / c->sequence->frame_rate; @@ -117,7 +117,7 @@ void cache_audio_worker(Clip* c, bool scrubbing, QVector& nests) { AVFrame* frame; int nb_bytes = INT_MAX; - if (c->media == NULL) { + if (c->media == nullptr) { frame = c->frame; nb_bytes = frame->nb_samples * av_get_bytes_per_sample(static_cast(frame->format)) * frame->channels; while ((c->frame_sample_index == -1 || c->frame_sample_index >= nb_bytes) && nb_bytes > 0) { @@ -390,7 +390,7 @@ void cache_audio_worker(Clip* c, bool scrubbing, QVector& nests) { audio_write_lock.unlock(); if (scrubbing) { - if (audio_thread != NULL) audio_thread->notifyReceiver(); + if (audio_thread != nullptr) audio_thread->notifyReceiver(); } if (c->frame_sample_index == nb_bytes) { @@ -541,7 +541,7 @@ void cache_video_worker(Clip* c, long playhead) { void reset_cache(Clip* c, long target_frame) { // if we seek to a whole other place in the timeline, we'll need to reset the cache with new values - if (c->media == NULL) { + if (c->media == nullptr) { if (c->track >= 0) { // tone clip c->reached_end = false; @@ -625,7 +625,7 @@ Cacher::Cacher(Clip* c) : clip(c) {} AVSampleFormat sample_format = AV_SAMPLE_FMT_S16; void open_clip_worker(Clip* clip) { - if (clip->media == NULL) { + if (clip->media == nullptr) { if (clip->track >= 0) { clip->frame = av_frame_alloc(); clip->frame->format = sample_format; @@ -649,8 +649,8 @@ void open_clip_worker(Clip* clip) { int errCode = avformat_open_input( &clip->formatCtx, filename, - NULL, - NULL + nullptr, + nullptr ); if (errCode != 0) { char err[1024]; @@ -659,7 +659,7 @@ void open_clip_worker(Clip* clip) { return; } - errCode = avformat_find_stream_info(clip->formatCtx, NULL); + errCode = avformat_find_stream_info(clip->formatCtx, nullptr); if (errCode < 0) { char err[1024]; av_strerror(errCode, err, 1024); @@ -692,7 +692,7 @@ void open_clip_worker(Clip* clip) { if (ms->video_interlacing != VIDEO_PROGRESSIVE) clip->max_queue_size *= 2; - clip->opts = NULL; + clip->opts = nullptr; // optimized decoding settings if ((clip->stream->codecpar->codec_id != AV_CODEC_ID_PNG && @@ -714,7 +714,7 @@ void open_clip_worker(Clip* clip) { // allocate filtergraph clip->filter_graph = avfilter_graph_alloc(); - if (clip->filter_graph == NULL) { + if (clip->filter_graph == nullptr) { qCritical() << "Could not create filtergraph"; } char filter_args[512]; @@ -730,8 +730,8 @@ void open_clip_worker(Clip* clip) { clip->stream->codecpar->sample_aspect_ratio.den ); - avfilter_graph_create_filter(&clip->buffersrc_ctx, avfilter_get_by_name("buffer"), "in", filter_args, NULL, clip->filter_graph); - avfilter_graph_create_filter(&clip->buffersink_ctx, avfilter_get_by_name("buffersink"), "out", NULL, NULL, clip->filter_graph); + avfilter_graph_create_filter(&clip->buffersrc_ctx, avfilter_get_by_name("buffer"), "in", filter_args, nullptr, clip->filter_graph); + avfilter_graph_create_filter(&clip->buffersink_ctx, avfilter_get_by_name("buffersink"), "out", nullptr, nullptr, clip->filter_graph); AVFilterContext* last_filter = clip->buffersrc_ctx; @@ -739,7 +739,7 @@ void open_clip_worker(Clip* clip) { AVFilterContext* yadif_filter; char yadif_args[100]; snprintf(yadif_args, sizeof(yadif_args), "mode=3:parity=%d", ((ms->video_interlacing == VIDEO_TOP_FIELD_FIRST) ? 0 : 1)); // there's a CUDA version if we start using nvdec/nvenc - avfilter_graph_create_filter(&yadif_filter, avfilter_get_by_name("yadif"), "yadif", yadif_args, NULL, clip->filter_graph); + avfilter_graph_create_filter(&yadif_filter, avfilter_get_by_name("yadif"), "yadif", yadif_args, nullptr, clip->filter_graph); avfilter_link(last_filter, 0, yadif_filter, 0); last_filter = yadif_filter; @@ -749,7 +749,7 @@ void open_clip_worker(Clip* clip) { bool stabilize = false; if (stabilize) { AVFilterContext* stab_filter; - int stab_ret = avfilter_graph_create_filter(&stab_filter, avfilter_get_by_name("vidstabtransform"), "vidstab", "input=/media/matt/Home/samples/transforms.trf", NULL, clip->filter_graph); + int stab_ret = avfilter_graph_create_filter(&stab_filter, avfilter_get_by_name("vidstabtransform"), "vidstab", "input=/media/matt/Home/samples/transforms.trf", nullptr, clip->filter_graph); if (stab_ret < 0) { char err[100]; av_strerror(stab_ret, err, sizeof(err)); @@ -765,18 +765,18 @@ void open_clip_worker(Clip* clip) { AV_PIX_FMT_NONE }; - clip->pix_fmt = avcodec_find_best_pix_fmt_of_list(valid_pix_fmts, static_cast(clip->stream->codecpar->format), 1, NULL); + clip->pix_fmt = avcodec_find_best_pix_fmt_of_list(valid_pix_fmts, static_cast(clip->stream->codecpar->format), 1, nullptr); const char* chosen_format = av_get_pix_fmt_name(static_cast(clip->pix_fmt)); char format_args[100]; snprintf(format_args, sizeof(format_args), "pix_fmts=%s", chosen_format); AVFilterContext* format_conv; - avfilter_graph_create_filter(&format_conv, avfilter_get_by_name("format"), "fmt", format_args, NULL, clip->filter_graph); + avfilter_graph_create_filter(&format_conv, avfilter_get_by_name("format"), "fmt", format_args, nullptr, clip->filter_graph); avfilter_link(last_filter, 0, format_conv, 0); avfilter_link(format_conv, 0, clip->buffersink_ctx, 0); - avfilter_graph_config(clip->filter_graph, NULL); + avfilter_graph_config(clip->filter_graph, nullptr); } else if (clip->stream->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) { if (clip->codecCtx->channel_layout == 0) clip->codecCtx->channel_layout = av_get_default_channel_layout(clip->stream->codecpar->channels); @@ -802,8 +802,8 @@ void open_clip_worker(Clip* clip) { clip->codecCtx->channel_layout ); - avfilter_graph_create_filter(&clip->buffersrc_ctx, avfilter_get_by_name("abuffer"), "in", filter_args, NULL, clip->filter_graph); - avfilter_graph_create_filter(&clip->buffersink_ctx, avfilter_get_by_name("abuffersink"), "out", NULL, NULL, clip->filter_graph); + avfilter_graph_create_filter(&clip->buffersrc_ctx, avfilter_get_by_name("abuffer"), "in", filter_args, nullptr, clip->filter_graph); + avfilter_graph_create_filter(&clip->buffersink_ctx, avfilter_get_by_name("abuffersink"), "out", nullptr, nullptr, clip->filter_graph); enum AVSampleFormat sample_fmts[] = { sample_format, static_cast(-1) }; if (av_opt_set_int_list(clip->buffersink_ctx, "sample_fmts", sample_fmts, -1, AV_OPT_SEARCH_CHILDREN) < 0) { @@ -837,16 +837,16 @@ void open_clip_worker(Clip* clip) { if (whole2 > 0) { snprintf(speed_param, sizeof(speed_param), "%f", base); for (int i=0;ifilter_graph); + AVFilterContext* tempo_filter = nullptr; + avfilter_graph_create_filter(&tempo_filter, avfilter_get_by_name("atempo"), "atempo", speed_param, nullptr, clip->filter_graph); avfilter_link(previous_filter, 0, tempo_filter, 0); previous_filter = tempo_filter; } } snprintf(speed_param, sizeof(speed_param), "%f", qPow(base, speedlog)); - last_filter = NULL; - avfilter_graph_create_filter(&last_filter, avfilter_get_by_name("atempo"), "atempo", speed_param, NULL, clip->filter_graph); + last_filter = nullptr; + avfilter_graph_create_filter(&last_filter, avfilter_get_by_name("atempo"), "atempo", speed_param, nullptr, clip->filter_graph); avfilter_link(previous_filter, 0, last_filter, 0); // } @@ -861,7 +861,7 @@ void open_clip_worker(Clip* clip) { qCritical() << "Could not set output sample rates"; } - avfilter_graph_config(clip->filter_graph, NULL); + avfilter_graph_config(clip->filter_graph, nullptr); clip->audio_reset = true; } @@ -885,7 +885,7 @@ void cache_clip_worker(Clip* clip, long playhead, bool reset, bool scrubbing, QV clip->audio_reset = false; } - if (clip->media == NULL) { + if (clip->media == nullptr) { if (clip->track >= 0) { cache_audio_worker(clip, scrubbing, nests); } @@ -901,7 +901,7 @@ void cache_clip_worker(Clip* clip, long playhead, bool reset, bool scrubbing, QV void close_clip_worker(Clip* clip) { clip->finished_opening = false; - if (clip->media != NULL && clip->media->get_type() == MEDIA_TYPE_FOOTAGE) { + if (clip->media != nullptr && clip->media->get_type() == MEDIA_TYPE_FOOTAGE) { clip->queue_clear(); avfilter_graph_free(&clip->filter_graph); diff --git a/playback/playback.cpp b/playback/playback.cpp index d6faaa28f..8a30a9c6d 100644 --- a/playback/playback.cpp +++ b/playback/playback.cpp @@ -37,7 +37,7 @@ bool texture_failed = false; bool rendering = false; bool clip_uses_cacher(Clip* clip) { - return (clip->media == NULL && clip->track >= 0) || (clip->media != NULL && clip->media->get_type() == MEDIA_TYPE_FOOTAGE); + return (clip->media == nullptr && clip->track >= 0) || (clip->media != nullptr && clip->media->get_type() == MEDIA_TYPE_FOOTAGE); } void open_clip(Clip* clip, bool multithreaded) { @@ -63,20 +63,20 @@ void open_clip(Clip* clip, bool multithreaded) { void close_clip(Clip* clip, bool wait) { // destroy opengl texture in main thread - if (clip->texture != NULL) { + if (clip->texture != nullptr) { delete clip->texture; - clip->texture = NULL; + clip->texture = nullptr; } for (int i=0;ieffects.size();i++) { if (clip->effects.at(i)->is_open()) clip->effects.at(i)->close(); } - if (clip->fbo != NULL) { + if (clip->fbo != nullptr) { delete clip->fbo[0]; delete clip->fbo[1]; delete [] clip->fbo; - clip->fbo = NULL; + clip->fbo = nullptr; } if (clip_uses_cacher(clip)) { @@ -91,7 +91,7 @@ void close_clip(Clip* clip, bool wait) { close_clip_worker(clip); } } else { - if (clip->media != NULL && clip->media->get_type() == MEDIA_TYPE_SEQUENCE) + if (clip->media != nullptr && clip->media->get_type() == MEDIA_TYPE_SEQUENCE) closeActiveClips(clip->media->to_sequence()); clip->open = false; @@ -129,7 +129,7 @@ void get_clip_frame(Clip* c, long playhead) { second_pts *= 2; } - AVFrame* target_frame = NULL; + AVFrame* target_frame = nullptr; bool reset = false; bool cache = true; @@ -222,7 +222,7 @@ void get_clip_frame(Clip* c, long playhead) { #ifdef GCF_DEBUG dout << "GCF ==> RESET" << target_pts << "(" << target_frame->pts << "-" << target_frame->pts+target_frame->pkt_duration << ")"; #endif - if (!config.fast_seeking) target_frame = NULL; + if (!config.fast_seeking) target_frame = nullptr; reset = true; c->last_invalid_ts = target_pts; } else { @@ -231,7 +231,7 @@ void get_clip_frame(Clip* c, long playhead) { #endif if (c->queue.size() >= c->max_queue_size) c->queue_remove_earliest(); c->ignore_reverse = true; - target_frame = NULL; + target_frame = nullptr; } } } @@ -240,13 +240,13 @@ void get_clip_frame(Clip* c, long playhead) { reset = true; } - if (target_frame == NULL || reset) { + if (target_frame == nullptr || reset) { // reset cache texture_failed = true; qInfo() << "Frame queue couldn't keep up - either the user seeked or the system is overloaded (queue size:" << c->queue.size() << ")"; } - if (target_frame != NULL) { + if (target_frame != nullptr) { int nb_components = av_pix_fmt_desc_get(static_cast(c->pix_fmt))->nb_components; glPixelStorei(GL_UNPACK_ROW_LENGTH, target_frame->linesize[0]/nb_components); @@ -291,7 +291,7 @@ double playhead_to_clip_seconds(Clip* c, long playhead) { long clip_frame = playhead_to_clip_frame(c, playhead); if (c->reverse) clip_frame = c->getMaximumLength() - clip_frame - 1; double secs = ((double) clip_frame/c->sequence->frame_rate)*c->speed; - if (c->media != NULL && c->media->get_type() == MEDIA_TYPE_FOOTAGE) secs *= c->media->to_footage()->speed; + if (c->media != nullptr && c->media->get_type() == MEDIA_TYPE_FOOTAGE) secs *= c->media->to_footage()->speed; return secs; } @@ -330,7 +330,7 @@ int retrieve_next_frame(Clip* c, AVFrame* f) { } } else { if (read_ret == AVERROR_EOF) { - int send_ret = avcodec_send_packet(c->codecCtx, NULL); + int send_ret = avcodec_send_packet(c->codecCtx, nullptr); if (send_ret < 0) { qCritical() << "Failed to send packet to decoder." << send_ret; return send_ret; @@ -365,11 +365,11 @@ void set_sequence(Sequence* s) { } void closeActiveClips(Sequence *s) { - if (s != NULL) { + if (s != nullptr) { for (int i=0;iclips.size();i++) { Clip* c = s->clips.at(i); - if (c != NULL) { - if (c->media != NULL && c->media->get_type() == MEDIA_TYPE_SEQUENCE) { + if (c != nullptr) { + if (c->media != nullptr && c->media->get_type() == MEDIA_TYPE_SEQUENCE) { closeActiveClips(c->media->to_sequence()); if (c->open) close_clip(c, true); } else if (c->open) { diff --git a/project/clip.cpp b/project/clip.cpp index 05758928c..f57213b2f 100644 --- a/project/clip.cpp +++ b/project/clip.cpp @@ -25,7 +25,7 @@ Clip::Clip(Sequence* s) : timeline_in(0), timeline_out(0), track(0), - media(NULL), + media(nullptr), speed(1.0), reverse(false), maintain_audio_pitch(false), @@ -36,9 +36,9 @@ Clip::Clip(Sequence* s) : replaced(false), ignore_reverse(false), use_existing_frame(false), - filter_graph(NULL), - fbo(NULL), - opts(NULL) + filter_graph(nullptr), + fbo(nullptr), + opts(nullptr) { pkt = av_packet_alloc(); reset(); @@ -67,10 +67,10 @@ Clip* Clip::copy(Sequence* s) { copy->effects.append(effects.at(i)->copy(copy)); } - copy->cached_fr = (this->sequence == NULL) ? cached_fr : this->sequence->frame_rate; + copy->cached_fr = (this->sequence == nullptr) ? cached_fr : this->sequence->frame_rate; - if (get_opening_transition() != NULL && get_opening_transition()->secondary_clip == NULL) copy->opening_transition = get_opening_transition()->copy(copy, NULL); - if (get_closing_transition() != NULL && get_closing_transition()->secondary_clip == NULL) copy->closing_transition = get_closing_transition()->copy(copy, NULL); + if (get_opening_transition() != nullptr && get_opening_transition()->secondary_clip == nullptr) copy->opening_transition = get_opening_transition()->copy(copy, nullptr); + if (get_closing_transition() != nullptr && get_closing_transition()->secondary_clip == nullptr) copy->closing_transition = get_closing_transition()->copy(copy, nullptr); copy->recalculateMaxLength(); @@ -86,16 +86,16 @@ void Clip::reset() { frame_sample_index = -1; audio_buffer_write = false; texture_frame = -1; - formatCtx = NULL; - stream = NULL; - codec = NULL; - codecCtx = NULL; - texture = NULL; + formatCtx = nullptr; + stream = nullptr; + codec = nullptr; + codecCtx = nullptr; + texture = nullptr; last_invalid_ts = -1; } void Clip::reset_audio() { - if (media == NULL || media->get_type() == MEDIA_TYPE_FOOTAGE) { + if (media == nullptr || media->get_type() == MEDIA_TYPE_FOOTAGE) { audio_reset = true; frame_sample_index = -1; audio_buffer_write = 0; @@ -103,14 +103,14 @@ void Clip::reset_audio() { Sequence* nested_sequence = media->to_sequence(); for (int i=0;iclips.size();i++) { Clip* c = nested_sequence->clips.at(i); - if (c != NULL) c->reset_audio(); + if (c != nullptr) c->reset_audio(); } } } void Clip::refresh() { // validates media if it was replaced - if (replaced && media != NULL && media->get_type() == MEDIA_TYPE_FOOTAGE) { + if (replaced && media != nullptr && media->get_type() == MEDIA_TYPE_FOOTAGE) { Footage* m = media->to_footage(); if (track < 0 && m->video_tracks.size() > 0) { @@ -150,24 +150,24 @@ void Clip::queue_remove_earliest() { Transition* Clip::get_opening_transition() { if (opening_transition > -1) { - if (this->sequence == NULL) { + if (this->sequence == nullptr) { return clipboard_transitions.at(opening_transition); } else { return this->sequence->transitions.at(opening_transition); } } - return NULL; + return nullptr; } Transition* Clip::get_closing_transition() { if (closing_transition > -1) { - if (this->sequence == NULL) { + if (this->sequence == nullptr) { return clipboard_transitions.at(closing_transition); } else { return this->sequence->transitions.at(closing_transition); } } - return NULL; + return nullptr; } Clip::~Clip() { @@ -185,7 +185,7 @@ Clip::~Clip() { } long Clip::get_clip_in_with_transition() { - if (get_opening_transition() != NULL && get_opening_transition()->secondary_clip != NULL) { + if (get_opening_transition() != nullptr && get_opening_transition()->secondary_clip != nullptr) { // we must be the secondary clip, so return (timeline in - length) return clip_in - get_opening_transition()->get_true_length(); } @@ -193,7 +193,7 @@ long Clip::get_clip_in_with_transition() { } long Clip::get_timeline_in_with_transition() { - if (get_opening_transition() != NULL && get_opening_transition()->secondary_clip != NULL) { + if (get_opening_transition() != nullptr && get_opening_transition()->secondary_clip != nullptr) { // we must be the secondary clip, so return (timeline in - length) return timeline_in - get_opening_transition()->get_true_length(); } @@ -201,7 +201,7 @@ long Clip::get_timeline_in_with_transition() { } long Clip::get_timeline_out_with_transition() { - if (get_closing_transition() != NULL && get_closing_transition()->secondary_clip != NULL) { + if (get_closing_transition() != nullptr && get_closing_transition()->secondary_clip != nullptr) { // we must be the primary clip, so return (timeline out + length2) return timeline_out + get_closing_transition()->get_true_length(); } else { @@ -216,29 +216,29 @@ long Clip::getLength() { double Clip::getMediaFrameRate() { Q_ASSERT(track < 0); - if (media != NULL) { + if (media != nullptr) { double rate = media->get_frame_rate(media_stream); if (!qIsNaN(rate)) return rate; } - if (sequence != NULL) return sequence->frame_rate; + if (sequence != nullptr) return sequence->frame_rate; return qSNaN(); } void Clip::recalculateMaxLength() { - if (sequence != NULL) { + if (sequence != nullptr) { double fr = this->sequence->frame_rate; fr /= speed; calculated_length = LONG_MAX; - if (media != NULL) { + if (media != nullptr) { switch (media->get_type()) { case MEDIA_TYPE_FOOTAGE: { Footage* m = media->to_footage(); const FootageStream* ms = m->get_stream_from_file_index(track < 0, media_stream); - if (ms != NULL && ms->infinite_length) { + if (ms != nullptr && ms->infinite_length) { calculated_length = LONG_MAX; } else { calculated_length = m->get_length_in_frames(fr); @@ -261,13 +261,13 @@ long Clip::getMaximumLength() { } int Clip::getWidth() { - if (media == NULL && sequence != NULL) return sequence->width; + if (media == nullptr && sequence != nullptr) return sequence->width; switch (media->get_type()) { case MEDIA_TYPE_FOOTAGE: { const FootageStream* ms = media->to_footage()->get_stream_from_file_index(track < 0, media_stream); - if (ms != NULL) return ms->video_width; - if (sequence != NULL) return sequence->width; + if (ms != nullptr) return ms->video_width; + if (sequence != nullptr) return sequence->width; } case MEDIA_TYPE_SEQUENCE: { @@ -279,13 +279,13 @@ int Clip::getWidth() { } int Clip::getHeight() { - if (media == NULL && sequence != NULL) return sequence->height; + if (media == nullptr && sequence != nullptr) return sequence->height; switch (media->get_type()) { case MEDIA_TYPE_FOOTAGE: { const FootageStream* ms = media->to_footage()->get_stream_from_file_index(track < 0, media_stream); - if (ms != NULL) return ms->video_height; - if (sequence != NULL) return sequence->height; + if (ms != nullptr) return ms->video_height; + if (sequence != nullptr) return sequence->height; } case MEDIA_TYPE_SEQUENCE: { diff --git a/project/effect.cpp b/project/effect.cpp index 14400133e..c28f20a53 100644 --- a/project/effect.cpp +++ b/project/effect.cpp @@ -73,7 +73,7 @@ Effect* create_effect(Clip* c, const EffectMeta* em) { qCritical() << "Invalid effect data"; QMessageBox::critical(mainWindow, "Invalid effect", "No candidate for effect '" + em->name + "'. This effect may be corrupt. Try reinstalling it or Olive."); } - return NULL; + return nullptr; } const EffectMeta* get_internal_meta(int internal_id, int type) { @@ -82,11 +82,11 @@ const EffectMeta* get_internal_meta(int internal_id, int type) { return &effects.at(i); } } - return NULL; + return nullptr; } void load_internal_effects() { - qWarning() << "Shaders are disabled, some effects may be nonfunctional"; + qWarning() << "Shaders are disabled, some effects may be nonfunctional"; EffectMeta em; @@ -266,8 +266,8 @@ Effect::Effect(Clip* c, const EffectMeta *em) : enable_coords(false), enable_superimpose(false), enable_image(false), - glslProgram(NULL), - texture(NULL), + glslProgram(nullptr), + texture(nullptr), isOpen(false), bound(false), enable_always_update(false) @@ -283,7 +283,7 @@ Effect::Effect(Clip* c, const EffectMeta *em) : connect(container->title_bar, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(show_context_menu(const QPoint&))); - if (em != NULL) { + if (em != nullptr) { // set up UI from effect file container->setText(em->name); @@ -504,7 +504,7 @@ void Effect::copy_field_keyframes(Effect* e) { } EffectRow* Effect::add_row(const QString& name, bool savable, bool keyframable) { - EffectRow* row = new EffectRow(this, savable, ui_layout, name, rows.size()); + EffectRow* row = new EffectRow(this, savable, ui_layout, name, rows.size(), keyframable); rows.append(row); return row; } @@ -590,7 +590,7 @@ void Effect::move_down() { } int Effect::get_index_in_clip() { - if (parent_clip != NULL) { + if (parent_clip != nullptr) { for (int i=0;ieffects.size();i++) { if (parent_clip->effects.at(i) == this) { return i; @@ -729,7 +729,7 @@ void Effect::load(QXmlStreamReader& stream) { } } -void Effect::custom_load(QXmlStreamReader &stream) {} +void Effect::custom_load(QXmlStreamReader &) {} void Effect::save(QXmlStreamWriter& stream) { stream.writeAttribute("name", meta->name); @@ -788,9 +788,9 @@ void Effect::open() { if (isOpen) { qWarning() << "Tried to open an effect that was already open"; close(); - } - if (shaders_are_enabled && enable_shader) { - if (QOpenGLContext::currentContext() == NULL) { + } + if (shaders_are_enabled && enable_shader) { + if (QOpenGLContext::currentContext() == nullptr) { qWarning() << "No current context to create a shader program for - will retry next repaint"; } else { glslProgram = new QOpenGLShaderProgram(); @@ -835,15 +835,15 @@ void Effect::close() { qWarning() << "Tried to close an effect that was already closed"; } delete_texture(); - if (glslProgram != NULL) { + if (glslProgram != nullptr) { delete glslProgram; - glslProgram = NULL; + glslProgram = nullptr; } isOpen = false; } bool Effect::is_glsl_linked() { - return glslProgram != NULL && glslProgram->isLinked(); + return glslProgram != nullptr && glslProgram->isLinked(); } void Effect::startEffect() { @@ -851,11 +851,11 @@ void Effect::startEffect() { open(); qWarning() << "Tried to start a closed effect - opening"; } - if (shaders_are_enabled - && enable_shader - && glslProgram->isLinked()) { - bound = glslProgram->bind(); - } + if (shaders_are_enabled + && enable_shader + && glslProgram->isLinked()) { + bound = glslProgram->bind(); + } } void Effect::endEffect() { @@ -903,7 +903,7 @@ void Effect::process_shader(double timecode, GLTextureCoords&) { } } -void Effect::process_coords(double, GLTextureCoords&, int data) {} +void Effect::process_coords(double, GLTextureCoords&, int) {} GLuint Effect::process_superimpose(double timecode) { bool recreate_texture = false; @@ -919,7 +919,7 @@ GLuint Effect::process_superimpose(double timecode) { redraw(timecode); } - if (texture != NULL) { + if (texture != nullptr) { if (recreate_texture || texture->width() != img.width() || texture->height() != img.height()) { delete_texture(); texture = new QOpenGLTexture(QOpenGLTexture::Target2D); @@ -939,21 +939,21 @@ void Effect::gizmo_draw(double, GLTextureCoords &) {} void Effect::gizmo_move(EffectGizmo* gizmo, int x_movement, int y_movement, double timecode, bool done) { for (int i=0;ix_field1 != NULL) { + if (gizmo->x_field1 != nullptr) { gizmo->x_field1->set_double_value(gizmo->x_field1->get_double_value(timecode) + x_movement*gizmo->x_field_multi1); gizmo->x_field1->make_key_from_change(ca); } - if (gizmo->y_field1 != NULL) { + if (gizmo->y_field1 != nullptr) { gizmo->y_field1->set_double_value(gizmo->y_field1->get_double_value(timecode) + y_movement*gizmo->y_field_multi1); gizmo->y_field1->make_key_from_change(ca); } - if (gizmo->x_field2 != NULL) { + if (gizmo->x_field2 != nullptr) { gizmo->x_field2->set_double_value(gizmo->x_field2->get_double_value(timecode) + x_movement*gizmo->x_field_multi2); gizmo->x_field2->make_key_from_change(ca); } - if (gizmo->y_field2 != NULL) { + if (gizmo->y_field2 != nullptr) { gizmo->y_field2->set_double_value(gizmo->y_field2->get_double_value(timecode) + y_movement*gizmo->y_field_multi2); gizmo->y_field2->make_key_from_change(ca); } @@ -1063,9 +1063,9 @@ bool Effect::valueHasChanged(double timecode) { } void Effect::delete_texture() { - if (texture != NULL) { + if (texture != nullptr) { delete texture; - texture = NULL; + texture = nullptr; } } diff --git a/project/effectfield.cpp b/project/effectfield.cpp index f6626dc91..4f3ec79be 100644 --- a/project/effectfield.cpp +++ b/project/effectfield.cpp @@ -270,7 +270,7 @@ QVariant EffectField::validate_keyframe_data(double timecode, bool async) { void EffectField::ui_element_change() { bool dragging_double = (type == EFFECT_FIELD_DOUBLE && static_cast(ui_element)->is_dragging()); - ComboAction* ca = NULL; + ComboAction* ca = nullptr; if (!dragging_double) ca = new ComboAction(); make_key_from_change(ca); if (!dragging_double) undo_stack.push(ca); @@ -280,7 +280,7 @@ void EffectField::ui_element_change() { void EffectField::make_key_from_change(ComboAction* ca) { if (parent_row->isKeyframing()) { parent_row->set_keyframe_now(ca); - } else if (ca != NULL) { + } else if (ca != nullptr) { // set undo ca->append(new EffectFieldUndo(this)); } diff --git a/project/effectgizmo.cpp b/project/effectgizmo.cpp index 65bf0cc31..8b21eb771 100644 --- a/project/effectgizmo.cpp +++ b/project/effectgizmo.cpp @@ -4,13 +4,13 @@ #include "effectfield.h" EffectGizmo::EffectGizmo(int type) : - x_field1(NULL), + x_field1(nullptr), x_field_multi1(1.0), - y_field1(NULL), + y_field1(nullptr), y_field_multi1(1.0), - x_field2(NULL), + x_field2(nullptr), x_field_multi2(1.0), - y_field2(NULL), + y_field2(nullptr), y_field_multi2(1.0), type(type), cursor(-1) @@ -23,10 +23,10 @@ EffectGizmo::EffectGizmo(int type) : } void EffectGizmo::set_previous_value() { - if (x_field1 != NULL) static_cast(x_field1->ui_element)->set_previous_value(); - if (y_field1 != NULL) static_cast(y_field1->ui_element)->set_previous_value(); - if (x_field2 != NULL) static_cast(x_field2->ui_element)->set_previous_value(); - if (y_field2 != NULL) static_cast(y_field2->ui_element)->set_previous_value(); + if (x_field1 != nullptr) static_cast(x_field1->ui_element)->set_previous_value(); + if (y_field1 != nullptr) static_cast(y_field1->ui_element)->set_previous_value(); + if (x_field2 != nullptr) static_cast(x_field2->ui_element)->set_previous_value(); + if (y_field2 != nullptr) static_cast(y_field2->ui_element)->set_previous_value(); } int EffectGizmo::get_point_count() { diff --git a/project/effectrow.cpp b/project/effectrow.cpp index 4735e8def..5b4d4acac 100644 --- a/project/effectrow.cpp +++ b/project/effectrow.cpp @@ -31,7 +31,7 @@ EffectRow::EffectRow(Effect *parent, bool save, QGridLayout *uilayout, const QSt column_count = 1; - if (parent_effect->meta != NULL + if (parent_effect->meta != nullptr && parent_effect->meta->type != EFFECT_TYPE_TRANSITION && keyframable) { connect(label, SIGNAL(clicked()), this, SLOT(focus_row())); @@ -209,7 +209,7 @@ void EffectRow::set_keyframe_now(ComboAction* ca) { field(i)->keyframes[unsafe_keys.at(i)].data = field(i)->get_current_data(); } - if (ca != NULL) { + if (ca != nullptr) { for (int i=0;iappend(new KeyframeFieldSet(field(i), unsafe_keys.at(i))); ca->append(new SetQVariant(&field(i)->keyframes[unsafe_keys.at(i)].data, unsafe_old_data.at(i), field(i)->get_current_data())); @@ -225,7 +225,7 @@ void EffectRow::set_keyframe_now(ComboAction* ca) { - /*if (ca != NULL) { + /*if (ca != nullptr) { just_made_unsafe_keyframe = false; } else { if (!just_made_unsafe_keyframe) { @@ -248,7 +248,7 @@ void EffectRow::set_keyframe_now(ComboAction* ca) { KeyframeSet* ks = new KeyframeSet(this, index, time, just_made_unsafe_keyframe); - if (ca != NULL) { + if (ca != nullptr) { just_made_unsafe_keyframe = false; ca->append(ks); } else { diff --git a/project/footage.cpp b/project/footage.cpp index e63d343f2..2f3651017 100644 --- a/project/footage.cpp +++ b/project/footage.cpp @@ -11,7 +11,7 @@ extern "C" { #include "project/clip.h" -Footage::Footage() : ready(false), preview_gen(NULL), invalid(false), in(0), out(0), speed(1.0) { +Footage::Footage() : ready(false), preview_gen(nullptr), invalid(false), in(0), out(0), speed(1.0) { ready_lock.lock(); } @@ -20,7 +20,7 @@ Footage::~Footage() { } void Footage::reset() { - if (preview_gen != NULL) { + if (preview_gen != nullptr) { preview_gen->cancel(); preview_gen->wait(); } @@ -48,7 +48,7 @@ FootageStream* Footage::get_stream_from_file_index(bool video, int index) { } } } - return NULL; + return nullptr; } void FootageStream::make_square_thumb() { diff --git a/project/media.cpp b/project/media.cpp index 1ecb0cc8b..69d25f6f4 100644 --- a/project/media.cpp +++ b/project/media.cpp @@ -28,9 +28,9 @@ QString get_interlacing_name(int interlacing) { QString get_channel_layout_name(int channels, uint64_t layout) { switch (channels) { - case 0: return "Invalid"; break; - case 1: return "Mono"; break; - case 2: return "Stereo"; break; + case 0: return "Invalid"; + case 1: return "Mono"; + case 2: return "Stereo"; default: { char buf[50]; av_get_channel_layout_string(buf, sizeof(buf), channels, layout); @@ -41,7 +41,7 @@ QString get_channel_layout_name(int channels, uint64_t layout) { Media::Media(Media* iparent) : parent(iparent), - throbber(NULL), + throbber(nullptr), root(false), type(-1) {} @@ -49,9 +49,9 @@ Media::Media(Media* iparent) : Media::~Media() { switch (get_type()) { case MEDIA_TYPE_FOOTAGE: delete to_footage(); break; - case MEDIA_TYPE_SEQUENCE: if (object != NULL) delete to_sequence(); break; + case MEDIA_TYPE_SEQUENCE: if (object != nullptr) delete to_sequence(); break; } - if (throbber != NULL) delete throbber; + if (throbber != nullptr) delete throbber; qDeleteAll(children); } @@ -72,14 +72,14 @@ void Media::set_sequence(Sequence *s) { set_icon(QIcon(":/icons/sequence.png")); type = MEDIA_TYPE_SEQUENCE; object = s; - if (s != NULL) update_tooltip(); + if (s != nullptr) update_tooltip(); } void Media::set_folder() { if (folder_name.isEmpty()) folder_name = "New Folder"; set_icon(QIcon(":/icons/folder.png")); type = MEDIA_TYPE_FOLDER; - object = NULL; + object = nullptr; } void Media::set_icon(const QIcon &ico) { @@ -207,7 +207,7 @@ double Media::get_frame_rate(int stream) { } case MEDIA_TYPE_SEQUENCE: return to_sequence()->frame_rate; } - return NULL; + return 0; } int Media::get_sampling_rate(int stream) { diff --git a/project/projectmodel.cpp b/project/projectmodel.cpp index 4105e5a54..acec09122 100644 --- a/project/projectmodel.cpp +++ b/project/projectmodel.cpp @@ -6,7 +6,7 @@ #include "project/media.h" #include "debug.h" -ProjectModel::ProjectModel(QObject *parent) : QAbstractItemModel(parent), root_item(NULL) { +ProjectModel::ProjectModel(QObject *parent) : QAbstractItemModel(parent), root_item(nullptr) { root_item = new Media(0); root_item->root = true; } @@ -16,10 +16,10 @@ ProjectModel::~ProjectModel() { } void ProjectModel::destroy_root() { - if (panel_sequence_viewer != NULL) panel_sequence_viewer->viewer_widget->delete_function(); - if (panel_footage_viewer != NULL) panel_footage_viewer->viewer_widget->delete_function(); + if (panel_sequence_viewer != nullptr) panel_sequence_viewer->viewer_widget->delete_function(); + if (panel_footage_viewer != nullptr) panel_footage_viewer->viewer_widget->delete_function(); - if (root_item != NULL) { + if (root_item != nullptr) { delete root_item; } } @@ -143,14 +143,14 @@ void ProjectModel::set_icon(Media* m, const QIcon &ico) { } void ProjectModel::appendChild(Media *parent, Media *child) { - if (parent == NULL) parent = root_item; + if (parent == nullptr) parent = root_item; beginInsertRows(parent == root_item ? QModelIndex() : createIndex(parent->row(), 0, parent), parent->childCount(), parent->childCount()); parent->appendChild(child); endInsertRows(); } void ProjectModel::moveChild(Media *child, Media *to) { - if (to == NULL) to = root_item; + if (to == nullptr) to = root_item; Media* from = child->parentItem(); beginMoveRows( from == root_item ? QModelIndex() : createIndex(from->row(), 0, from), @@ -165,18 +165,18 @@ void ProjectModel::moveChild(Media *child, Media *to) { } void ProjectModel::removeChild(Media* parent, Media* m) { - if (parent == NULL) parent = root_item; + if (parent == nullptr) parent = root_item; beginRemoveRows(parent == root_item ? QModelIndex() : createIndex(parent->row(), 0, parent), m->row(), m->row()); parent->removeChild(m->row()); endRemoveRows(); } Media* ProjectModel::child(int i, Media* parent) { - if (parent == NULL) parent = root_item; + if (parent == nullptr) parent = root_item; return parent->child(i); } int ProjectModel::childCount(Media *parent) { - if (parent == NULL) parent = root_item; + if (parent == nullptr) parent = root_item; return parent->childCount(); } diff --git a/project/projectmodel.h b/project/projectmodel.h index b37836f6b..03ea9eadb 100644 --- a/project/projectmodel.h +++ b/project/projectmodel.h @@ -31,8 +31,8 @@ public: void appendChild(Media* parent, Media* child); void moveChild(Media *child, Media *to); void removeChild(Media *parent, Media* m); - Media *child(int i, Media* parent = NULL); - int childCount(Media* parent = NULL); + Media *child(int i, Media* parent = nullptr); + int childCount(Media* parent = nullptr); void set_icon(Media* m, const QIcon &ico); private: diff --git a/project/sequence.cpp b/project/sequence.cpp index 1a902966d..c0380ad17 100644 --- a/project/sequence.cpp +++ b/project/sequence.cpp @@ -33,8 +33,8 @@ Sequence* Sequence::copy() { s->clips.resize(clips.size()); for (int i=0;iclips[i] = NULL; + if (c == nullptr) { + s->clips[i] = nullptr; } else { Clip* copy = c->copy(s); copy->linked = c->linked; @@ -48,7 +48,7 @@ long Sequence::getEndFrame() { long end = 0; for (int j=0;jtimeline_out > end) { + if (c != nullptr && c->timeline_out > end) { end = c->timeline_out; } } @@ -61,10 +61,10 @@ void Sequence::hard_delete_transition(Clip *c, int type) { bool del = true; Transition* t = transitions.at(transition_index); - if (t->secondary_clip != NULL) { + if (t->secondary_clip != nullptr) { for (int i=0;iopening_transition == transition_index || c->closing_transition == transition_index)) { @@ -74,14 +74,14 @@ void Sequence::hard_delete_transition(Clip *c, int type) { } del = false; - t->secondary_clip = NULL; + t->secondary_clip = nullptr; } } } if (del) { delete transitions.at(transition_index); - transitions[transition_index] = NULL; + transitions[transition_index] = nullptr; } if (type == TA_OPENING_TRANSITION) { @@ -97,7 +97,7 @@ void Sequence::getTrackLimits(int* video_tracks, int* audio_tracks) { int at = 0; for (int j=0;jtrack < 0 && c->track < vt) { // video clip vt = c->track; } else if (c->track > at) { @@ -105,9 +105,9 @@ void Sequence::getTrackLimits(int* video_tracks, int* audio_tracks) { } } } - if (video_tracks != NULL) *video_tracks = vt; - if (audio_tracks != NULL) *audio_tracks = at; + if (video_tracks != nullptr) *video_tracks = vt; + if (audio_tracks != nullptr) *audio_tracks = at; } // static variable for the currently active sequence -Sequence* sequence = NULL; +Sequence* sequence = nullptr; diff --git a/project/sourcescommon.cpp b/project/sourcescommon.cpp index 04d6dc781..eea4a1ee7 100644 --- a/project/sourcescommon.cpp +++ b/project/sourcescommon.cpp @@ -18,8 +18,8 @@ #include SourcesCommon::SourcesCommon(Project* parent) : - project_parent(parent), - editing_item(NULL) + editing_item(nullptr), + project_parent(parent) { rename_timer.setInterval(1000); connect(&rename_timer, SIGNAL(timeout()), this, SLOT(rename_interval())); @@ -39,7 +39,7 @@ void SourcesCommon::create_seq_from_selected() { panel_timeline->create_ghosts_from_media(s, 0, media_list); panel_timeline->add_clips_from_ghosts(ca, s); - project_parent->new_sequence(ca, s, true, NULL); + project_parent->new_sequence(ca, s, true, nullptr); undo_stack.push(ca); } } @@ -148,7 +148,7 @@ void SourcesCommon::item_click(Media *m, const QModelIndex& index) { } } -void SourcesCommon::mouseDoubleClickEvent(QMouseEvent *e, const QModelIndexList& selected_items) { +void SourcesCommon::mouseDoubleClickEvent(QMouseEvent *, const QModelIndexList& selected_items) { stop_rename_timer(); if (selected_items.size() == 0) { project_parent->import_dialog(); @@ -196,7 +196,7 @@ void SourcesCommon::dropEvent(QWidget* parent, QDropEvent *event, const QModelIn parent = drop_item.parent(); } } - project_parent->process_file_list(paths, false, NULL, panel_project->item_to_media(parent)); + project_parent->process_file_list(paths, false, nullptr, panel_project->item_to_media(parent)); } } event->acceptProposedAction(); @@ -271,7 +271,7 @@ void SourcesCommon::stop_rename_timer() { void SourcesCommon::rename_interval() { stop_rename_timer(); - if (view->hasFocus() && editing_item != NULL) { + if (view->hasFocus() && editing_item != nullptr) { view->edit(editing_index); } } @@ -280,6 +280,6 @@ void SourcesCommon::item_renamed(Media* item) { if (editing_item == item) { MediaRename* mr = new MediaRename(item, "idk"); undo_stack.push(mr); - editing_item = NULL; + editing_item = nullptr; } } diff --git a/project/transition.cpp b/project/transition.cpp index 3badb5ca3..2c81dfcc6 100644 --- a/project/transition.cpp +++ b/project/transition.cpp @@ -31,7 +31,7 @@ Transition::Transition(Clip* c, Clip* s, const EffectMeta* em) : LabelSlider* length_ui_ele = static_cast(length_field->ui_element); length_ui_ele->set_display_type(LABELSLIDER_FRAMENUMBER); - length_ui_ele->set_frame_rate(parent_clip->sequence == NULL ? parent_clip->cached_fr : parent_clip->sequence->frame_rate); + length_ui_ele->set_frame_rate(parent_clip->sequence == nullptr ? parent_clip->cached_fr : parent_clip->sequence->frame_rate); } int Transition::copy(Clip *c, Clip* s) { @@ -48,7 +48,7 @@ long Transition::get_true_length() { } long Transition::get_length() { - if (secondary_clip != NULL) { + if (secondary_clip != nullptr) { return length * 2; } return length; @@ -76,14 +76,14 @@ Transition* get_transition_from_meta(Clip* c, Clip* s, const EffectMeta* em) { qCritical() << "Invalid transition data"; QMessageBox::critical(mainWindow, "Invalid transition", "No candidate for transition '" + em->name + "'. This transition may be corrupt. Try reinstalling it or Olive."); } - return NULL; + return nullptr; } int create_transition(Clip* c, Clip* s, const EffectMeta* em, long length) { Transition* t = get_transition_from_meta(c, s, em); - if (t != NULL) { + if (t != nullptr) { if (length >= 0) t->set_length(length); - QVector& transition_list = (c->sequence == NULL) ? clipboard_transitions : c->sequence->transitions; + QVector& transition_list = (c->sequence == nullptr) ? clipboard_transitions : c->sequence->transitions; transition_list.append(t); return transition_list.size() - 1; } diff --git a/project/undo.cpp b/project/undo.cpp index d8660a7b5..f37e13793 100644 --- a/project/undo.cpp +++ b/project/undo.cpp @@ -116,7 +116,7 @@ DeleteClipAction::DeleteClipAction(Sequence* s, int clip) : {} DeleteClipAction::~DeleteClipAction() { - if (ref != NULL) delete ref; + if (ref != nullptr) delete ref; } void DeleteClipAction::undo() { @@ -141,7 +141,7 @@ void DeleteClipAction::undo() { seq->clips.at(linkClipIndex.at(i))->linked.insert(linkLinkIndex.at(i), index); } - ref = NULL; + ref = nullptr; mainWindow->setWindowModified(old_project_changed); } @@ -152,18 +152,18 @@ void DeleteClipAction::redo() { if (ref->open) { close_clip(ref, true); } - seq->clips[index] = NULL; + seq->clips[index] = nullptr; // save shared transitions - if (ref->opening_transition > -1 && ref->get_opening_transition()->secondary_clip != NULL) { + if (ref->opening_transition > -1 && ref->get_opening_transition()->secondary_clip != nullptr) { opening_transition = ref->opening_transition; ref->get_opening_transition()->parent_clip = ref->get_opening_transition()->secondary_clip; - ref->get_opening_transition()->secondary_clip = NULL; + ref->get_opening_transition()->secondary_clip = nullptr; ref->opening_transition = -1; } - if (ref->closing_transition > -1 && ref->get_closing_transition()->secondary_clip != NULL) { + if (ref->closing_transition > -1 && ref->get_closing_transition()->secondary_clip != nullptr) { closing_transition = ref->closing_transition; - ref->get_closing_transition()->secondary_clip = NULL; + ref->get_closing_transition()->secondary_clip = nullptr; ref->closing_transition = -1; } @@ -172,7 +172,7 @@ void DeleteClipAction::redo() { linkLinkIndex.clear(); for (int i=0;iclips.size();i++) { Clip* c = seq->clips.at(i); - if (c != NULL) { + if (c != nullptr) { for (int j=0;jlinked.size();j++) { if (c->linked.at(j) == index) { linkClipIndex.append(i); @@ -256,7 +256,7 @@ AddEffectCommand::AddEffectCommand(Clip* c, Effect* e, const EffectMeta *m, int {} AddEffectCommand::~AddEffectCommand() { - if (!done && ref != NULL) delete ref; + if (!done && ref != nullptr) delete ref; } void AddEffectCommand::undo() { @@ -271,7 +271,7 @@ void AddEffectCommand::undo() { } void AddEffectCommand::redo() { - if (ref == NULL) { + if (ref == nullptr) { ref = create_effect(clip, meta); } if (pos < 0) { @@ -295,14 +295,14 @@ AddTransitionCommand::AddTransitionCommand(Clip* c, Clip *s, Transition* copy, c void AddTransitionCommand::undo() { clip->sequence->hard_delete_transition(clip, type); - if (secondary != NULL) secondary->sequence->hard_delete_transition(secondary, (type == TA_OPENING_TRANSITION) ? TA_CLOSING_TRANSITION : TA_OPENING_TRANSITION); + if (secondary != nullptr) secondary->sequence->hard_delete_transition(secondary, (type == TA_OPENING_TRANSITION) ? TA_CLOSING_TRANSITION : TA_OPENING_TRANSITION); if (type == TA_OPENING_TRANSITION) { clip->opening_transition = old_ptransition; - if (secondary != NULL) secondary->closing_transition = old_stransition; + if (secondary != nullptr) secondary->closing_transition = old_stransition; } else { clip->closing_transition = old_ptransition; - if (secondary != NULL) secondary->opening_transition = old_stransition; + if (secondary != nullptr) secondary->opening_transition = old_stransition; } mainWindow->setWindowModified(old_project_changed); @@ -311,8 +311,8 @@ void AddTransitionCommand::undo() { void AddTransitionCommand::redo() { if (type == TA_OPENING_TRANSITION) { old_ptransition = clip->opening_transition; - clip->opening_transition = (transition_to_copy == NULL) ? create_transition(clip, secondary, transition) : transition_to_copy->copy(clip, NULL); - if (secondary != NULL) { + clip->opening_transition = (transition_to_copy == nullptr) ? create_transition(clip, secondary, transition) : transition_to_copy->copy(clip, nullptr); + if (secondary != nullptr) { old_stransition = secondary->closing_transition; secondary->closing_transition = clip->opening_transition; } @@ -321,8 +321,8 @@ void AddTransitionCommand::redo() { } } else { old_ptransition = clip->closing_transition; - clip->closing_transition = (transition_to_copy == NULL) ? create_transition(clip, secondary, transition) : transition_to_copy->copy(clip, NULL); - if (secondary != NULL) { + clip->closing_transition = (transition_to_copy == nullptr) ? create_transition(clip, secondary, transition) : transition_to_copy->copy(clip, nullptr); + if (secondary != nullptr) { old_stransition = secondary->opening_transition; secondary->opening_transition = clip->closing_transition; } @@ -356,30 +356,30 @@ void ModifyTransitionCommand::redo() { DeleteTransitionCommand::DeleteTransitionCommand(Sequence* s, int transition_index) : seq(s), index(transition_index), - transition(NULL), - otc(NULL), - ctc(NULL), + transition(nullptr), + otc(nullptr), + ctc(nullptr), old_project_changed(mainWindow->isWindowModified()) {} DeleteTransitionCommand::~DeleteTransitionCommand() { - if (transition != NULL) delete transition; + if (transition != nullptr) delete transition; } void DeleteTransitionCommand::undo() { seq->transitions[index] = transition; - if (otc != NULL) otc->opening_transition = index; - if (ctc != NULL) ctc->closing_transition = index; + if (otc != nullptr) otc->opening_transition = index; + if (ctc != nullptr) ctc->closing_transition = index; - transition = NULL; + transition = nullptr; mainWindow->setWindowModified(old_project_changed); } void DeleteTransitionCommand::redo() { for (int i=0;iclips.size();i++) { Clip* c = seq->clips.at(i); - if (c != NULL) { + if (c != nullptr) { if (c->opening_transition == index) { otc = c; c->opening_transition = -1; @@ -392,7 +392,7 @@ void DeleteTransitionCommand::redo() { } transition = seq->transitions.at(index); - seq->transitions[index] = NULL; + seq->transitions[index] = nullptr; mainWindow->setWindowModified(true); } @@ -403,7 +403,7 @@ NewSequenceCommand::NewSequenceCommand(Media *s, Media* iparent) : done(false), old_project_changed(mainWindow->isWindowModified()) { - if (parent == NULL) parent = project_model.get_root(); + if (parent == nullptr) parent = project_model.get_root(); } NewSequenceCommand::~NewSequenceCommand() { @@ -518,8 +518,8 @@ void AddClipCommand::redo() { for (int j=0;jlinked.size();j++) { copy->linked[j] = original->linked.at(j) + linkOffset; } - if (original->opening_transition > -1) copy->opening_transition = original->get_opening_transition()->copy(copy, NULL); - if (original->closing_transition > -1) copy->closing_transition = original->get_closing_transition()->copy(copy, NULL); + if (original->opening_transition > -1) copy->opening_transition = original->get_opening_transition()->copy(copy, nullptr); + if (original->closing_transition > -1) copy->closing_transition = original->get_closing_transition()->copy(copy, nullptr); seq->clips.append(copy); } } @@ -591,7 +591,7 @@ void ReplaceMediaCommand::replace(QString& filename) { Sequence* s = all_sequences.at(i)->to_sequence(); for (int j=0;jclips.size();j++) { Clip* c = s->clips.at(j); - if (c != NULL && c->media == item && c->open) { + if (c != nullptr && c->media == item && c->open) { close_clip(c, true); c->replaced = true; } @@ -602,7 +602,7 @@ void ReplaceMediaCommand::replace(QString& filename) { QStringList files; files.append(filename); item->to_footage()->ready_lock.lock(); - panel_project->process_file_list(files, false, item, NULL); + panel_project->process_file_list(files, false, item, nullptr); } void ReplaceMediaCommand::undo() { @@ -713,7 +713,7 @@ void MediaMove::undo() { } void MediaMove::redo() { - if (to == NULL) to = project_model.get_root(); + if (to == nullptr) to = project_model.get_root(); froms.resize(items.size()); for (int i=0;iparentItem(); @@ -998,7 +998,7 @@ void EditSequenceCommand::update() { item->set_sequence(seq); for (int i=0;iclips.size();i++) { - if (seq->clips.at(i) != NULL) seq->clips.at(i)->refresh(); + if (seq->clips.at(i) != nullptr) seq->clips.at(i)->refresh(); } if (sequence == seq) { @@ -1157,7 +1157,7 @@ void RippleAction::redo() { for (int i=0;iclips.size();i++) { if (!ignore.contains(i)) { Clip* c = s->clips.at(i); - if (c != NULL) { + if (c != nullptr) { if (c->timeline_in >= point) { move_clip(ca, c, length, length, 0, 0, true, true); } @@ -1265,7 +1265,7 @@ void RefreshClips::redo() { Sequence* s = all_sequences.at(i)->to_sequence(); for (int j=0;jclips.size();j++) { Clip* c = s->clips.at(j); - if (c != NULL && c->media == media) { + if (c != nullptr && c->media == media) { c->replaced = true; c->refresh(); } diff --git a/ui/audiomonitor.cpp b/ui/audiomonitor.cpp index 5e136aada..12738aa4b 100644 --- a/ui/audiomonitor.cpp +++ b/ui/audiomonitor.cpp @@ -35,7 +35,7 @@ void AudioMonitor::resizeEvent(QResizeEvent *e) { } void AudioMonitor::paintEvent(QPaintEvent *) { - if (sequence != NULL) { + if (sequence != nullptr) { QPainter p(this); int channel_x = AUDIO_MONITOR_GAP; int channel_count = av_get_channel_layout_nb_channels(sequence->audio_layout); diff --git a/ui/collapsiblewidget.cpp b/ui/collapsiblewidget.cpp index fddebc040..57b90bbdd 100644 --- a/ui/collapsiblewidget.cpp +++ b/ui/collapsiblewidget.cpp @@ -44,7 +44,7 @@ CollapsibleWidget::CollapsibleWidget(QWidget* parent) : QWidget(parent) { set_button_icon(true); - contents = NULL; + contents = nullptr; } void CollapsibleWidget::header_click(bool s, bool deselect) { @@ -74,7 +74,7 @@ void CollapsibleWidget::set_button_icon(bool open) { } void CollapsibleWidget::setContents(QWidget* c) { - bool existing = (contents != NULL); + bool existing = (contents != nullptr); contents = c; if (!existing) { layout->addWidget(contents); diff --git a/ui/colorbutton.cpp b/ui/colorbutton.cpp index 026d1c42d..843478b39 100644 --- a/ui/colorbutton.cpp +++ b/ui/colorbutton.cpp @@ -31,7 +31,7 @@ void ColorButton::set_button_color() { } void ColorButton::open_dialog() { - QColor new_color = QColorDialog::getColor(color, NULL, "Set Color"); + QColor new_color = QColorDialog::getColor(color, nullptr, "Set Color"); if (new_color.isValid() && color != new_color) { set_color(new_color); set_button_color(); diff --git a/ui/graphview.cpp b/ui/graphview.cpp index fc1b82db0..36251f308 100644 --- a/ui/graphview.cpp +++ b/ui/graphview.cpp @@ -42,7 +42,7 @@ GraphView::GraphView(QWidget* parent) : y_scroll(0), mousedown(false), zoom(1.0), - row(NULL), + row(nullptr), moved_keys(false), current_handle(BEZIER_HANDLE_NONE), rect_select(false), @@ -59,14 +59,14 @@ void GraphView::show_context_menu(const QPoint& pos) { QMenu menu(this); QAction* zoom_to_selection = menu.addAction("Zoom to Selection"); - if (selected_keys.size() == 0 || row == NULL) { + if (selected_keys.size() == 0 || row == nullptr) { zoom_to_selection->setEnabled(false); } else { connect(zoom_to_selection, SIGNAL(triggered(bool)), this, SLOT(set_view_to_selection())); } QAction* zoom_to_all = menu.addAction("Zoom to Show All"); - if (row == NULL) { + if (row == nullptr) { zoom_to_all->setEnabled(false); } else { connect(zoom_to_all, SIGNAL(triggered(bool)), this, SLOT(set_view_to_all())); @@ -75,7 +75,7 @@ void GraphView::show_context_menu(const QPoint& pos) { menu.addSeparator(); QAction* reset_action = menu.addAction("Reset View"); - if (row == NULL) { + if (row == nullptr) { reset_action->setEnabled(false); } else { connect(reset_action, SIGNAL(triggered(bool)), this, SLOT(reset_view())); @@ -93,7 +93,7 @@ void GraphView::reset_view() { } void GraphView::set_view_to_selection() { - if (row != NULL && selected_keys.size() > 0) { + if (row != nullptr && selected_keys.size() > 0) { long min_time = LONG_MAX; long max_time = LONG_MIN; double min_dbl = DBL_MAX; @@ -110,7 +110,7 @@ void GraphView::set_view_to_selection() { } void GraphView::set_view_to_all() { - if (row != NULL) { + if (row != nullptr) { bool can_set = false; long min_time = LONG_MAX; @@ -201,7 +201,7 @@ QVector sort_keys_from_field(EffectField* field) { void GraphView::paintEvent(QPaintEvent *) { QPainter p(this); - if (panel_sequence_viewer->seq != NULL) { + if (panel_sequence_viewer->seq != nullptr) { // draw grid lines p.setPen(Qt::gray); @@ -210,7 +210,7 @@ void GraphView::paintEvent(QPaintEvent *) { draw_lines(p, false); // draw keyframes - if (row != NULL) { + if (row != nullptr) { QPen line_pen; line_pen.setWidth(BEZIER_LINE_SIZE); @@ -329,7 +329,7 @@ void GraphView::paintEvent(QPaintEvent *) { } void GraphView::mousePressEvent(QMouseEvent *event) { - if (row != NULL) { + if (row != nullptr) { mousedown = true; start_x = event->pos().x(); start_y = event->pos().y(); @@ -530,7 +530,7 @@ void GraphView::mouseMoveEvent(QMouseEvent *event) { break; } } - } else if (row != NULL) { + } else if (row != nullptr) { // clicking on the curve click_add = false; @@ -665,7 +665,7 @@ void GraphView::mouseMoveEvent(QMouseEvent *event) { } } -void GraphView::mouseReleaseEvent(QMouseEvent *e) { +void GraphView::mouseReleaseEvent(QMouseEvent *) { if (click_add_proc) { undo_stack.push(new KeyframeFieldSet(click_add_field, click_add_key)); } else if (moved_keys && selected_keys.size() > 0) { @@ -742,7 +742,7 @@ void GraphView::set_row(EffectRow *r) { selected_keys_old_doubles.clear(); emit selection_changed(false, -1); row = r; - if (row != NULL) { + if (row != nullptr) { field_visibility.resize(row->fieldCount()); field_visibility.fill(true); visible_in = row->parent_effect->parent_clip->timeline_in; @@ -771,7 +771,7 @@ void GraphView::set_field_visibility(int field, bool b) { } void GraphView::delete_selected_keys() { - if (row != NULL) { + if (row != nullptr) { QVector fields; for (int i=0;ifield(selected_keys_fields.at(i))); @@ -781,7 +781,7 @@ void GraphView::delete_selected_keys() { } void GraphView::select_all() { - if (row != NULL) { + if (row != nullptr) { selected_keys.clear(); selected_keys_fields.clear(); for (int i=0;ifieldCount();i++) { diff --git a/ui/timelineheader.cpp b/ui/timelineheader.cpp index 5e7cf4b6a..f8ef7b4c7 100644 --- a/ui/timelineheader.cpp +++ b/ui/timelineheader.cpp @@ -118,7 +118,7 @@ void TimelineHeader::show_text(bool enable) { } void TimelineHeader::mousePressEvent(QMouseEvent* event) { - if (viewer->seq != NULL && event->buttons() & Qt::LeftButton) { + if (viewer->seq != nullptr && event->buttons() & Qt::LeftButton) { if (resizing_workarea) { sequence_end = viewer->seq->getEndFrame(); } else { @@ -168,7 +168,7 @@ void TimelineHeader::mousePressEvent(QMouseEvent* event) { } void TimelineHeader::mouseMoveEvent(QMouseEvent* event) { - if (viewer->seq != NULL) { + if (viewer->seq != nullptr) { if (dragging) { if (resizing_workarea) { long frame = getHeaderFrameFromScreenPoint(event->pos().x()); @@ -214,7 +214,7 @@ void TimelineHeader::mouseMoveEvent(QMouseEvent* event) { } else { resizing_workarea = false; unsetCursor(); - if (viewer->seq != NULL && viewer->seq->using_workarea) { + if (viewer->seq != nullptr && viewer->seq->using_workarea) { long min_frame = getHeaderFrameFromScreenPoint(event->pos().x() - CLICK_RANGE) - 1; long max_frame = getHeaderFrameFromScreenPoint(event->pos().x() + CLICK_RANGE) + 1; if (viewer->seq->workarea_in > min_frame && viewer->seq->workarea_in < max_frame) { @@ -235,7 +235,7 @@ void TimelineHeader::mouseMoveEvent(QMouseEvent* event) { } void TimelineHeader::mouseReleaseEvent(QMouseEvent*) { - if (viewer->seq != NULL) { + if (viewer->seq != nullptr) { dragging = false; if (resizing_workarea) { undo_stack.push(new SetTimelineInOutCommand(viewer->seq, true, temp_workarea_in, temp_workarea_out)); @@ -294,7 +294,7 @@ void TimelineHeader::delete_markers() { } void TimelineHeader::paintEvent(QPaintEvent*) { - if (viewer->seq != NULL && zoom > 0) { + if (viewer->seq != nullptr && zoom > 0) { QPainter p(this); int yoff = (text_enabled) ? height()/2 : 0; diff --git a/ui/timelinewidget.cpp b/ui/timelinewidget.cpp index 44b69ffdc..17c971fde 100644 --- a/ui/timelinewidget.cpp +++ b/ui/timelinewidget.cpp @@ -48,8 +48,8 @@ #define TRANSITION_BETWEEN_RANGE 40 TimelineWidget::TimelineWidget(QWidget *parent) : QWidget(parent) { - selection_command = NULL; - self_created_sequence = NULL; + selection_command = nullptr; + self_created_sequence = nullptr; scroll = 0; bottom_align = false; @@ -79,7 +79,7 @@ void TimelineWidget::right_click_ripple() { } void TimelineWidget::show_context_menu(const QPoint& pos) { - if (sequence != NULL) { + if (sequence != nullptr) { // hack because sometimes right clicking doesn't trigger mouse release event panel_timeline->rect_select_init = false; panel_timeline->rect_select_proc = false; @@ -98,7 +98,7 @@ void TimelineWidget::show_context_menu(const QPoint& pos) { QVector selected_clips; for (int i=0;iclips.size();i++) { Clip* c = sequence->clips.at(i); - if (c != NULL && panel_timeline->is_clip_selected(c, true)) { + if (c != nullptr && panel_timeline->is_clip_selected(c, true)) { selected_clips.append(c); } } @@ -115,7 +115,7 @@ void TimelineWidget::show_context_menu(const QPoint& pos) { for (int i=0;iclips.size();i++) { Clip* c = sequence->clips.at(i); - if (c != NULL) { + if (c != nullptr) { if (c->timeline_in > panel_timeline->cursor_frame || c->timeline_out > panel_timeline->cursor_frame) { at_end_of_sequence = false; } @@ -163,7 +163,7 @@ void TimelineWidget::show_context_menu(const QPoint& pos) { for (int i=0;itrack < 0) { video_clip_count++; - if (selected_clips.at(i)->media == NULL + if (selected_clips.at(i)->media == nullptr || selected_clips.at(i)->media->get_type() != MEDIA_TYPE_FOOTAGE) { all_video_is_footage = false; } @@ -204,7 +204,7 @@ void TimelineWidget::toggle_autoscale() { SetAutoscaleAction* action = new SetAutoscaleAction(); for (int i=0;iclips.size();i++) { Clip* c = sequence->clips.at(i); - if (c != NULL && panel_timeline->is_clip_selected(c, true)) { + if (c != nullptr && panel_timeline->is_clip_selected(c, true)) { action->clips.append(c); } } @@ -216,10 +216,10 @@ void TimelineWidget::toggle_autoscale() { } void TimelineWidget::tooltip_timer_timeout() { - if (sequence != NULL) { + if (sequence != nullptr) { if (tooltip_clip < sequence->clips.size()) { Clip* c = sequence->clips.at(tooltip_clip); - if (c != NULL) { + if (c != nullptr) { QToolTip::showText(QCursor::pos(), c->name + "\nStart: " + frame_to_timecode(c->timeline_in, config.timecode_view, sequence->frame_rate) @@ -235,7 +235,7 @@ void TimelineWidget::rename_clip() { QVector selected_clips; for (int i=0;iclips.size();i++) { Clip* c = sequence->clips.at(i); - if (c != NULL && panel_timeline->is_clip_selected(c, true)) { + if (c != nullptr && panel_timeline->is_clip_selected(c, true)) { selected_clips.append(c); } } @@ -343,7 +343,7 @@ void TimelineWidget::dragEnterEvent(QDragEnterEvent *event) { long entry_point; Sequence* seq = sequence; - if (seq == NULL) { + if (seq == nullptr) { // if no sequence, we're going to create a new one using the clips as a reference entry_point = 0; @@ -365,7 +365,7 @@ void TimelineWidget::dragMoveEvent(QDragMoveEvent *event) { if (panel_timeline->importing) { event->acceptProposedAction(); - if (sequence != NULL) { + if (sequence != nullptr) { QPoint pos = event->pos(); update_ghosts(pos, event->keyboardModifiers() & Qt::ShiftModifier); panel_timeline->move_insert = ((event->keyboardModifiers() & Qt::ControlModifier) && (panel_timeline->tool == TIMELINE_TOOL_POINTER || panel_timeline->importing)); @@ -403,9 +403,9 @@ void TimelineWidget::dragLeaveEvent(QDragLeaveEvent* event) { panel_timeline->importing = false; update_ui(false); } - if (self_created_sequence != NULL) { + if (self_created_sequence != nullptr) { delete self_created_sequence; - self_created_sequence = NULL; + self_created_sequence = nullptr; } } @@ -453,7 +453,7 @@ void insert_clips(ComboAction* ca) { for (int i=0;iclips.size();i++) { Clip* c = sequence->clips.at(i); - if (c != NULL) { + if (c != nullptr) { // don't split any clips that are moving bool found = false; for (int j=0;jghosts.size();j++) { @@ -511,10 +511,10 @@ void TimelineWidget::dropEvent(QDropEvent* event) { Sequence* s = sequence; // if we're dropping into nothing, create a new sequences based on the clip being dragged - if (s == NULL) { + if (s == nullptr) { s = self_created_sequence; - panel_project->new_sequence(ca, self_created_sequence, true, NULL); - self_created_sequence = NULL; + panel_project->new_sequence(ca, self_created_sequence, true, nullptr); + self_created_sequence = nullptr; } else if (event->keyboardModifiers() & Qt::ControlModifier) { insert_clips(ca); } else { @@ -552,7 +552,7 @@ bool isLiveEditing() { } void TimelineWidget::mousePressEvent(QMouseEvent *event) { - if (sequence != NULL) { + if (sequence != nullptr) { int tool = panel_timeline->tool; if (event->button() == Qt::MiddleButton) { tool = TIMELINE_TOOL_HAND; @@ -602,7 +602,7 @@ void TimelineWidget::mousePressEvent(QMouseEvent *event) { Ghost g; g.in = g.old_in = g.out = g.old_out = panel_timeline->drag_frame_start; g.track = g.old_track = panel_timeline->drag_track_start; - g.transition = NULL; + g.transition = nullptr; g.clip = -1; g.trimming = true; g.trim_in = false; @@ -626,7 +626,7 @@ void TimelineWidget::mousePressEvent(QMouseEvent *event) { } else { if (clip_index >= 0) { Clip* clip = sequence->clips.at(clip_index); - if (clip != NULL) { + if (clip != nullptr) { if (panel_timeline->is_clip_selected(clip, true)) { if (shift) { panel_timeline->deselect_area(clip->timeline_in, clip->timeline_out, clip->track); @@ -648,14 +648,14 @@ void TimelineWidget::mousePressEvent(QMouseEvent *event) { Selection s; s.track = clip->track; - if (panel_timeline->transition_select == TA_OPENING_TRANSITION && clip->get_opening_transition() != NULL) { + if (panel_timeline->transition_select == TA_OPENING_TRANSITION && clip->get_opening_transition() != nullptr) { s.in = clip->timeline_in; - if (clip->get_opening_transition()->secondary_clip != NULL) s.in -= clip->get_opening_transition()->get_true_length(); + if (clip->get_opening_transition()->secondary_clip != nullptr) s.in -= clip->get_opening_transition()->get_true_length(); s.out = clip->timeline_in + clip->get_opening_transition()->get_true_length(); - } else if (panel_timeline->transition_select == TA_CLOSING_TRANSITION && clip->get_closing_transition() != NULL) { + } else if (panel_timeline->transition_select == TA_CLOSING_TRANSITION && clip->get_closing_transition() != nullptr) { s.in = clip->timeline_out - clip->get_closing_transition()->get_true_length(); s.out = clip->timeline_out; - if (clip->get_closing_transition()->secondary_clip != NULL) s.out += clip->get_closing_transition()->get_true_length(); + if (clip->get_closing_transition()->secondary_clip != nullptr) s.out += clip->get_closing_transition()->get_true_length(); } sequence->selections.append(s); } @@ -673,12 +673,12 @@ void TimelineWidget::mousePressEvent(QMouseEvent *event) { if (panel_timeline->tool == TIMELINE_TOOL_POINTER) { if (panel_timeline->transition_select == TA_OPENING_TRANSITION) { s.out = clip->timeline_in + clip->get_opening_transition()->get_true_length(); - if (clip->get_opening_transition()->secondary_clip != NULL) s.in -= clip->get_opening_transition()->get_true_length(); + if (clip->get_opening_transition()->secondary_clip != nullptr) s.in -= clip->get_opening_transition()->get_true_length(); } if (panel_timeline->transition_select == TA_CLOSING_TRANSITION) { s.in = clip->timeline_out - clip->get_closing_transition()->get_true_length(); - if (clip->get_closing_transition()->secondary_clip != NULL) s.out += clip->get_closing_transition()->get_true_length(); + if (clip->get_closing_transition()->secondary_clip != nullptr) s.out += clip->get_closing_transition()->get_true_length(); } } @@ -749,10 +749,10 @@ void TimelineWidget::mousePressEvent(QMouseEvent *event) { void make_room_for_transition(ComboAction* ca, Clip* c, int type, long transition_start, long transition_end, bool delete_old_transitions) { // make room for transition if (type == TA_OPENING_TRANSITION) { - if (delete_old_transitions && c->get_opening_transition() != NULL) { + if (delete_old_transitions && c->get_opening_transition() != nullptr) { ca->append(new DeleteTransitionCommand(c->sequence, c->opening_transition)); } - if (c->get_closing_transition() != NULL) { + if (c->get_closing_transition() != nullptr) { if (transition_end >= c->timeline_out) { ca->append(new DeleteTransitionCommand(c->sequence, c->closing_transition)); } else if (transition_end > c->timeline_out - c->get_closing_transition()->get_true_length()) { @@ -760,10 +760,10 @@ void make_room_for_transition(ComboAction* ca, Clip* c, int type, long transitio } } } else { - if (delete_old_transitions && c->get_closing_transition() != NULL) { + if (delete_old_transitions && c->get_closing_transition() != nullptr) { ca->append(new DeleteTransitionCommand(c->sequence, c->closing_transition)); } - if (c->get_opening_transition() != NULL) { + if (c->get_opening_transition() != nullptr) { if (transition_start <= c->timeline_in) { ca->append(new DeleteTransitionCommand(c->sequence, c->opening_transition)); } else if (transition_start < c->timeline_in + c->get_opening_transition()->get_true_length()) { @@ -775,7 +775,7 @@ void make_room_for_transition(ComboAction* ca, Clip* c, int type, long transitio void TimelineWidget::mouseReleaseEvent(QMouseEvent *event) { QToolTip::hideText(); - if (sequence != NULL) { + if (sequence != nullptr) { bool alt = (event->modifiers() & Qt::AltModifier); bool shift = (event->modifiers() & Qt::ShiftModifier); bool ctrl = (event->modifiers() & Qt::ControlModifier); @@ -794,7 +794,7 @@ void TimelineWidget::mouseReleaseEvent(QMouseEvent *event) { panel_timeline->creating = false; } else if (g.in != g.out) { Clip* c = new Clip(sequence); - c->media = NULL; + c->media = nullptr; c->timeline_in = qMin(g.in, g.out); c->timeline_out = qMax(g.in, g.out); c->clip_in = 0; @@ -955,9 +955,9 @@ void TimelineWidget::mouseReleaseEvent(QMouseEvent *event) { const Ghost& g = panel_timeline->ghosts.at(i); sequence->clips.at(g.clip)->undeletable = true; - if (g.transition != NULL) { + if (g.transition != nullptr) { g.transition->parent_clip->undeletable = true; - if (g.transition->secondary_clip != NULL) g.transition->secondary_clip->undeletable = true; + if (g.transition->secondary_clip != nullptr) g.transition->secondary_clip->undeletable = true; } Selection s; @@ -970,9 +970,9 @@ void TimelineWidget::mouseReleaseEvent(QMouseEvent *event) { for (int i=0;ighosts.size();i++) { const Ghost& g = panel_timeline->ghosts.at(i); sequence->clips.at(g.clip)->undeletable = false; - if (g.transition != NULL) { + if (g.transition != nullptr) { g.transition->parent_clip->undeletable = false; - if (g.transition->secondary_clip != NULL) g.transition->secondary_clip->undeletable = false; + if (g.transition->secondary_clip != nullptr) g.transition->secondary_clip->undeletable = false; } } } @@ -981,14 +981,14 @@ void TimelineWidget::mouseReleaseEvent(QMouseEvent *event) { // step 3 - move clips Clip* c = sequence->clips.at(g.clip); - if (g.transition == NULL) { + if (g.transition == nullptr) { move_clip(ca, c, (g.in - g.old_in), (g.out - g.old_out), (g.clip_in - g.old_clip_in), (g.track - g.old_track), true, true); // adjust transitions if we need to long new_clip_length = (g.out - g.in); - if (c->get_opening_transition() != NULL) { + if (c->get_opening_transition() != nullptr) { long max_open_length = new_clip_length; - if (c->get_closing_transition() != NULL && !panel_timeline->trim_in_point) { + if (c->get_closing_transition() != nullptr && !panel_timeline->trim_in_point) { max_open_length -= c->get_closing_transition()->get_true_length(); } if (max_open_length <= 0) { @@ -997,9 +997,9 @@ void TimelineWidget::mouseReleaseEvent(QMouseEvent *event) { ca->append(new ModifyTransitionCommand(c, TA_OPENING_TRANSITION, max_open_length)); } } - if (c->get_closing_transition() != NULL) { + if (c->get_closing_transition() != nullptr) { long max_open_length = new_clip_length; - if (c->get_opening_transition() != NULL && panel_timeline->trim_in_point) { + if (c->get_opening_transition() != nullptr && panel_timeline->trim_in_point) { max_open_length -= c->get_opening_transition()->get_true_length(); } if (max_open_length <= 0) { @@ -1011,12 +1011,12 @@ void TimelineWidget::mouseReleaseEvent(QMouseEvent *event) { } else { bool is_opening_transition = (g.transition == c->get_opening_transition()); long new_transition_length = g.out - g.in; - if (g.transition->secondary_clip != NULL) new_transition_length >>= 1; + if (g.transition->secondary_clip != nullptr) new_transition_length >>= 1; ca->append(new ModifyTransitionCommand(c, is_opening_transition ? TA_OPENING_TRANSITION : TA_CLOSING_TRANSITION, new_transition_length)); long clip_length = c->getLength(); - if (g.transition->secondary_clip != NULL) { + if (g.transition->secondary_clip != nullptr) { if (g.in != g.old_in && !g.trimming) { long movement = g.in - g.old_in; move_clip(ca, g.transition->parent_clip, movement, 0, movement, 0, false, true); @@ -1106,9 +1106,9 @@ void TimelineWidget::mouseReleaseEvent(QMouseEvent *event) { } if (panel_timeline->transition_tool_post_clip > -1) { - ca->append(new AddTransitionCommand(pre, post, NULL, panel_timeline->transition_tool_meta, TA_OPENING_TRANSITION, transition_end - pre->timeline_in)); + ca->append(new AddTransitionCommand(pre, post, nullptr, panel_timeline->transition_tool_meta, TA_OPENING_TRANSITION, transition_end - pre->timeline_in)); } else { - ca->append(new AddTransitionCommand(pre, NULL, NULL, panel_timeline->transition_tool_meta, panel_timeline->transition_tool_type, transition_end - transition_start)); + ca->append(new AddTransitionCommand(pre, nullptr, nullptr, panel_timeline->transition_tool_meta, panel_timeline->transition_tool_type, transition_end - transition_start)); } push_undo = true; @@ -1130,10 +1130,10 @@ void TimelineWidget::mouseReleaseEvent(QMouseEvent *event) { // remove duplicate selections panel_timeline->clean_up_selections(sequence->selections); - if (selection_command != NULL) { + if (selection_command != nullptr) { selection_command->new_data = sequence->selections; ca->append(selection_command); - selection_command = NULL; + selection_command = nullptr; push_undo = true; } @@ -1180,7 +1180,7 @@ void TimelineWidget::init_ghosts() { g.in = g.old_in = c->get_timeline_in_with_transition(); g.out = g.old_out = c->get_timeline_out_with_transition(); g.ghost_length = g.old_out - g.old_in; - } else if (g.transition == NULL) { + } else if (g.transition == nullptr) { // this ghost is for a clip g.in = g.old_in = c->timeline_in; g.out = g.old_out = c->timeline_out; @@ -1277,11 +1277,11 @@ void TimelineWidget::update_ghosts(const QPoint& mouse_pos, bool lock_frame) { long temp_frame_diff = frame_diff; // cache to see if we change it (thus cancelling any snap) for (int i=0;ighosts.size();i++) { const Ghost& g = panel_timeline->ghosts.at(i); - Clip* c = NULL; + Clip* c = nullptr; if (g.clip != -1) c = sequence->clips.at(g.clip); - const FootageStream* ms = NULL; - if (g.clip != -1 && c->media != NULL && c->media->get_type() == MEDIA_TYPE_FOOTAGE) { + const FootageStream* ms = nullptr; + if (g.clip != -1 && c->media != nullptr && c->media->get_type() == MEDIA_TYPE_FOOTAGE) { ms = c->media->to_footage()->get_stream_from_file_index(c->track < 0, c->media_stream); } @@ -1289,8 +1289,8 @@ void TimelineWidget::update_ghosts(const QPoint& mouse_pos, bool lock_frame) { if (panel_timeline->creating) { // i feel like we might need something here but we haven't so far? } else if (effective_tool == TIMELINE_TOOL_SLIP) { - if ((c->media != NULL && c->media->get_type() == MEDIA_TYPE_SEQUENCE) - || (ms != NULL && !ms->infinite_length)) { + if ((c->media != nullptr && c->media->get_type() == MEDIA_TYPE_SEQUENCE) + || (ms != nullptr && !ms->infinite_length)) { // prevent slip moving a clip below 0 clip_in validator = g.old_clip_in - frame_diff; if (validator < 0) frame_diff += validator; @@ -1312,8 +1312,8 @@ void TimelineWidget::update_ghosts(const QPoint& mouse_pos, bool lock_frame) { } // prevent clip_in from going below 0 - if ((c->media != NULL && c->media->get_type() == MEDIA_TYPE_SEQUENCE) - || (ms != NULL && !ms->infinite_length)) { + if ((c->media != nullptr && c->media->get_type() == MEDIA_TYPE_SEQUENCE) + || (ms != nullptr && !ms->infinite_length)) { validator = g.old_clip_in + frame_diff; if (validator < 0) frame_diff -= validator; } @@ -1323,15 +1323,15 @@ void TimelineWidget::update_ghosts(const QPoint& mouse_pos, bool lock_frame) { if (validator < 1) frame_diff += (1 - validator); // prevent clip length exceeding media length - if ((c->media != NULL && c->media->get_type() == MEDIA_TYPE_SEQUENCE) - || (ms != NULL && !ms->infinite_length)) { + if ((c->media != nullptr && c->media->get_type() == MEDIA_TYPE_SEQUENCE) + || (ms != nullptr && !ms->infinite_length)) { validator = g.old_clip_in + g.ghost_length + frame_diff; if (validator > g.media_length) frame_diff -= validator - g.media_length; } } // prevent dual transition from going below 0 on the primary or media length on the secondary - if (g.transition != NULL && g.transition->secondary_clip != NULL) { + if (g.transition != nullptr && g.transition->secondary_clip != nullptr) { Clip* otc = g.transition->parent_clip; Clip* ctc = g.transition->secondary_clip; @@ -1387,8 +1387,8 @@ void TimelineWidget::update_ghosts(const QPoint& mouse_pos, bool lock_frame) { validator = g.old_in + frame_diff; if (validator < 0) frame_diff -= validator; - if (g.transition != NULL) { - if (g.transition->secondary_clip != NULL) { + if (g.transition != nullptr) { + if (g.transition->secondary_clip != nullptr) { // prevent dual transitions from going below 0 on the primary or above media length on the secondary validator = g.transition->parent_clip->get_clip_in_with_transition() + frame_diff; @@ -1405,14 +1405,14 @@ void TimelineWidget::update_ghosts(const QPoint& mouse_pos, bool lock_frame) { } else { // prevent clip_in from going below 0 if (c->media->get_type() == MEDIA_TYPE_SEQUENCE - || (ms != NULL && !ms->infinite_length)) { + || (ms != nullptr && !ms->infinite_length)) { validator = g.old_clip_in + frame_diff; if (validator < 0) frame_diff -= validator; } // prevent clip length exceeding media length if (c->media->get_type() == MEDIA_TYPE_SEQUENCE - || (ms != NULL && !ms->infinite_length)) { + || (ms != nullptr && !ms->infinite_length)) { validator = g.old_clip_in + g.ghost_length + frame_diff; if (validator > g.media_length) frame_diff -= validator - g.media_length; } @@ -1482,7 +1482,7 @@ void TimelineWidget::update_ghosts(const QPoint& mouse_pos, bool lock_frame) { } // apply changes - if (g.transition != NULL && g.transition->secondary_clip != NULL) { + if (g.transition != nullptr && g.transition->secondary_clip != nullptr) { if (g.trim_in) ghost_diff = -ghost_diff; g.in = g.old_in - ghost_diff; g.out = g.old_out + ghost_diff; @@ -1497,7 +1497,7 @@ void TimelineWidget::update_ghosts(const QPoint& mouse_pos, bool lock_frame) { g.in = g.old_in + frame_diff; g.out = g.old_out + frame_diff; - if (g.transition != NULL && g.transition == sequence->clips.at(g.clip)->get_opening_transition()) { + if (g.transition != nullptr && g.transition == sequence->clips.at(g.clip)->get_opening_transition()) { g.clip_in = g.old_clip_in + frame_diff; } @@ -1566,7 +1566,7 @@ void TimelineWidget::update_ghosts(const QPoint& mouse_pos, bool lock_frame) { QString tip = ((frame_diff < 0) ? "-" : "+") + frame_to_timecode(qAbs(frame_diff), config.timecode_view, sequence->frame_rate); if (panel_timeline->trim_target > -1) { // find which clip is being moved - const Ghost* g = NULL; + const Ghost* g = nullptr; for (int i=0;ighosts.size();i++) { if (panel_timeline->ghosts.at(i).clip == panel_timeline->trim_target) { g = &panel_timeline->ghosts.at(i); @@ -1574,7 +1574,7 @@ void TimelineWidget::update_ghosts(const QPoint& mouse_pos, bool lock_frame) { } } - if (g != NULL) { + if (g != nullptr) { tip += " Duration: "; long len = (g->old_out-g->old_in); if (panel_timeline->trim_in_point) { @@ -1591,7 +1591,7 @@ void TimelineWidget::update_ghosts(const QPoint& mouse_pos, bool lock_frame) { void TimelineWidget::mouseMoveEvent(QMouseEvent *event) { tooltip_timer.stop(); - if (sequence != NULL) { + if (sequence != nullptr) { bool alt = (event->modifiers() & Qt::AltModifier); panel_timeline->cursor_frame = panel_timeline->getTimelineFrameFromScreenPoint(event->pos().x()); @@ -1690,14 +1690,14 @@ void TimelineWidget::mouseMoveEvent(QMouseEvent *event) { // create ghosts for (int i=0;iclips.size();i++) { Clip* c = sequence->clips.at(i); - if (c != NULL) { + if (c != nullptr) { Ghost g; - g.transition = NULL; + g.transition = nullptr; bool add = panel_timeline->is_clip_selected(c, true); // if a whole clip is not selected, maybe just a transition is - if (panel_timeline->tool == TIMELINE_TOOL_POINTER && (c->get_opening_transition() != NULL || c->get_closing_transition() != NULL)) { + if (panel_timeline->tool == TIMELINE_TOOL_POINTER && (c->get_opening_transition() != nullptr || c->get_closing_transition() != nullptr)) { // check if any selections contain the whole clip or transition for (int j=0;jselections.size();j++) { const Selection& s = sequence->selections.at(j); @@ -1715,7 +1715,7 @@ void TimelineWidget::mouseMoveEvent(QMouseEvent *event) { } } - if (add && g.transition != NULL) { + if (add && g.transition != nullptr) { // check for duplicate transitions for (int j=0;jghosts.size();j++) { if (panel_timeline->ghosts.at(j).transition == g.transition) { @@ -1771,7 +1771,7 @@ void TimelineWidget::mouseMoveEvent(QMouseEvent *event) { if (!found) { // add ghost for this clip with opposite trim_in Ghost gh; - gh.transition = NULL; + gh.transition = nullptr; gh.clip = j; gh.trimming = (panel_timeline->trim_target > -1); gh.trim_in = !panel_timeline->trim_in_point; @@ -1795,7 +1795,7 @@ void TimelineWidget::mouseMoveEvent(QMouseEvent *event) { panel_timeline->ghosts[i].trimming = false; for (int j=0;jclips.size();j++) { Clip* c = sequence->clips.at(j); - if (c != NULL && c->track == ghost_clip->track) { + if (c != nullptr && c->track == ghost_clip->track) { bool found = false; for (int k=0;kghosts.at(k).clip == j) { @@ -1807,7 +1807,7 @@ void TimelineWidget::mouseMoveEvent(QMouseEvent *event) { bool is_in = (c->timeline_in == ghost_clip->timeline_out); if (is_in || c->timeline_out == ghost_clip->timeline_in) { Ghost gh; - gh.transition = NULL; + gh.transition = nullptr; gh.clip = j; gh.trimming = true; gh.trim_in = is_in; @@ -1836,7 +1836,7 @@ void TimelineWidget::mouseMoveEvent(QMouseEvent *event) { for (int i=0;iclips.size();i++) { Clip* c = sequence->clips.at(i); - if (c != NULL && !panel_timeline->is_clip_selected(c, true)) { + if (c != nullptr && !panel_timeline->is_clip_selected(c, true)) { bool clip_is_post = (c->timeline_in >= axis); // see if this a clip on this track is already in the list, and if it's closer @@ -1912,7 +1912,7 @@ void TimelineWidget::mouseMoveEvent(QMouseEvent *event) { QVector selected_clips; for (int i=0;iclips.size();i++) { Clip* clip = sequence->clips.at(i); - if (clip != NULL && + if (clip != nullptr && clip->track >= track_min && clip->track <= track_max && !(clip->timeline_in < frame_min && clip->timeline_out < frame_min) && @@ -1983,7 +1983,7 @@ void TimelineWidget::mouseMoveEvent(QMouseEvent *event) { panel_timeline->transition_select = TA_NO_TRANSITION; for (int i=0;iclips.size();i++) { Clip* c = sequence->clips.at(i); - if (c != NULL) { + if (c != nullptr) { min_track = qMin(min_track, c->track); max_track = qMax(max_track, c->track); if (c->track == mouse_track) { @@ -1994,9 +1994,9 @@ void TimelineWidget::mouseMoveEvent(QMouseEvent *event) { tooltip_timer.start(); tooltip_clip = i; - if (c->get_opening_transition() != NULL && panel_timeline->cursor_frame <= c->timeline_in + c->get_opening_transition()->get_true_length()) { + if (c->get_opening_transition() != nullptr && panel_timeline->cursor_frame <= c->timeline_in + c->get_opening_transition()->get_true_length()) { panel_timeline->transition_select = TA_OPENING_TRANSITION; - } else if (c->get_closing_transition() != NULL && panel_timeline->cursor_frame >= c->timeline_out - c->get_closing_transition()->get_true_length()) { + } else if (c->get_closing_transition() != nullptr && panel_timeline->cursor_frame >= c->timeline_out - c->get_closing_transition()->get_true_length()) { panel_timeline->transition_select = TA_CLOSING_TRANSITION; } } @@ -2019,7 +2019,7 @@ void TimelineWidget::mouseMoveEvent(QMouseEvent *event) { } } if (panel_timeline->tool == TIMELINE_TOOL_POINTER) { - if (c->get_opening_transition() != NULL) { + if (c->get_opening_transition() != nullptr) { long transition_point = c->timeline_in + c->get_opening_transition()->get_true_length(); if (transition_point > mouse_frame_lower && transition_point < mouse_frame_upper) { @@ -2033,7 +2033,7 @@ void TimelineWidget::mouseMoveEvent(QMouseEvent *event) { } } } - if (c->get_closing_transition() != NULL) { + if (c->get_closing_transition() != nullptr) { long transition_point = c->timeline_out - c->get_closing_transition()->get_true_length(); if (transition_point > mouse_frame_lower && transition_point < mouse_frame_upper) { int nc = qAbs(transition_point + 1 - panel_timeline->cursor_frame); @@ -2150,7 +2150,7 @@ void TimelineWidget::leaveEvent(QEvent*) { } int color_brightness(int r, int g, int b) { - return (0.2126*r + 0.7152*g + 0.0722*b); + return qRound(0.2126*r + 0.7152*g + 0.0722*b); } void draw_waveform(Clip* clip, const FootageStream* ms, long media_length, QPainter *p, const QRect& clip_rect, int waveform_start, int waveform_limit, double zoom) { @@ -2186,7 +2186,7 @@ void draw_waveform(Clip* clip, const FootageStream* ms, long media_length, QPain void draw_transition(QPainter& p, Clip* c, const QRect& clip_rect, QRect& text_rect, int transition_type) { Transition* t = (transition_type == TA_OPENING_TRANSITION) ? c->get_opening_transition() : c->get_closing_transition(); - if (t != NULL) { + if (t != nullptr) { QColor transition_color(255, 0, 0, 16); int transition_width = getScreenPointFromFrame(panel_timeline->zoom, t->get_true_length()); int transition_height = clip_rect.height(); @@ -2206,7 +2206,7 @@ void draw_transition(QPainter& p, Clip* c, const QRect& clip_rect, QRect& text_r bool draw_text = true; p.setPen(QColor(0, 0, 0, 96)); - if (t->secondary_clip == NULL) { + if (t->secondary_clip == nullptr) { if (transition_type == TA_OPENING_TRANSITION) { p.drawLine(transition_rect.bottomLeft(), transition_rect.topRight()); } else { @@ -2236,7 +2236,7 @@ void draw_transition(QPainter& p, Clip* c, const QRect& clip_rect, QRect& text_r void TimelineWidget::paintEvent(QPaintEvent*) { // Draw clips - if (sequence != NULL) { + if (sequence != nullptr) { QPainter p(this); // get widget width and height @@ -2244,7 +2244,7 @@ void TimelineWidget::paintEvent(QPaintEvent*) { int audio_track_limit = 0; for (int i=0;iclips.size();i++) { Clip* clip = sequence->clips.at(i); - if (clip != NULL) { + if (clip != nullptr) { video_track_limit = qMin(video_track_limit, clip->track); audio_track_limit = qMax(audio_track_limit, clip->track); } @@ -2268,7 +2268,7 @@ void TimelineWidget::paintEvent(QPaintEvent*) { for (int i=0;iclips.size();i++) { Clip* clip = sequence->clips.at(i); - if (clip != NULL && is_track_visible(clip->track)) { + if (clip != nullptr && is_track_visible(clip->track)) { QRect clip_rect(panel_timeline->getTimelineScreenPointFromFrame(clip->timeline_in), getScreenPointFromTrack(clip->track), getScreenPointFromFrame(panel_timeline->zoom, clip->getLength()), panel_timeline->calculate_track_height(clip->track, -1)); QRect text_rect(clip_rect.left() + CLIP_TEXT_PADDING, clip_rect.top() + CLIP_TEXT_PADDING, clip_rect.width() - CLIP_TEXT_PADDING - 1, clip_rect.height() - CLIP_TEXT_PADDING - 1); if (clip_rect.left() < width() && clip_rect.right() >= 0 && clip_rect.top() < height() && clip_rect.bottom() >= 0) { @@ -2281,12 +2281,12 @@ void TimelineWidget::paintEvent(QPaintEvent*) { int thumb_x = clip_rect.x() + 1; - if (clip->media != NULL && clip->media->get_type() == MEDIA_TYPE_FOOTAGE) { + if (clip->media != nullptr && clip->media->get_type() == MEDIA_TYPE_FOOTAGE) { bool draw_checkerboard = false; QRect checkerboard_rect(clip_rect); Footage* m = clip->media->to_footage(); FootageStream* ms = m->get_stream_from_file_index(clip->track < 0, clip->media_stream); - if (ms == NULL) { + if (ms == nullptr) { draw_checkerboard = true; } else if (ms->preview_done) { // draw top and tail triangles @@ -2332,12 +2332,12 @@ void TimelineWidget::paintEvent(QPaintEvent*) { int thumb_y = p.fontMetrics().height()+CLIP_TEXT_PADDING+CLIP_TEXT_PADDING; if (thumb_x < width() && thumb_y < height()) { int space_for_thumb = clip_rect.width()-1; - if (clip->get_opening_transition() != NULL) { + if (clip->get_opening_transition() != nullptr) { int ot_width = getScreenPointFromFrame(panel_timeline->zoom, clip->get_opening_transition()->get_true_length()); thumb_x += ot_width; space_for_thumb -= ot_width; } - if (clip->get_closing_transition() != NULL) { + if (clip->get_closing_transition() != nullptr) { space_for_thumb -= getScreenPointFromFrame(panel_timeline->zoom, clip->get_closing_transition()->get_true_length()); } int thumb_height = clip_rect.height()-thumb_y; @@ -2642,7 +2642,7 @@ void TimelineWidget::paintEvent(QPaintEvent*) { } } -void TimelineWidget::resizeEvent(QResizeEvent *event) { +void TimelineWidget::resizeEvent(QResizeEvent *) { scrollBar->setPageStep(height()); } @@ -2692,7 +2692,7 @@ int TimelineWidget::getScreenPointFromTrack(int track) { int TimelineWidget::getClipIndexFromCoords(long frame, int track) { for (int i=0;iclips.size();i++) { Clip* c = sequence->clips.at(i); - if (c != NULL && c->track == track && frame >= c->timeline_in && frame < c->timeline_out) { + if (c != nullptr && c->track == track && frame >= c->timeline_in && frame < c->timeline_out) { return i; } } diff --git a/ui/viewercontainer.cpp b/ui/viewercontainer.cpp index 5c109b077..21f709b1c 100644 --- a/ui/viewercontainer.cpp +++ b/ui/viewercontainer.cpp @@ -14,7 +14,7 @@ ViewerContainer::ViewerContainer(QWidget *parent) : QScrollArea(parent), fit(true), - child(NULL) + child(nullptr) { setFrameShadow(QFrame::Plain); setFrameShape(QFrame::NoFrame); @@ -50,7 +50,7 @@ void ViewerContainer::dragScrollMove(const QPoint &p) { } void ViewerContainer::adjust() { - if (viewer->seq != NULL) { + if (viewer->seq != nullptr) { if (child->waveform) { child->move(0, 0); child->resize(size()); diff --git a/ui/viewerwidget.cpp b/ui/viewerwidget.cpp index f8adf8313..e64509b07 100644 --- a/ui/viewerwidget.cpp +++ b/ui/viewerwidget.cpp @@ -46,10 +46,10 @@ extern "C" { ViewerWidget::ViewerWidget(QWidget *parent) : QOpenGLWidget(parent), - default_fbo(NULL), + default_fbo(nullptr), waveform(false), dragging(false), - selected_gizmo(NULL), + selected_gizmo(nullptr), waveform_zoom(1.0), waveform_scroll(0) { @@ -70,7 +70,7 @@ ViewerWidget::ViewerWidget(QWidget *parent) : void ViewerWidget::delete_function() { // destroy all textures as well - if (viewer->seq != NULL) { + if (viewer->seq != nullptr) { makeCurrent(); closeActiveClips(viewer->seq); doneCurrent(); @@ -143,7 +143,7 @@ void ViewerWidget::save_frame() { img.save(fn); fbo.release(); - default_fbo = NULL; + default_fbo = nullptr; rendering = false; } } @@ -204,7 +204,7 @@ void ViewerWidget::seek_from_click(int x) { } EffectGizmo* ViewerWidget::get_gizmo_from_mouse(int x, int y) { - if (gizmos != NULL) { + if (gizmos != nullptr) { double multiplier = (double) viewer->seq->width / (double) width(); QPoint mouse_pos(qRound(x*multiplier), qRound(y*multiplier)); int dot_size = 2 * qRound(GIZMO_DOT_SIZE * multiplier); @@ -238,11 +238,11 @@ EffectGizmo* ViewerWidget::get_gizmo_from_mouse(int x, int y) { } } - return NULL; + return nullptr; } void ViewerWidget::move_gizmos(QMouseEvent *event, bool done) { - if (selected_gizmo != NULL) { + if (selected_gizmo != nullptr) { double multiplier = (double) viewer->seq->width / (double) width(); int x_movement = (event->pos().x() - drag_start_x)*multiplier; @@ -274,7 +274,7 @@ void ViewerWidget::mousePressEvent(QMouseEvent* event) { selected_gizmo = get_gizmo_from_mouse(event->pos().x(), event->pos().y()); - if (selected_gizmo != NULL) { + if (selected_gizmo != nullptr) { selected_gizmo->set_previous_value(); } } @@ -291,7 +291,7 @@ void ViewerWidget::mouseMoveEvent(QMouseEvent* event) { seek_from_click(event->x()); } else if (event->buttons() & Qt::MiddleButton || panel_timeline->tool == TIMELINE_TOOL_HAND) { container->dragScrollMove(event->pos()); - } else if (gizmos == NULL) { + } else if (gizmos == nullptr) { QDrag* drag = new QDrag(this); QMimeData* mimeData = new QMimeData; mimeData->setText("h"); // QMimeData will fail without some kind of data @@ -303,7 +303,7 @@ void ViewerWidget::mouseMoveEvent(QMouseEvent* event) { } } else { EffectGizmo* g = get_gizmo_from_mouse(event->pos().x(), event->pos().y()); - if (g != NULL) { + if (g != nullptr) { if (g->get_cursor() > -1) { setCursor(static_cast(g->get_cursor())); } @@ -420,7 +420,7 @@ GLuint ViewerWidget::draw_clip(QOpenGLFramebufferObject* fbo, GLuint texture, bo // restore previous blendFunc glBlendFuncSeparate(src_rgb, dst_rgb, src_alpha, dst_alpha); - if (default_fbo != NULL) default_fbo->bind(); + if (default_fbo != nullptr) default_fbo->bind(); glPopMatrix(); return fbo->texture(); @@ -441,7 +441,7 @@ void ViewerWidget::process_effect(Clip* c, Effect* e, double timecode, GLTexture if (e->enable_superimpose) { GLuint superimpose_texture = e->process_superimpose(timecode); if (superimpose_texture == 0) { - qWarning() << "Superimpose texture was NULL, retrying..."; + qWarning() << "Superimpose texture was nullptr, retrying..."; texture_failed = true; } else { composite_texture = draw_clip(c->fbo[!fbo_switcher], superimpose_texture, false); @@ -466,7 +466,7 @@ GLuint ViewerWidget::compose_sequence(QVector& nests, bool render_audio) playhead = refactor_frame_number(playhead, nests.at(i)->sequence->frame_rate, s->frame_rate); } - if (nests.last()->fbo != NULL) { + if (nests.last()->fbo != nullptr) { nests.last()->fbo[0]->bind(); glClear(GL_COLOR_BUFFER_BIT); nests.last()->fbo[0]->release(); @@ -481,16 +481,16 @@ GLuint ViewerWidget::compose_sequence(QVector& nests, bool render_audio) Clip* c = s->clips.at(i); // if clip starts within one second and/or hasn't finished yet - if (c != NULL) { + if (c != nullptr) { if (!(!nests.isEmpty() && !same_sign(c->track, nests.last()->track))) { bool clip_is_active = false; - if (c->media != NULL && c->media->get_type() == MEDIA_TYPE_FOOTAGE) { + if (c->media != nullptr && c->media->get_type() == MEDIA_TYPE_FOOTAGE) { Footage* m = c->media->to_footage(); if (!m->invalid && !(c->track >= 0 && !is_audio_device_set())) { if (m->ready) { const FootageStream* ms = m->get_stream_from_file_index(c->track < 0, c->media_stream); - if (ms != NULL && is_clip_active(c, playhead)) { + if (ms != nullptr && is_clip_active(c, playhead)) { // if thread is already working, we don't want to touch this, // but we also don't want to hang the UI thread if (!c->open) { @@ -545,7 +545,7 @@ GLuint ViewerWidget::compose_sequence(QVector& nests, bool render_audio) Clip* c = current_clips.at(i); - if (c->media != NULL && c->media->get_type() == MEDIA_TYPE_FOOTAGE && !c->finished_opening) { + if (c->media != nullptr && c->media->get_type() == MEDIA_TYPE_FOOTAGE && !c->finished_opening) { qWarning() << "Tried to display clip" << i << "but it's closed"; texture_failed = true; } else { @@ -554,11 +554,11 @@ GLuint ViewerWidget::compose_sequence(QVector& nests, bool render_audio) int video_width = c->getWidth(); int video_height = c->getHeight(); - if (c->media != NULL) { + if (c->media != nullptr) { switch (c->media->get_type()) { case MEDIA_TYPE_FOOTAGE: // set up opengl texture - if (c->texture == NULL) { + if (c->texture == nullptr) { c->texture = new QOpenGLTexture(QOpenGLTexture::Target2D); c->texture->setSize(c->stream->codecpar->width, c->stream->codecpar->height); c->texture->setFormat(get_gl_tex_fmt_from_av(c->pix_fmt)); @@ -575,14 +575,14 @@ GLuint ViewerWidget::compose_sequence(QVector& nests, bool render_audio) } } - if (textureID == 0 && c->media != NULL) { + if (textureID == 0 && c->media != nullptr) { qWarning() << "Texture hasn't been created yet"; texture_failed = true; } else if (playhead >= c->get_timeline_in_with_transition()) { glPushMatrix(); // start preparing cache - if (c->fbo == NULL) { + if (c->fbo == nullptr) { c->fbo = new QOpenGLFramebufferObject* [2]; c->fbo[0] = new QOpenGLFramebufferObject(video_width, video_height); c->fbo[1] = new QOpenGLFramebufferObject(video_width, video_height); @@ -602,7 +602,7 @@ GLuint ViewerWidget::compose_sequence(QVector& nests, bool render_audio) GLuint composite_texture; - if (c->media == NULL) { + if (c->media == nullptr) { c->fbo[fbo_switcher]->bind(); glClear(GL_COLOR_BUFFER_BIT); c->fbo[fbo_switcher]->release(); @@ -644,35 +644,35 @@ GLuint ViewerWidget::compose_sequence(QVector& nests, bool render_audio) // EFFECT CODE START double timecode = get_timecode(c, playhead); - Effect* first_gizmo_effect = NULL; - Effect* selected_effect = NULL; + Effect* first_gizmo_effect = nullptr; + Effect* selected_effect = nullptr; for (int j=0;jeffects.size();j++) { Effect* e = c->effects.at(j); process_effect(c, e, timecode, coords, composite_texture, fbo_switcher, TA_NO_TRANSITION); if (e->are_gizmos_enabled()) { - if (first_gizmo_effect == NULL) first_gizmo_effect = e; + if (first_gizmo_effect == nullptr) first_gizmo_effect = e; if (e->container->selected) selected_effect = e; } } if (!rendering) { - if (selected_effect != NULL) { + if (selected_effect != nullptr) { gizmos = selected_effect; } else if (panel_timeline->is_clip_selected(c, true)) { gizmos = first_gizmo_effect; } } - if (c->get_opening_transition() != NULL) { + if (c->get_opening_transition() != nullptr) { int transition_progress = playhead - c->get_timeline_in_with_transition(); if (transition_progress < c->get_opening_transition()->get_length()) { process_effect(c, c->get_opening_transition(), (double)transition_progress/(double)c->get_opening_transition()->get_length(), coords, composite_texture, fbo_switcher, TA_OPENING_TRANSITION); } } - if (c->get_closing_transition() != NULL) { + if (c->get_closing_transition() != nullptr) { int transition_progress = playhead - (c->get_timeline_out_with_transition() - c->get_closing_transition()->get_length()); if (transition_progress >= 0 && transition_progress < c->get_closing_transition()->get_length()) { process_effect(c, c->get_closing_transition(), (double)transition_progress/(double)c->get_closing_transition()->get_length(), coords, composite_texture, fbo_switcher, TA_CLOSING_TRANSITION); @@ -750,7 +750,7 @@ GLuint ViewerWidget::compose_sequence(QVector& nests, bool render_audio) glBindTexture(GL_TEXTURE_2D, 0); // unbind texture - if (gizmos != NULL && !drawn_gizmos) { + if (gizmos != nullptr && !drawn_gizmos) { gizmos->gizmo_draw(timecode, coords); // set correct gizmo coords gizmos->gizmo_world_to_screen(); @@ -759,7 +759,7 @@ GLuint ViewerWidget::compose_sequence(QVector& nests, bool render_audio) if (!nests.isEmpty()) { nests.last()->fbo[0]->release(); - if (default_fbo != NULL) default_fbo->bind(); + if (default_fbo != nullptr) default_fbo->bind(); } glPopMatrix(); @@ -774,7 +774,7 @@ GLuint ViewerWidget::compose_sequence(QVector& nests, bool render_audio) } } else { if (render_audio || (config.enable_audio_scrubbing && audio_scrub)) { - if (c->media != NULL && c->media->get_type() == MEDIA_TYPE_SEQUENCE) { + if (c->media != nullptr && c->media->get_type() == MEDIA_TYPE_SEQUENCE) { nests.append(c); compose_sequence(nests, render_audio); nests.removeLast(); @@ -810,7 +810,7 @@ GLuint ViewerWidget::compose_sequence(QVector& nests, bool render_audio) glPopMatrix(); - if (!nests.isEmpty() && nests.last()->fbo != NULL) { + if (!nests.isEmpty() && nests.last()->fbo != nullptr) { // returns nested clip's texture return nests.last()->fbo[0]->texture(); } @@ -821,8 +821,8 @@ GLuint ViewerWidget::compose_sequence(QVector& nests, bool render_audio) void ViewerWidget::paintGL() { drawn_gizmos = false; force_quit = false; - if (viewer->seq != NULL) { - gizmos = NULL; + if (viewer->seq != nullptr) { + gizmos = nullptr; bool render_audio = (viewer->playing || rendering); bool loop = false; @@ -883,7 +883,7 @@ void ViewerWidget::paintGL() { drawTitleSafeArea(); } - if (gizmos != NULL && drawn_gizmos) { + if (gizmos != nullptr && drawn_gizmos) { float color[4]; glGetFloatv(GL_CURRENT_COLOR, color);