Fix a memory leak and a minor graphical glitch that sometimes happened to the video slider when switching visual typesetting modes.

Originally committed to SVN as r3709.
This commit is contained in:
Thomas Goyne 2009-10-13 17:28:39 +00:00
parent 389f296b4d
commit 3032c4f883
2 changed files with 7 additions and 24 deletions

View file

@ -103,8 +103,6 @@ BEGIN_EVENT_TABLE(VideoDisplay, wxGLCanvas)
EVT_MENU(VIDEO_MENU_SAVE_SNAPSHOT_RAW,VideoDisplay::OnSaveSnapshotRaw)
END_EVENT_TABLE()
/// Attribute list for gl canvases; set the canvases to doublebuffered rgba with an 8 bit stencil buffer
int attribList[] = { WX_GL_RGBA , WX_GL_DOUBLEBUFFER, WX_GL_STENCIL_SIZE, 8, 0 };
@ -129,10 +127,10 @@ VideoDisplay::VideoDisplay(VideoBox *box, VideoSlider *ControlSlider, wxTextCtrl
, SubsPosition(SubsPosition)
, PositionDisplay(PositionDisplay)
, visual(NULL)
, videoOut(new VideoOutGL())
, box(box)
, freeSize(false)
{
videoOut = new VideoOutGL();
SetCursor(wxNullCursor);
}
@ -192,13 +190,10 @@ void VideoDisplay::SetFrame(int frameNumber) {
// Set the text box for time relative to active subtitle line
SubsPosition->SetValue(wxString::Format(_T("%s%ims; %s%ims"), startSign.c_str(), startOff, endSign.c_str(), endOff));
if (IsShownOnScreen()) {
// Update the visual typesetting tools
if (visual) visual->Refresh();
if (IsShownOnScreen() && visual) visual->Refresh();
// Render the new frame
Render(frameNumber);
}
currentFrame = frameNumber;
}
@ -321,8 +316,6 @@ catch (...) {
VideoContext::Get()->Reset();
}
/// @brief Draw the appropriate overscan masks for the current aspect ratio
void VideoDisplay::DrawTVEffects() {
// Get coordinates
@ -528,8 +521,6 @@ void VideoDisplay::OnCopyToClipboard(wxCommandEvent &event) {
}
}
/// @brief Copy the currently display frame to the clipboard, without subtitles
/// @param event Unused
void VideoDisplay::OnCopyToClipboardRaw(wxCommandEvent &event) {
@ -539,24 +530,18 @@ void VideoDisplay::OnCopyToClipboardRaw(wxCommandEvent &event) {
}
}
/// @brief Save the currently display frame to a file, with subtitles
/// @param event Unused
void VideoDisplay::OnSaveSnapshot(wxCommandEvent &event) {
VideoContext::Get()->SaveSnapshot(false);
}
/// @brief Save the currently display frame to a file, without subtitles
/// @param event Unused
void VideoDisplay::OnSaveSnapshotRaw(wxCommandEvent &event) {
VideoContext::Get()->SaveSnapshot(true);
}
/// @brief Copy coordinates of the mouse to the clipboard
/// @param event Unused
void VideoDisplay::OnCopyCoords(wxCommandEvent &event) {
@ -570,8 +555,6 @@ void VideoDisplay::OnCopyCoords(wxCommandEvent &event) {
}
}
/// @brief Convert mouse coordinates relative to the display to coordinates relative to the video
/// @param x X coordinate
/// @param y Y coordinate
@ -586,8 +569,6 @@ void VideoDisplay::ConvertMouseCoords(int &x,int &y) {
y = (y-dy1)*h/dy2;
}
/// @brief Set the current visual typesetting mode
/// @param mode The new mode
/// @param render Whether the display should be rerendered
@ -621,6 +602,7 @@ void VideoDisplay::SetVisualMode(int mode, bool render) {
// Update size as the new typesetting tool may have changed the subtoolbar size
UpdateSize();
ControlSlider->Refresh(false);
}
if (render) Render();
}

View file

@ -39,6 +39,7 @@
#include <wx/glcanvas.h>
#include <wx/combobox.h>
#include <wx/textctrl.h>
#include <memory>
#endif
@ -124,7 +125,7 @@ private:
VisualTool *visual;
/// The video renderer
VideoOutGL *videoOut;
std::auto_ptr<VideoOutGL> videoOut;
public:
/// The VideoBox this display is contained in