forked from mia/Aegisub
Fix a crash caused by the video display recieving a paint event before the first video frame is ready
Originally committed to SVN as r5902.
This commit is contained in:
parent
3c9864e888
commit
eb2a6e14fa
1 changed files with 8 additions and 6 deletions
|
@ -105,7 +105,6 @@ VideoDisplay::VideoDisplay(
|
||||||
, viewport_top(0)
|
, viewport_top(0)
|
||||||
, viewport_height(0)
|
, viewport_height(0)
|
||||||
, zoomValue(OPT_GET("Video/Default Zoom")->GetInt() * .125 + .125)
|
, zoomValue(OPT_GET("Video/Default Zoom")->GetInt() * .125 + .125)
|
||||||
, videoOut(new VideoOutGL())
|
|
||||||
, toolBar(visualSubToolBar)
|
, toolBar(visualSubToolBar)
|
||||||
, zoomBox(zoomBox)
|
, zoomBox(zoomBox)
|
||||||
, freeSize(freeSize)
|
, freeSize(freeSize)
|
||||||
|
@ -153,6 +152,9 @@ bool VideoDisplay::InitContext() {
|
||||||
void VideoDisplay::UploadFrameData(FrameReadyEvent &evt) {
|
void VideoDisplay::UploadFrameData(FrameReadyEvent &evt) {
|
||||||
if (!InitContext()) return;
|
if (!InitContext()) return;
|
||||||
|
|
||||||
|
if (!videoOut)
|
||||||
|
videoOut.reset(new VideoOutGL);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
videoOut->UploadFrameData(*evt.frame);
|
videoOut->UploadFrameData(*evt.frame);
|
||||||
}
|
}
|
||||||
|
@ -175,17 +177,17 @@ void VideoDisplay::UploadFrameData(FrameReadyEvent &evt) {
|
||||||
|
|
||||||
void VideoDisplay::OnVideoOpen() {
|
void VideoDisplay::OnVideoOpen() {
|
||||||
if (!con->videoController->IsLoaded()) return;
|
if (!con->videoController->IsLoaded()) return;
|
||||||
if (!tool.get())
|
if (!tool)
|
||||||
cmd::call("video/tool/cross", con);
|
cmd::call("video/tool/cross", con);
|
||||||
UpdateSize();
|
UpdateSize();
|
||||||
con->videoController->JumpToFrame(0);
|
con->videoController->JumpToFrame(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void VideoDisplay::Render() try {
|
void VideoDisplay::Render() try {
|
||||||
if (!InitContext()) return;
|
if (!InitContext() || !con->videoController->IsLoaded() || !videoOut) return;
|
||||||
if (!con->videoController->IsLoaded()) return;
|
|
||||||
assert(wxIsMainThread());
|
if (!viewport_height || !viewport_width)
|
||||||
if (!viewport_height || !viewport_width) UpdateSize();
|
UpdateSize();
|
||||||
|
|
||||||
videoOut->Render(viewport_left, viewport_bottom, viewport_width, viewport_height);
|
videoOut->Render(viewport_left, viewport_bottom, viewport_width, viewport_height);
|
||||||
E(glViewport(0, std::min(viewport_bottom, 0), w, h));
|
E(glViewport(0, std::min(viewport_bottom, 0), w, h));
|
||||||
|
|
Loading…
Reference in a new issue