Bug 354120 - kcm_sddm AdvanceConfig Autologin save freeze
Summary: kcm_sddm AdvanceConfig Autologin save freeze
Status: RESOLVED FIXED
Alias: None
Product: systemsettings
Classification: Applications
Component: kcm_sddm (show other bugs)
Version: unspecified
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: David Edmundson
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-10-20 07:51 UTC by Leslie Zhai
Modified: 2015-10-28 05:50 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Leslie Zhai 2015-10-20 07:51:32 UTC
KAuth saveAction issue?
https://projects.kde.org/projects/kde/workspace/sddm-kcm/repository/revisions/master/entry/src/sddmkcm.cpp#L80

  PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND                            
 9253 lesliez+  20   0  985200 123064  69516 R 100.0  1.5   0:21.97 kcmshell5

Qt5: 5.5.1
KF5: 5.15.0

Reproducible: Always

Steps to Reproduce:
1. kcmshell5 kcm_sddm
2. click Advanced, checked Autologin
3. click apply, then kcm_sddm freeze
Comment 1 Leslie Zhai 2015-10-20 08:33:03 UTC
/usr/share/polkit-1/rules.d/sddm.rules

polkit.addRule(function(action, subject) {
    if (action.id == "org.kde.kcontrol.kcmsddm.save" &&
        subject.isInGroup("wheel") && subject.active) {
        return polkit.Result.YES;
    }
});
Comment 2 Leslie Zhai 2015-10-20 08:58:29 UTC
https://projects.kde.org/projects/frameworks/kcoreaddons/repository/revisions/master/entry/src/lib/jobs/kjob.h#L243

the synchronous job->exec() might block, so I just simply change it to asynchronous one:

diff --git a/src/sddmkcm.cpp b/src/sddmkcm.cpp
index be07230..7e56727 100644
--- a/src/sddmkcm.cpp
+++ b/src/sddmkcm.cpp
@@ -83,17 +83,17 @@ void SddmKcm::save()
     saveAction.setArguments(args);
     
     auto job = saveAction.execute();
-    job->exec();
-
-    if (job->error()){
-        qDebug() << "Save Failed";
-        qDebug() << job->errorString();
-        qDebug() << job->errorText();
-    } else {
-        changed(false);
-        qDebug() << "Option saved";
-    }
-    
+    connect(job, &KJob::result, [this](KJob *job){
+                if (job->error()) {
+                    qDebug() << "Save Failed";
+                    qDebug() << job->errorString();
+                    qDebug() << job->errorText();
+                } else {
+                    changed(false);
+                    qDebug() << "Option saved";
+                }
+            });
+    job->start();
 }
 
 void SddmKcm::prepareUi()
Comment 3 Leslie Zhai 2015-10-20 09:04:39 UTC
Git commit e5e4c3507c20adf9b3d61efaa9c0ef0698919e43 by Leslie Zhai.
Committed on 20/10/2015 at 09:03.
Pushed by lesliezhai into branch 'asynchronous-save'.

Use KJob asynchronous instead of exec()

M  +14   -11   src/sddmkcm.cpp

http://commits.kde.org/sddm-kcm/e5e4c3507c20adf9b3d61efaa9c0ef0698919e43
Comment 4 Bhushan Shah 2015-10-20 09:17:10 UTC
I believe you pushed it into wrong branch?
Comment 5 Leslie Zhai 2015-10-28 05:27:38 UTC
Hi Bhushan,

sorry that, Martin told me to upload my patches to http://git.reviewboard.kde.org for review at first, sorry for my mistake ;-(
Comment 6 Leslie Zhai 2015-10-28 05:50:35 UTC
Hi David && Bhushan,

Could you review this? thanks a lot!
https://git.reviewboard.kde.org/r/125832/