fixes for errs in nested edl rework, proxy popup delete
authorGood Guy <good1.2guy@gmail.com>
Sat, 17 Mar 2018 21:58:58 +0000 (15:58 -0600)
committerGood Guy <good1.2guy@gmail.com>
Sat, 17 Mar 2018 21:58:58 +0000 (15:58 -0600)
13 files changed:
cinelerra-5.1/cinelerra/clipedls.C
cinelerra-5.1/cinelerra/clipedls.h
cinelerra-5.1/cinelerra/clippopup.C
cinelerra-5.1/cinelerra/edit.C
cinelerra-5.1/cinelerra/edits.C
cinelerra-5.1/cinelerra/edl.C
cinelerra-5.1/cinelerra/edl.h
cinelerra-5.1/cinelerra/indexable.C
cinelerra-5.1/cinelerra/mwindow.C
cinelerra-5.1/cinelerra/mwindowedit.C
cinelerra-5.1/cinelerra/proxypopup.C
cinelerra-5.1/cinelerra/proxypopup.h
cinelerra-5.1/cinelerra/proxypopup.inc

index 52dd7678ea168d41c7d9cc64ad8e434f7292d226..6f384fe8877196077e9833ca74a48e8bb0f0f90a 100644 (file)
@@ -35,7 +35,7 @@ void ClipEDLs::remove_clip(EDL *clip)
 }
 
 
