Replace most remaining uses of std::auto_ptr with agi::scoped_ptr
Originally committed to SVN as r6604.
This commit is contained in:
parent
55f9ccc18d
commit
2840fc0aea
8 changed files with 42 additions and 62 deletions
|
@ -41,6 +41,8 @@
|
||||||
#include "ass_file.h"
|
#include "ass_file.h"
|
||||||
#include "include/aegisub/context.h"
|
#include "include/aegisub/context.h"
|
||||||
|
|
||||||
|
#include <libaegisub/scoped_ptr.h>
|
||||||
|
|
||||||
#ifndef AGI_PRE
|
#ifndef AGI_PRE
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#endif
|
#endif
|
||||||
|
@ -115,7 +117,7 @@ AssFile *AssExporter::ExportTransform(wxWindow *export_dialog, bool copy) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void AssExporter::Export(wxString const& filename, wxString const& charset, wxWindow *export_dialog) {
|
void AssExporter::Export(wxString const& filename, wxString const& charset, wxWindow *export_dialog) {
|
||||||
std::auto_ptr<AssFile> subs(ExportTransform(export_dialog, true));
|
agi::scoped_ptr<AssFile> subs(ExportTransform(export_dialog, true));
|
||||||
subs->Save(filename, false, false, charset);
|
subs->Save(filename, false, false, charset);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -36,8 +36,6 @@
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#include <libaegisub/background_runner.h>
|
|
||||||
|
|
||||||
#include "audio_provider_ram.h"
|
#include "audio_provider_ram.h"
|
||||||
|
|
||||||
#include "audio_controller.h"
|
#include "audio_controller.h"
|
||||||
|
@ -45,12 +43,15 @@
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
|
||||||
|
#include <libaegisub/background_runner.h>
|
||||||
|
#include <libaegisub/scoped_ptr.h>
|
||||||
|
|
||||||
#define CacheBits ((22))
|
#define CacheBits ((22))
|
||||||
|
|
||||||
#define CacheBlockSize ((1 << CacheBits))
|
#define CacheBlockSize ((1 << CacheBits))
|
||||||
|
|
||||||
RAMAudioProvider::RAMAudioProvider(AudioProvider *src, agi::BackgroundRunner *br) {
|
RAMAudioProvider::RAMAudioProvider(AudioProvider *src, agi::BackgroundRunner *br) {
|
||||||
std::auto_ptr<AudioProvider> source(src);
|
agi::scoped_ptr<AudioProvider> source(src);
|
||||||
|
|
||||||
samples_native_endian = source->AreSamplesNativeEndian();
|
samples_native_endian = source->AreSamplesNativeEndian();
|
||||||
|
|
||||||
|
|
|
@ -336,7 +336,7 @@ DialogStyleEditor::DialogStyleEditor(wxWindow *parent, AssStyle *style, agi::Con
|
||||||
if (!SubtitlesProviderFactory::GetClasses().empty()) {
|
if (!SubtitlesProviderFactory::GetClasses().empty()) {
|
||||||
PreviewText = new wxTextCtrl(this, -1, lagi_wxString(OPT_GET("Tool/Style Editor/Preview Text")->GetString()));
|
PreviewText = new wxTextCtrl(this, -1, lagi_wxString(OPT_GET("Tool/Style Editor/Preview Text")->GetString()));
|
||||||
previewButton = new ColourButton(this, -1, wxSize(45, 16), lagi_wxColour(OPT_GET("Colour/Style Editor/Background/Preview")->GetColour()));
|
previewButton = new ColourButton(this, -1, wxSize(45, 16), lagi_wxColour(OPT_GET("Colour/Style Editor/Background/Preview")->GetColour()));
|
||||||
SubsPreview = new SubtitlesPreview(this, -1, wxDefaultPosition, wxSize(100, 60), wxSUNKEN_BORDER, lagi_wxColour(OPT_GET("Colour/Style Editor/Background/Preview")->GetColour()));
|
SubsPreview = new SubtitlesPreview(this, wxSize(100, 60), wxSUNKEN_BORDER, lagi_wxColour(OPT_GET("Colour/Style Editor/Background/Preview")->GetColour()));
|
||||||
|
|
||||||
SubsPreview->SetToolTip(_("Preview of current style"));
|
SubsPreview->SetToolTip(_("Preview of current style"));
|
||||||
SubsPreview->SetStyle(*style);
|
SubsPreview->SetStyle(*style);
|
||||||
|
|
|
@ -50,17 +50,8 @@
|
||||||
#include "include/aegisub/subtitles_provider.h"
|
#include "include/aegisub/subtitles_provider.h"
|
||||||
#include "video_provider_dummy.h"
|
#include "video_provider_dummy.h"
|
||||||
|
|
||||||
|
SubtitlesPreview::SubtitlesPreview(wxWindow *parent, wxSize size, int winStyle, wxColour col)
|
||||||
/// @brief Constructor
|
: wxWindow(parent, -1, wxDefaultPosition, size, winStyle)
|
||||||
/// @param parent
|
|
||||||
/// @param id
|
|
||||||
/// @param pos
|
|
||||||
/// @param size
|
|
||||||
/// @param winStyle
|
|
||||||
/// @param col
|
|
||||||
///
|
|
||||||
SubtitlesPreview::SubtitlesPreview(wxWindow *parent,int id,wxPoint pos,wxSize size,int winStyle,wxColour col)
|
|
||||||
: wxWindow(parent,id,pos,size,winStyle)
|
|
||||||
, style(new AssStyle)
|
, style(new AssStyle)
|
||||||
, backColour(col)
|
, backColour(col)
|
||||||
, subFile(new AssFile)
|
, subFile(new AssFile)
|
||||||
|
@ -78,6 +69,9 @@ SubtitlesPreview::SubtitlesPreview(wxWindow *parent,int id,wxPoint pos,wxSize si
|
||||||
wxSizeEvent evt(size);
|
wxSizeEvent evt(size);
|
||||||
OnSize(evt);
|
OnSize(evt);
|
||||||
UpdateBitmap();
|
UpdateBitmap();
|
||||||
|
|
||||||
|
Bind(wxEVT_PAINT, &SubtitlesPreview::OnPaint, this);
|
||||||
|
Bind(wxEVT_SIZE, &SubtitlesPreview::OnSize, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
SubtitlesPreview::~SubtitlesPreview() {
|
SubtitlesPreview::~SubtitlesPreview() {
|
||||||
|
@ -100,13 +94,21 @@ void SubtitlesPreview::SetText(wxString text) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SubtitlesPreview::SetColour(wxColour col) {
|
||||||
|
if (col != backColour) {
|
||||||
|
backColour = col;
|
||||||
|
vid.reset(new DummyVideoProvider(0.0, 10, bmp->GetWidth(), bmp->GetHeight(), backColour, true));
|
||||||
|
UpdateBitmap();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void SubtitlesPreview::UpdateBitmap() {
|
void SubtitlesPreview::UpdateBitmap() {
|
||||||
if (!vid.get()) return;
|
if (!vid) return;
|
||||||
|
|
||||||
AegiVideoFrame frame;
|
AegiVideoFrame frame;
|
||||||
frame.CopyFrom(vid->GetFrame(0));
|
frame.CopyFrom(vid->GetFrame(0));
|
||||||
|
|
||||||
if (provider.get()) {
|
if (provider) {
|
||||||
try {
|
try {
|
||||||
provider->LoadSubtitles(subFile.get());
|
provider->LoadSubtitles(subFile.get());
|
||||||
provider->DrawSubtitles(frame, 0.1);
|
provider->DrawSubtitles(frame, 0.1);
|
||||||
|
@ -120,14 +122,8 @@ void SubtitlesPreview::UpdateBitmap() {
|
||||||
Refresh();
|
Refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
BEGIN_EVENT_TABLE(SubtitlesPreview,wxWindow)
|
|
||||||
EVT_PAINT(SubtitlesPreview::OnPaint)
|
|
||||||
EVT_SIZE(SubtitlesPreview::OnSize)
|
|
||||||
END_EVENT_TABLE()
|
|
||||||
|
|
||||||
void SubtitlesPreview::OnPaint(wxPaintEvent &) {
|
void SubtitlesPreview::OnPaint(wxPaintEvent &) {
|
||||||
wxPaintDC dc(this);
|
wxPaintDC(this).DrawBitmap(*bmp, 0, 0);
|
||||||
dc.DrawBitmap(*bmp,0,0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SubtitlesPreview::OnSize(wxSizeEvent &evt) {
|
void SubtitlesPreview::OnSize(wxSizeEvent &evt) {
|
||||||
|
@ -148,16 +144,8 @@ void SubtitlesPreview::OnSize(wxSizeEvent &evt) {
|
||||||
"No subtitles provider", wxICON_ERROR | wxOK);
|
"No subtitles provider", wxICON_ERROR | wxOK);
|
||||||
}
|
}
|
||||||
|
|
||||||
subFile->SetScriptInfo("PlayResX", wxString::Format("%i", w));
|
subFile->SetScriptInfo("PlayResX", wxString::Format("%d", w));
|
||||||
subFile->SetScriptInfo("PlayResY", wxString::Format("%i", h));
|
subFile->SetScriptInfo("PlayResY", wxString::Format("%d", h));
|
||||||
|
|
||||||
UpdateBitmap();
|
UpdateBitmap();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SubtitlesPreview::SetColour(wxColour col) {
|
|
||||||
if (col != backColour) {
|
|
||||||
backColour = col;
|
|
||||||
vid.reset(new DummyVideoProvider(0.0, 10, bmp->GetWidth(), bmp->GetHeight(), backColour, true));
|
|
||||||
UpdateBitmap();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -35,11 +35,12 @@
|
||||||
///
|
///
|
||||||
|
|
||||||
#ifndef AGI_PRE
|
#ifndef AGI_PRE
|
||||||
#include <memory>
|
|
||||||
#include <wx/window.h>
|
#include <wx/window.h>
|
||||||
#include <wx/bitmap.h>
|
#include <wx/bitmap.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <libaegisub/scoped_ptr.h>
|
||||||
|
|
||||||
class AssFile;
|
class AssFile;
|
||||||
class AssStyle;
|
class AssStyle;
|
||||||
class SubtitlesProvider;
|
class SubtitlesProvider;
|
||||||
|
@ -49,19 +50,18 @@ class VideoProvider;
|
||||||
/// @class SubtitlesPreview
|
/// @class SubtitlesPreview
|
||||||
/// @brief Preview window to show a short string with a given ass style
|
/// @brief Preview window to show a short string with a given ass style
|
||||||
class SubtitlesPreview : public wxWindow {
|
class SubtitlesPreview : public wxWindow {
|
||||||
private:
|
|
||||||
/// The subtitle provider used to render the string
|
/// The subtitle provider used to render the string
|
||||||
std::auto_ptr<SubtitlesProvider> provider;
|
agi::scoped_ptr<SubtitlesProvider> provider;
|
||||||
/// Bitmap to render into
|
/// Bitmap to render into
|
||||||
std::auto_ptr<wxBitmap> bmp;
|
agi::scoped_ptr<wxBitmap> bmp;
|
||||||
/// The currently display style
|
/// The currently display style
|
||||||
AssStyle* style;
|
AssStyle* style;
|
||||||
/// Video provider to render into
|
/// Video provider to render into
|
||||||
std::auto_ptr<VideoProvider> vid;
|
agi::scoped_ptr<VideoProvider> vid;
|
||||||
/// Current background color
|
/// Current background color
|
||||||
wxColour backColour;
|
wxColour backColour;
|
||||||
/// Subtitle file containing the style and displayed line
|
/// Subtitle file containing the style and displayed line
|
||||||
std::auto_ptr<AssFile> subFile;
|
agi::scoped_ptr<AssFile> subFile;
|
||||||
/// Line used to render the specified text
|
/// Line used to render the specified text
|
||||||
AssDialogue* line;
|
AssDialogue* line;
|
||||||
|
|
||||||
|
@ -80,10 +80,6 @@ public:
|
||||||
/// Set the background color
|
/// Set the background color
|
||||||
void SetColour(wxColour col);
|
void SetColour(wxColour col);
|
||||||
|
|
||||||
void Update() { UpdateBitmap(); }
|
SubtitlesPreview(wxWindow *parent, wxSize size, int style, wxColour colour);
|
||||||
|
|
||||||
SubtitlesPreview(wxWindow *parent,int id,wxPoint pos,wxSize size,int style,wxColour colour);
|
|
||||||
~SubtitlesPreview();
|
~SubtitlesPreview();
|
||||||
|
|
||||||
DECLARE_EVENT_TABLE()
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -54,7 +54,8 @@
|
||||||
///
|
///
|
||||||
TextFileWriter::TextFileWriter(wxString const& filename, wxString encoding)
|
TextFileWriter::TextFileWriter(wxString const& filename, wxString encoding)
|
||||||
: file(new agi::io::Save(STD_STR(filename), true))
|
: file(new agi::io::Save(STD_STR(filename), true))
|
||||||
, conv() {
|
, conv()
|
||||||
|
{
|
||||||
if (encoding.empty()) encoding = lagi_wxString(OPT_GET("App/Save Charset")->GetString());
|
if (encoding.empty()) encoding = lagi_wxString(OPT_GET("App/Save Charset")->GetString());
|
||||||
if (encoding.Lower() != wxSTRING_ENCODING)
|
if (encoding.Lower() != wxSTRING_ENCODING)
|
||||||
conv.reset(new agi::charset::IconvWrapper(wxSTRING_ENCODING, encoding.utf8_str(), true));
|
conv.reset(new agi::charset::IconvWrapper(wxSTRING_ENCODING, encoding.utf8_str(), true));
|
||||||
|
@ -68,17 +69,10 @@ TextFileWriter::TextFileWriter(wxString const& filename, wxString encoding)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// @brief DOCME
|
|
||||||
///
|
|
||||||
TextFileWriter::~TextFileWriter() {
|
TextFileWriter::~TextFileWriter() {
|
||||||
// Explicit empty destructor required with an auto_ptr to an incomplete class
|
// Explicit empty destructor required with an auto_ptr to an incomplete class
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// @brief DOCME
|
|
||||||
/// @param line
|
|
||||||
/// @param addLineBreak
|
|
||||||
void TextFileWriter::WriteLineToFile(wxString line, bool addLineBreak) {
|
void TextFileWriter::WriteLineToFile(wxString line, bool addLineBreak) {
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
if (addLineBreak) line += "\r\n";
|
if (addLineBreak) line += "\r\n";
|
||||||
|
@ -94,7 +88,7 @@ void TextFileWriter::WriteLineToFile(wxString line, bool addLineBreak) {
|
||||||
size_t len = line.length() * sizeof(wxStringCharType);
|
size_t len = line.length() * sizeof(wxStringCharType);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (conv.get()) {
|
if (conv) {
|
||||||
std::string buf = conv->Convert(std::string(data, len));
|
std::string buf = conv->Convert(std::string(data, len));
|
||||||
file->Get().write(buf.data(), buf.size());
|
file->Get().write(buf.data(), buf.size());
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,7 +38,6 @@
|
||||||
|
|
||||||
#ifndef AGI_PRE
|
#ifndef AGI_PRE
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <memory>
|
|
||||||
|
|
||||||
#include <wx/string.h>
|
#include <wx/string.h>
|
||||||
#endif
|
#endif
|
||||||
|
@ -52,6 +51,8 @@ namespace agi {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#include <libaegisub/scoped_ptr.h>
|
||||||
|
|
||||||
|
|
||||||
/// DOCME
|
/// DOCME
|
||||||
/// @class TextFileWriter
|
/// @class TextFileWriter
|
||||||
|
@ -60,13 +61,10 @@ namespace agi {
|
||||||
/// DOCME
|
/// DOCME
|
||||||
class TextFileWriter {
|
class TextFileWriter {
|
||||||
/// DOCME
|
/// DOCME
|
||||||
std::auto_ptr<agi::io::Save> file;
|
agi::scoped_ptr<agi::io::Save> file;
|
||||||
|
|
||||||
/// DOCME
|
/// DOCME
|
||||||
std::auto_ptr<agi::charset::IconvWrapper> conv;
|
agi::scoped_ptr<agi::charset::IconvWrapper> conv;
|
||||||
|
|
||||||
TextFileWriter(const TextFileWriter&);
|
|
||||||
TextFileWriter& operator=(const TextFileWriter&);
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
TextFileWriter(wxString const& filename, wxString encoding="");
|
TextFileWriter(wxString const& filename, wxString encoding="");
|
||||||
|
|
|
@ -44,6 +44,7 @@
|
||||||
#include <wx/stopwatch.h>
|
#include <wx/stopwatch.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <libaegisub/scoped_ptr.h>
|
||||||
#include <libaegisub/signal.h>
|
#include <libaegisub/signal.h>
|
||||||
#include <libaegisub/vfr.h>
|
#include <libaegisub/vfr.h>
|
||||||
|
|
||||||
|
@ -83,7 +84,7 @@ class VideoContext : public wxEvtHandler {
|
||||||
VideoProvider *videoProvider;
|
VideoProvider *videoProvider;
|
||||||
|
|
||||||
/// Asynchronous provider of video frames
|
/// Asynchronous provider of video frames
|
||||||
std::auto_ptr<ThreadedFrameSource> provider;
|
agi::scoped_ptr<ThreadedFrameSource> provider;
|
||||||
|
|
||||||
/// Filename of currently open video
|
/// Filename of currently open video
|
||||||
wxString videoFile;
|
wxString videoFile;
|
||||||
|
|
Loading…
Reference in a new issue