mirror of
https://github.com/obsproject/obs-studio.git
synced 2024-09-20 04:42:18 +02:00
fd502cbd4d
The display context was sometimes created again by a resize event after destruction from `OBSBasic::closeEvent`. That resulted in the display context alive until reaching the destructor of the `OBSQTDisplay` class and caused a crash in `render_display` on macOS. To avoid this, destroy the display context at the event `SurfaceAboutToBeDestroyed` and let not create the display context again.
51 lines
1.2 KiB
C++
51 lines
1.2 KiB
C++
#pragma once
|
|
|
|
#include <QWidget>
|
|
#include <obs.hpp>
|
|
|
|
#define GREY_COLOR_BACKGROUND 0xFF4C4C4C
|
|
|
|
class OBSQTDisplay : public QWidget {
|
|
Q_OBJECT
|
|
Q_PROPERTY(QColor displayBackgroundColor MEMBER backgroundColor READ
|
|
GetDisplayBackgroundColor WRITE
|
|
SetDisplayBackgroundColor)
|
|
|
|
OBSDisplay display;
|
|
bool destroying = false;
|
|
|
|
virtual void paintEvent(QPaintEvent *event) override;
|
|
virtual void moveEvent(QMoveEvent *event) override;
|
|
virtual void resizeEvent(QResizeEvent *event) override;
|
|
virtual bool nativeEvent(const QByteArray &eventType, void *message,
|
|
qintptr *result) override;
|
|
|
|
signals:
|
|
void DisplayCreated(OBSQTDisplay *window);
|
|
void DisplayResized();
|
|
|
|
public:
|
|
OBSQTDisplay(QWidget *parent = nullptr,
|
|
Qt::WindowFlags flags = Qt::WindowFlags());
|
|
~OBSQTDisplay() { display = nullptr; }
|
|
|
|
virtual QPaintEngine *paintEngine() const override;
|
|
|
|
inline obs_display_t *GetDisplay() const { return display; }
|
|
|
|
uint32_t backgroundColor = GREY_COLOR_BACKGROUND;
|
|
|
|
QColor GetDisplayBackgroundColor() const;
|
|
void SetDisplayBackgroundColor(const QColor &color);
|
|
void UpdateDisplayBackgroundColor();
|
|
void CreateDisplay();
|
|
void DestroyDisplay()
|
|
{
|
|
display = nullptr;
|
|
destroying = true;
|
|
};
|
|
|
|
void OnMove();
|
|
void OnDisplayChange();
|
|
};
|