From: Good Guy Date: Sun, 9 Dec 2018 02:27:22 +0000 (-0700) Subject: remove asset while preview active segv fix, guard against segv with missing asset... X-Git-Tag: 2019-08~158 X-Git-Url: https://git.cinelerra-gg.org/git/?a=commitdiff_plain;h=24d62aadcd7a6188aff573aaec22f31e3bba4a57;p=goodguy%2Fcinelerra.git remove asset while preview active segv fix, guard against segv with missing asset index, avoid deadlock with proxy toggle --- diff --git a/cinelerra-5.1/cinelerra/asset.C b/cinelerra-5.1/cinelerra/asset.C index 4f911e98..2856ed5c 100644 --- a/cinelerra-5.1/cinelerra/asset.C +++ b/cinelerra-5.1/cinelerra/asset.C @@ -603,7 +603,8 @@ int Asset::write(FileXML *file, write_audio(file); write_video(file); // index goes after source - if(index_state->index_status == INDEX_READY && include_index) + if( include_index && index_state && + index_state->index_status == INDEX_READY ) write_index(file); file->tag.set_title("/ASSET"); diff --git a/cinelerra-5.1/cinelerra/assetpopup.C b/cinelerra-5.1/cinelerra/assetpopup.C index f7961c7d..102c803c 100644 --- a/cinelerra-5.1/cinelerra/assetpopup.C +++ b/cinelerra-5.1/cinelerra/assetpopup.C @@ -359,9 +359,11 @@ AssetPopupProjectRemove::~AssetPopupProjectRemove() int AssetPopupProjectRemove::handle_event() { + popup->gui->unlock_window(); mwindow->remove_assets_from_project(1, 1, mwindow->session->drag_assets, mwindow->session->drag_clips); + popup->gui->lock_window("AssetPopupProjectRemove::handle_event"); return 1; } diff --git a/cinelerra-5.1/cinelerra/awindowgui.C b/cinelerra-5.1/cinelerra/awindowgui.C index b370b2c3..45954b76 100644 --- a/cinelerra-5.1/cinelerra/awindowgui.C +++ b/cinelerra-5.1/cinelerra/awindowgui.C @@ -547,10 +547,22 @@ AssetVIconThread::AssetVIconThread(AWindowGUI *gui, Preferences *preferences) case VICON_COLOR_MODE_HIGH: vicon_cmodel = BC_RGB888; break; } this->vicon_cmodel = vicon_cmodel; + this->draw_lock = new Mutex("AssetVIconThread::draw_lock"); } AssetVIconThread::~AssetVIconThread() { + delete draw_lock; +} + +void AssetVIconThread::drawing_started() +{ + draw_lock->lock("AssetVIconThread::drawing_started"); +} + +void AssetVIconThread::drawing_stopped() +{ + draw_lock->unlock(); } void AssetVIconThread::set_view_popup(AssetVIcon *v, int draw_mode) diff --git a/cinelerra-5.1/cinelerra/awindowgui.h b/cinelerra-5.1/cinelerra/awindowgui.h index 388ae622..13ccda90 100644 --- a/cinelerra-5.1/cinelerra/awindowgui.h +++ b/cinelerra-5.1/cinelerra/awindowgui.h @@ -194,10 +194,13 @@ public: void set_view_popup(AssetVIcon *v, int draw_mode=-1); ViewPopup *new_view_window(); + void drawing_started(); + void drawing_stopped(); AWindowGUI *gui; int draw_mode; int vicon_cmodel; + Mutex *draw_lock; }; diff --git a/cinelerra-5.1/cinelerra/mwindow.C b/cinelerra-5.1/cinelerra/mwindow.C index 07035302..5fde46cc 100644 --- a/cinelerra-5.1/cinelerra/mwindow.C +++ b/cinelerra-5.1/cinelerra/mwindow.C @@ -120,6 +120,7 @@ #include "vframe.h" #include "vtrack.h" #include "versioninfo.h" +#include "vicon.h" #include "videodevice.inc" #include "videowindow.h" #include "vplayback.h" @@ -4010,6 +4011,10 @@ void MWindow::remove_asset_from_caches(Asset *asset) void MWindow::remove_assets_from_project(int push_undo, int redraw, ArrayList *drag_assets, ArrayList *drag_clips) { + awindow->gui->vicon_thread->stop_drawing(); + awindow->gui->vicon_thread->drawing_started(); // waits for draw lock + awindow->gui->vicon_thread->drawing_stopped(); + for(int i = 0; i < drag_assets->total; i++) { Indexable *indexable = drag_assets->get(i); if(indexable->is_asset) remove_asset_from_caches((Asset*)indexable); diff --git a/cinelerra-5.1/cinelerra/mwindowgui.C b/cinelerra-5.1/cinelerra/mwindowgui.C index 36532ac7..d121f29e 100644 --- a/cinelerra-5.1/cinelerra/mwindowgui.C +++ b/cinelerra-5.1/cinelerra/mwindowgui.C @@ -2404,10 +2404,12 @@ ProxyToggle::~ProxyToggle() int ProxyToggle::handle_event() { int disabled = get_value(); + mwindow->gui->unlock_window(); if( disabled ) mwindow->disable_proxy(); else mwindow->enable_proxy(); + mwindow->gui->lock_window("ProxyToggle::handle_event"); set_tooltip(!disabled ? _("Disable proxy") : _("Enable proxy")); return 1; }