mirror of
https://github.com/obsproject/obs-studio.git
synced 2026-03-05 07:06:13 -05:00
Fix render issues with main preview widget
- I seem to have fixed ths issues with the main preview widget. It seems you just need to set the right window attributes to stop it from breaking. Though when opengl is enabled, there appears to be a weird background glitch in the Qt stuff -- I'm not entirely sure what's going on. Bug in Qt? Also fixed the layout issues, and the widget now properly resizes and centers in to its parent widget. - Prevent the render loop from accessing data if the data isn't valid. Because obs->data is freed before the graphics stuff, it can cause the graphics to keep trying to query the obs->data.displays_mutex after it had already been destroyed.
This commit is contained in:
@@ -281,28 +281,33 @@ bool OBSBasic::InitAudio()
|
||||
void OBSBasic::ResizePreview(uint32_t cx, uint32_t cy)
|
||||
{
|
||||
double targetAspect, baseAspect;
|
||||
QSize targetSize, newSize;
|
||||
QSize targetSize;
|
||||
int x, y;
|
||||
|
||||
/* resize preview panel to fix to the top section of the window */
|
||||
targetSize = ui->previewContainer->size();
|
||||
targetAspect = double(targetSize.width()) / double(targetSize.height());
|
||||
baseAspect = double(cx) / double(cy);
|
||||
|
||||
if (targetAspect > baseAspect)
|
||||
newSize = QSize(targetSize.height() * baseAspect,
|
||||
targetSize.height());
|
||||
else
|
||||
newSize = QSize(targetSize.width(),
|
||||
targetSize.width() / baseAspect);
|
||||
if (targetAspect > baseAspect) {
|
||||
cx = targetSize.height() * baseAspect;
|
||||
cy = targetSize.height();
|
||||
} else {
|
||||
cx = targetSize.width();
|
||||
cy = targetSize.width() / baseAspect;
|
||||
}
|
||||
|
||||
//ui->preview->resize(newSize);
|
||||
x = targetSize.width() /2 - cx/2;
|
||||
y = targetSize.height()/2 - cy/2;
|
||||
|
||||
ui->preview->setGeometry(x, y, cx, cy);
|
||||
|
||||
graphics_t graphics = obs_graphics();
|
||||
/*if (graphics) {
|
||||
if (graphics && isVisible()) {
|
||||
gs_entercontext(graphics);
|
||||
gs_resize(newSize.width(), newSize.height());
|
||||
gs_resize(cx, cy);
|
||||
gs_leavecontext();
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
||||
void OBSBasic::closeEvent(QCloseEvent *event)
|
||||
|
||||
Reference in New Issue
Block a user