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

View file

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