From 732ce79ef10c58c129a8b9822fad9955a97a153d Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Sat, 14 Jan 2023 22:50:14 +0100 Subject: [PATCH] Use wx_ptr for AutoCropDialog --- src/wx/auto_crop_dialog.h | 7 +++++++ src/wx/content_menu.cc | 6 +----- src/wx/content_menu.h | 5 +++-- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/wx/auto_crop_dialog.h b/src/wx/auto_crop_dialog.h index 6c02acbdd..4ccd681ed 100644 --- a/src/wx/auto_crop_dialog.h +++ b/src/wx/auto_crop_dialog.h @@ -19,6 +19,10 @@ */ +#ifndef DCPOMATIC_AUTO_CROP_DIALOG_H +#define DCPOMATIC_AUTO_CROP_DIALOG_H + + #include "table_dialog.h" #include "lib/crop.h" #include @@ -45,3 +49,6 @@ private: SpinCtrl* _threshold; }; + +#endif + diff --git a/src/wx/content_menu.cc b/src/wx/content_menu.cc index ac7a2b58b..83b84f594 100644 --- a/src/wx/content_menu.cc +++ b/src/wx/content_menu.cc @@ -545,11 +545,7 @@ ContentMenu::auto_crop () auto const crop = guess_crop_for_content (); update_viewer (crop); - if (_auto_crop_dialog) { - _auto_crop_dialog->Destroy(); - _auto_crop_dialog = nullptr; - } - _auto_crop_dialog = new AutoCropDialog (_parent, crop); + _auto_crop_dialog.reset(_parent, crop); _auto_crop_dialog->Show (); /* Update the dialog and view when the crop threshold changes */ diff --git a/src/wx/content_menu.h b/src/wx/content_menu.h index 783a5be04..c750ae852 100644 --- a/src/wx/content_menu.h +++ b/src/wx/content_menu.h @@ -23,7 +23,9 @@ #define DCPOMATIC_CONTENT_MENU_H +#include "auto_crop_dialog.h" #include "timeline_content_view.h" +#include "wx_ptr.h" #include "lib/types.h" #include LIBDCP_DISABLE_WARNINGS @@ -32,7 +34,6 @@ LIBDCP_ENABLE_WARNINGS #include -class AutoCropDialog; class DCPContent; class Film; class FilmViewer; @@ -85,7 +86,7 @@ private: wxMenuItem* _set_dcp_settings; wxMenuItem* _remove; - AutoCropDialog* _auto_crop_dialog = nullptr; + wx_ptr _auto_crop_dialog; boost::signals2::scoped_connection _auto_crop_config_connection; boost::signals2::scoped_connection _auto_crop_viewer_connection; }; -- 2.30.2