Use wx_ptr for AutoCropDialog
authorCarl Hetherington <cth@carlh.net>
Sat, 14 Jan 2023 21:50:14 +0000 (22:50 +0100)
committerCarl Hetherington <cth@carlh.net>
Sat, 14 Jan 2023 21:50:14 +0000 (22:50 +0100)
src/wx/auto_crop_dialog.h
src/wx/content_menu.cc
src/wx/content_menu.h

index 6c02acbdd9e8535cc8e206aea24386cb72676d9e..4ccd681edfde3c91c3fcfc9a333b8370989d0f35 100644 (file)
 */
 
 
+#ifndef DCPOMATIC_AUTO_CROP_DIALOG_H
+#define DCPOMATIC_AUTO_CROP_DIALOG_H
+
+
 #include "table_dialog.h"
 #include "lib/crop.h"
 #include <boost/signals2.hpp>
@@ -45,3 +49,6 @@ private:
        SpinCtrl* _threshold;
 };
 
+
+#endif
+
index ac7a2b58b44d13bf071e8d6055b8919b5d334f70..83b84f5947e41161a1cacdc86546ea0925309580 100644 (file)
@@ -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 */
index 783a5be04067c83ff524f2b35888eb8c1dc73e88..c750ae852d982c6f327cee7fbafc4f0dc4b17f53 100644 (file)
@@ -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 <dcp/warnings.h>
 LIBDCP_DISABLE_WARNINGS
@@ -32,7 +34,6 @@ LIBDCP_ENABLE_WARNINGS
 #include <memory>
 
 
-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<AutoCropDialog> _auto_crop_dialog;
        boost::signals2::scoped_connection _auto_crop_config_connection;
        boost::signals2::scoped_connection _auto_crop_viewer_connection;
 };