Blob Blame History Raw
commit de38db6b97264a82dca25f7e663ff2e8791bc804
Author: Dan Vrátil <dvratil@redhat.com>
Date:   Tue Apr 1 18:30:24 2014 +0200

    Update XRandROutput after it's disabled so that cache is kept up-to-date
    
    After disabling an output, we have to force-update the XRandROutput, because right
    after that we receive RRNotify_CRTCChange signal for that very output. This is
    propagated to users (like KCM), which then call canBeApplied(). canBeApplied()
    compares the KScreen::Config with the *outdated* XRandRConfig and that leads to
    a crash (because the XRandRConfig still claims that the output is enabled).
    
    By updating the cache right after we disable the output, when KCM calls canBeApplied(),
    it's Config is compared to an up-to-date Config and everything is fine.
    
    REVIEW: 117298

diff --git a/backends/xrandr/xrandrconfig.cpp b/backends/xrandr/xrandrconfig.cpp
index 04b37bd..c28250c 100644
--- a/backends/xrandr/xrandrconfig.cpp
+++ b/backends/xrandr/xrandrconfig.cpp
@@ -507,6 +507,12 @@ bool XRandRConfig::disableOutput(Output* output) const
                  0, 0, None, RR_Rotate_0, NULL, 0);
 
     kDebug(dXndr()) << "XRRSetCrtcConfig() returned" << s;
+
+    // Update the cached output now, otherwise we get RRNotify_CrtcChange notification
+    // for an outdated output, which can lead to a crash.
+    if (s == RRSetConfigSuccess) {
+        m_outputs.value(output->id())->update();
+    }
     return (s == RRSetConfigSuccess);
 }