mirror of
https://github.com/hyprwm/Hyprland
synced 2024-12-18 23:49:50 +01:00
core: fix crash on monitor removed with gammaControl (#7601)
* fix crash on monitor removed with gammaControl * Update GammaControl.cpp
This commit is contained in:
parent
cac59fefec
commit
a6315b0af4
2 changed files with 8 additions and 8 deletions
|
@ -17,7 +17,7 @@ CGammaControl::CGammaControl(SP<CZwlrGammaControlV1> resource_, wl_resource* out
|
|||
return;
|
||||
}
|
||||
|
||||
pMonitor = OUTPUTRES->monitor.get();
|
||||
pMonitor = OUTPUTRES->monitor;
|
||||
|
||||
if (!pMonitor) {
|
||||
LOGM(ERR, "No CMonitor");
|
||||
|
@ -103,7 +103,7 @@ CGammaControl::CGammaControl(SP<CZwlrGammaControlV1> resource_, wl_resource* out
|
|||
resource->sendGammaSize(gammaSize);
|
||||
|
||||
listeners.monitorDestroy = pMonitor->events.destroy.registerListener([this](std::any) { this->onMonitorDestroy(); });
|
||||
listeners.monitorDisconnect = pMonitor->events.destroy.registerListener([this](std::any) { this->onMonitorDestroy(); });
|
||||
listeners.monitorDisconnect = pMonitor->events.disconnect.registerListener([this](std::any) { this->onMonitorDestroy(); });
|
||||
}
|
||||
|
||||
CGammaControl::~CGammaControl() {
|
||||
|
@ -119,7 +119,7 @@ bool CGammaControl::good() {
|
|||
}
|
||||
|
||||
void CGammaControl::applyToMonitor() {
|
||||
if (!pMonitor)
|
||||
if (!pMonitor || !pMonitor->output)
|
||||
return; // ??
|
||||
|
||||
LOGM(LOG, "setting to monitor {}", pMonitor->szName);
|
||||
|
@ -136,16 +136,16 @@ void CGammaControl::applyToMonitor() {
|
|||
pMonitor->output->state->setGammaLut({});
|
||||
}
|
||||
|
||||
g_pHyprRenderer->damageMonitor(pMonitor);
|
||||
g_pHyprRenderer->damageMonitor(pMonitor.get());
|
||||
}
|
||||
|
||||
CMonitor* CGammaControl::getMonitor() {
|
||||
return pMonitor;
|
||||
return pMonitor ? pMonitor.get() : nullptr;
|
||||
}
|
||||
|
||||
void CGammaControl::onMonitorDestroy() {
|
||||
LOGM(LOG, "Destroying gamma control for {}", pMonitor->szName);
|
||||
resource->sendFailed();
|
||||
pMonitor = nullptr;
|
||||
}
|
||||
|
||||
CGammaControlProtocol::CGammaControlProtocol(const wl_interface* iface, const int& ver, const std::string& name) : IWaylandProtocol(iface, ver, name) {
|
||||
|
@ -187,4 +187,4 @@ void CGammaControlProtocol::applyGammaToState(CMonitor* pMonitor) {
|
|||
g->applyToMonitor();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ class CGammaControl {
|
|||
|
||||
private:
|
||||
SP<CZwlrGammaControlV1> resource;
|
||||
CMonitor* pMonitor = nullptr;
|
||||
WP<CMonitor> pMonitor;
|
||||
size_t gammaSize = 0;
|
||||
bool gammaTableSet = false;
|
||||
std::vector<uint16_t> gammaTable; // [r,g,b]+
|
||||
|
|
Loading…
Reference in a new issue