-EDL* ClipEDLs::get_copy(EDL *src)
+EDL* ClipEDLs::get_nested(EDL *src)
 {
        if( !src ) return 0;
        for( int i=0; i<size(); ++i ) {
index 8d4a4f8de12c1de3d1d1d8e0b7ab69b03d6efa2b..e64a0c945c816d3c16c931add8e5b51f18b67878 100644 (file)
@@ -14,7 +14,7 @@ public:
        void add_clip(EDL *clip);
        void remove_clip(EDL *clip);
 // Return copy of the src EDL which belongs to the current object.
-       EDL* get_copy(EDL *src);
+       EDL* get_nested(EDL *src);
        void copy_nested(ClipEDLs &nested);
        EDL* load(char *path);
        void clear();
index ef291f195c3c58e2cc56ac88a4028e9c314412cb..96e60c01eb258eaa537f6fad17a64e634eea614f 100644 (file)
@@ -431,36 +431,33 @@ int ClipPopupNest::handle_event()
        gui->lock_window("ClipPopupNest::handle_event 1");
        if( mwindow->session->drag_clips->total > 0 ) {
                EDL *edl = mwindow->edl;
+               time_t dt;      time(&dt);
+               struct tm dtm;  localtime_r(&dt, &dtm);
+               char path[BCSTRLEN];
+               sprintf(path, _("Nested_%02d%02d%02d-%02d%02d%02d"),
+                       dtm.tm_year+1900, dtm.tm_mon+1, dtm.tm_mday,
+                       dtm.tm_hour, dtm.tm_min, dtm.tm_sec);
                EDL *clip = mwindow->session->drag_clips->values[0];
-               EDL *new_clip = new EDL(edl);
-               new_clip->create_objects();
-               new_clip->copy_all(clip);
+               EDL *nested = edl->new_nested(clip, path);
+               EDL *new_clip = edl->create_nested_clip(nested);
                new_clip->awindow_folder = AW_CLIP_FOLDER;
+                sprintf(new_clip->local_session->clip_icon,
+                        "clip_%02d%02d%02d-%02d%02d%02d.png",
+                        dtm.tm_year+1900, dtm.tm_mon+1, dtm.tm_mday,
+                        dtm.tm_hour, dtm.tm_min, dtm.tm_sec);
                snprintf(new_clip->local_session->clip_title,
                        sizeof(new_clip->local_session->clip_title),
                        _("Nested: %s"), clip->local_session->clip_title);
                strcpy(new_clip->local_session->clip_notes,
                        clip->local_session->clip_notes);
-               time_t dt;      time(&dt);
-               struct tm dtm;  localtime_r(&dt, &dtm);
-               sprintf(new_clip->local_session->clip_icon,
-                       "clip_%02d%02d%02d-%02d%02d%02d.png",
-                       dtm.tm_year+1900, dtm.tm_mon+1, dtm.tm_mday,
-                       dtm.tm_hour, dtm.tm_min, dtm.tm_sec);
-               char path[BCSTRLEN];
-               sprintf(path, _("Nested_%02d%02d%02d-%02d%02d%02d"),
-                       dtm.tm_year+1900, dtm.tm_mon+1, dtm.tm_mday,
-                       dtm.tm_hour, dtm.tm_min, dtm.tm_sec);
-               EDL *clip_edl = edl->new_nested(new_clip, path);
-               new_clip->remove_user();
                int idx = edl->clips.number_of(clip);
                if( idx >= 0 ) {
-                       edl->clips[idx] = clip_edl;
+                       edl->clips[idx] = new_clip;
                        clip->remove_user();
                }
                else
-                       edl->clips.append(clip_edl);
-               mwindow->mainindexes->add_next_asset(0, clip_edl);
+                       edl->clips.append(new_clip);
+               mwindow->mainindexes->add_next_asset(0, nested);
                mwindow->mainindexes->start_build();
                popup->gui->async_update_assets();
        }
index ce2612acfacccd87a13965f8e20cb30be168e4e1..853baf7ef673366e9eebda7167f9d784353018f9 100644 (file)
@@ -241,7 +241,7 @@ int Edit::silence()
 
 void Edit::copy_from(Edit *edit)
 {
-       this->nested_edl = edl->nested_edls.get_copy(edit->nested_edl);
+       this->nested_edl = edl->nested_edls.get_nested(edit->nested_edl);
        this->asset = edl->assets->update(edit->asset);
        this->startsource = edit->startsource;
        this->startproject = edit->startproject;
index d4886476a621eed4b8bd25f095bc8e7a23232105..a79bb171d9ba2f4178f4d5a7b45b54506a4a9a44 100644 (file)
@@ -169,7 +169,7 @@ void Edits::insert_edits(Edits *source_edits,
        {
                EDL *dest_nested_edl = 0;
                if(source_edit->nested_edl)
-                       dest_nested_edl = edl->nested_edls.get_copy(source_edit->nested_edl);
+                       dest_nested_edl = edl->nested_edls.get_nested(source_edit->nested_edl);
 
 // Update Assets
                Asset *dest_asset = 0;
index 55b2caf455b25ef7ee355dfdb61d695e151c11ef..1334e5e7c2d129fed11e33284c16fbe8743e33ad 100644 (file)
@@ -597,36 +597,47 @@ int EDL::copy(double start, double end, int all,
        return 0;
 }
 
-EDL *EDL::get_nested(EDL *nested_edl, const char *path)
+void EDL::copy_indexables(EDL *edl)
 {
-       for( int i=0; i<nested_edls.size(); ++i ) {
-               EDL *dst = nested_edls[i];
-               if( !strcmp(path, dst->path) ) return dst;
+       for( Track *track=edl->tracks->first; track; track=track->next ) {
+               for( Edit *edit=track->edits->first; edit; edit=edit->next ) {
+                       if( edit->asset )
+                               assets->update(edit->asset);
+                       if( edit->nested_edl )
+                               nested_edls.get_nested(edit->nested_edl);
+               }
        }
-       return new_nested(nested_edl, path);
 }
 
-EDL *EDL::new_nested(EDL *nested_edl, const char *path)
+EDL *EDL::new_nested(EDL *edl, const char *path)
+{
+       EDL *nested = new EDL;  // no parent for nested edl
+       nested->create_objects();
+       nested->copy_session(edl);
+       nested->set_path(path);
+       nested->update_index(edl);
+       nested->copy_indexables(edl);
+       nested->tracks->copy_from(edl->tracks);
+       nested_edls.append(nested);
+       return nested;
+}
+
+EDL *EDL::create_nested_clip(EDL *nested)
 {
-       EDL *new_edl = new EDL;  // no parent for nested clip
+       EDL *new_edl = new EDL(this);  // parent for clip edl
        new_edl->create_objects();
-       new_edl->copy_session(this);
-       new_edl->create_nested(nested_edl, path);
+       new_edl->create_nested(nested);
        return new_edl;
 }
 
-void EDL::create_nested(EDL *nested_edl, const char *path)
+void EDL::create_nested(EDL *nested)
 {
-       set_path(path);
-       strcpy(local_session->clip_title, path);
-// save a ref to nested edl for garbage delete
-       EDL *nest = clips.get_copy(nested_edl);
 // Keep frame rate, sample rate, and output size unchanged.
 // Nest all video & audio outputs
        session->video_tracks = 1;
-       session->audio_tracks = nest->session->audio_channels;
+       session->audio_tracks = nested->session->audio_channels;
        create_default_tracks();
-       insert_asset(0, nest, 0, 0, 0);
+       insert_asset(0, nested, 0, 0, 0);
 }
 
 void EDL::retrack()
@@ -1048,7 +1059,7 @@ void EDL::insert_asset(Asset *asset,
        EDL *new_nested_edl = 0;
 
        if( asset ) new_asset = assets->update(asset);
-       if( nested_edl ) new_nested_edl = nested_edls.get_copy(nested_edl);
+       if( nested_edl ) new_nested_edl = nested_edls.get_nested(nested_edl);
 
 // Paste video
        int vtrack = 0;
index 77b7bfd80999e3358d75be905665c9d04caa1332..04170ad18aa45804a51d829b6ca9a2cfe902f04f 100644 (file)
@@ -189,9 +189,10 @@ public:
        int copy(double start, double end, int all,
                const char *closer, FileXML *file,
                const char *output_path, int rewind_it);
-       EDL *get_nested(EDL *nested_edl, const char *path);
-       EDL *new_nested(EDL *nested_edl, const char *path);
-       void create_nested(EDL *nested_edl, const char *path);
+       void copy_indexables(EDL *edl);
+       EDL *new_nested(EDL *edl, const char *path);
+       EDL *create_nested_clip(EDL *nested);
+       void create_nested(EDL *nested);
        void paste_silence(double start, double end,
                int edit_labels /* = 1 */,
                int edit_plugins,
index 1fff3eff0b842e47636ccea3fa9208cce00d5d91..3aacee67348734a697556c9b6f1e9af2266fb1b4 100644 (file)
@@ -64,7 +64,7 @@ void Indexable::update_index(Indexable *src)
        if( index_state == src->index_state ) return;
        if( index_state ) index_state->remove_user();
        index_state = src->index_state;
-       index_state->add_user();
+       if( index_state ) index_state->add_user();
 }
 
 
index a69af4e7642b3907bb2c50f690ebfcdb031d6d99..38e37d2f6e7fe7dc3c64d7f587b5f0c3e0cf7576 100644 (file)
@@ -1961,7 +1961,8 @@ if(debug) printf("MWindow::load_filenames %d\n", __LINE__);
                                nested_edl->create_objects();
                                nested_edl->load_xml(&xml_file, LOAD_ALL);
 //printf("MWindow::load_filenames %p %s\n", nested_edl, nested_edl->project_path);
-                               new_edl->create_nested(nested_edl, filenames->get(i));
+                               new_edl->create_nested(nested_edl);
+                               new_edl->set_path(filenames->get(i));
                                nested_edl->Garbage::remove_user();
                        }
                        else {
index 51f1b4214730aabdcd9cd6e6140b897212153f5e..ca3475edb94716c44e4d2d658f671378b41e2fff 100644 (file)
@@ -1209,7 +1209,8 @@ if( debug ) printf("MWindow::load_assets %d\n", __LINE__);
                new_edl->copy_session(edl);
                if( !indexable->is_asset ) {
                        EDL *nested_edl = (EDL*)indexable;
-                       new_edl->create_nested(nested_edl, indexable->path);
+                       new_edl->create_nested(nested_edl);
+                       new_edl->set_path(indexable->path);
                }
                else {
                        Asset *asset = (Asset*)indexable;
@@ -1557,7 +1558,7 @@ int MWindow::paste_edls(ArrayList<EDL*> *new_edls, int load_mode,
                        edl->add_clip(new_edl->clips[j]);
                }
                for( int j=0; j<new_edl->nested_edls.size(); ++j ) {
-                       edl->nested_edls.get_copy(new_edl->nested_edls[j]);
+                       edl->nested_edls.get_nested(new_edl->nested_edls[j]);
                }
 
                if( new_edl->total_vwindow_edls() ) {
index 225b21bd3db129968f42d682e21c97ffbb9e2136..583f6a57ecbde20baf34994345ca107dd286c8af 100644 (file)
@@ -20,6 +20,7 @@
  */
 
 #include "assetedit.h"
+#include "assetremove.h"
 #include "proxypopup.h"
 #include "awindow.h"
 #include "awindowgui.h"
@@ -57,6 +58,8 @@ ProxyPopup::~ProxyPopup()
 
 void ProxyPopup::create_objects()
 {
+       BC_MenuItem *menu_item;
+       BC_SubMenu *submenu;
        add_item(info = new ProxyPopupInfo(mwindow, this));
        add_item(format = new AWindowListFormat(mwindow, gui));
        add_item(new ProxyPopupSort(mwindow, this));
@@ -64,6 +67,10 @@ void ProxyPopup::create_objects()
        add_item(view_window = new ProxyPopupViewWindow(mwindow, this));
        add_item(new ProxyPopupCopy(mwindow, this));
        add_item(new ProxyPopupPaste(mwindow, this));
+       add_item(menu_item = new BC_MenuItem(_("Remove...")));
+       menu_item->add_submenu(submenu = new BC_SubMenu());
+       submenu->add_submenuitem(new ProxyPopupProjectRemove(mwindow, this));
+       submenu->add_submenuitem(new ProxyPopupDiskRemove(mwindow, this));
 }
 
 void ProxyPopup::paste_assets()
@@ -245,6 +252,48 @@ int ProxyPopupPaste::handle_event()
 }
 
 
+ProxyPopupProjectRemove::ProxyPopupProjectRemove(MWindow *mwindow, ProxyPopup *popup)
+ : BC_MenuItem(_("Remove from project"))
+{
+       this->mwindow = mwindow;
+       this->popup = popup;
+}
+
+ProxyPopupProjectRemove::~ProxyPopupProjectRemove()
+{
+}
+
+int ProxyPopupProjectRemove::handle_event()
+{
+       popup->gui->collect_assets();
+       mwindow->remove_assets_from_project(1, 1,
+               mwindow->session->drag_assets,
+               mwindow->session->drag_clips);
+       return 1;
+}
+
+
+ProxyPopupDiskRemove::ProxyPopupDiskRemove(MWindow *mwindow, ProxyPopup *popup)
+ : BC_MenuItem(_("Remove from disk"))
+{
+       this->mwindow = mwindow;
+       this->popup = popup;
+}
+
+
+ProxyPopupDiskRemove::~ProxyPopupDiskRemove()
+{
+}
+
+int ProxyPopupDiskRemove::handle_event()
+{
+       popup->gui->collect_assets();
+       mwindow->awindow->asset_remove->start();
+       return 1;
+}
+
+
+
 ProxyListMenu::ProxyListMenu(MWindow *mwindow, AWindowGUI *gui)
  : BC_PopupMenu(0, 0, 0, "", 0)
 {
index 3a0798062a0c77c434a13611222e1e7d6720265b..5f03a7933b5f78a704311cdeecfa3d57f469233e 100644 (file)
@@ -126,6 +126,30 @@ public:
        ProxyPopup *popup;
 };
 
+class ProxyPopupProjectRemove : public BC_MenuItem
+{
+public:
+       ProxyPopupProjectRemove(MWindow *mwindow, ProxyPopup *popup);
+       ~ProxyPopupProjectRemove();
+
+       int handle_event();
+
+       MWindow *mwindow;
+       ProxyPopup *popup;
+};
+
+class ProxyPopupDiskRemove : public BC_MenuItem
+{
+public:
+       ProxyPopupDiskRemove(MWindow *mwindow, ProxyPopup *popup);
+       ~ProxyPopupDiskRemove();
+
+       int handle_event();
+
+       MWindow *mwindow;
+       ProxyPopup *popup;
+};
+
 class ProxyListMenu : public BC_PopupMenu
 {
 public:
index e0a544ad55c3a4b3ab0059955530bb360f028eb7..10e42257332438983b80a8adb9d9b3061a1e5d1a 100644 (file)
@@ -28,6 +28,8 @@ class ProxyPopupSort;
 class ProxyPopupView;
 class ProxyPopupViewWindow;
 class ProxyPopupCopy;
+class ProxyPopupProjectRemove;
+class ProxyPopupDiskRemove;
 class ProxyListMenu;
 
 #endif