Bug 354534 - kscreen-console MUST NOT use qDebug for output
Summary: kscreen-console MUST NOT use qDebug for output
Status: RESOLVED FIXED
Alias: None
Product: KScreen
Classification: Plasma
Component: common (show other bugs)
Version: 5.4.2
Platform: openSUSE Linux
: NOR normal
Target Milestone: ---
Assignee: Daniel Vrátil
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-10-29 06:43 UTC by Thiago Macieira
Modified: 2017-04-05 21:44 UTC (History)
4 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
Fix the formatting by converting the json document to std::string and write it to std::cout. (658 bytes, patch)
2016-11-26 16:42 UTC, Jan-Matthias Braun
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Thiago Macieira 2015-10-29 06:43:24 UTC
Just don't. It's not meant for formatted output.

Reproducible: Always

Steps to Reproduce:
1. Run kscreen-console json


Actual Results:  
Garbled output is shown, not JSON

Expected Results:  
JSON is shown

This is what the output looks like:

"{\n    \"outputs\": [\n        {\n            \"clones\": [\n            ],\n            \"connected\": true,\n            \"currentModeId\": \"72\",\n            \"enabled\": true,\n            \"icon\": \"\",\n            \"id\": 67,\n            \"modes\": [\n                {\n                    \"id\": \"237\",\n                    \"name\": \"\",\n                    \"refreshRate\": 47.999099731445312,\n                    \"size\": {\n                        \"height\": 1080,\n                        \"width\": 1920\n                    }\n                },\n                {\n                    \"id\": \"238\",\n                    \"name\": \"\",\n                    \"refreshRate\": 59.975616455078125,\n                    \"size\": {\n                        \"height\": 1050,\n                        \"width\": 1400\n                    }\n                },\n                {\n                    \"id\": \"239\",\n                    \"name\": \"\",\n                    \"refreshRate\": 60.019741058349609,\n                    \"size\": {\n                        \"height\": 1024,\n                        \"width\": 1280\n                    }\n                },\n                {\n                    \"id\": \"240\",\n                    \"name\": \"\",\n                    \"refreshRate\": 60,\n                    \"size\": {\n                        \"height\": 960,\n                        \"width\": 1280\n                    }\n                },\n                {\n                    \"id\": \"241\",\n                    \"name\": \"\",\n                    \"refreshRate\": 60.003841400146484,\n                    \"size\": {\n                        \"height\": 768,\n                        \"width\": 1024\n                    }\n                },\n                {\n                    \"id\": \"242\",\n                    \"name\": \"\",\n                    \"refreshRate\": 60.316539764404297,\n                    \"size\": {\n                        \"height\": 600,\n                        \"width\": 800\n                    }\n                },\n                {\n                    \"id\": \"243\",\n                    \"name\": \"\",\n                    \"refreshRate\": 56.25,\n                    \"size\": {\n                        \"height\": 600,\n                        \"width\": 800\n                    }\n                },\n                {\n                    \"id\": \"244\",\n                    \"name\": \"\",\n                    \"refreshRate\": 59.940475463867188,\n                    \"size\": {\n                        \"height\": 480,\n                        \"width\": 640\n                    }\n                },\n                {\n                    \"id\": \"72\",\n                    \"name\": \"\",\n                    \"refreshRate\": 60.00103759765625,\n                    \"size\": {\n                        \"height\": 1080,\n                        \"width\": 1920\n                    }\n                }\n            ],\n            \"name\": \"eDP1\",\n            \"pos\": {\n                \"x\": 0,\n                \"y\": 0\n            },\n            \"preferredModes\": [\n                \"72\"\n            ],\n            \"primary\": true,\n            \"rotation\": 1,\n            \"size\": {\n                \"height\": 1080,\n                \"width\": 1920\n            },\n            \"sizeMM\": {\n                \"height\": 165,\n                \"width\": 293\n            },\n            \"type\": 7\n        },\n        {\n            \"clones\": [\n            ],\n            \"connected\": false,\n            \"currentModeId\": \"\",\n            \"enabled\": false,\n            \"icon\": \"\",\n            \"id\": 68,\n            \"modes\": [\n            ],\n            \"name\": \"DP1\",\n            \"pos\": {\n                \"x\": 0,\n                \"y\": 0\n            },\n            \"preferredModes\": [\n            ],\n            \"primary\": false,\n            \"rotation\": 1,\n            \"size\": {\n                \"height\": -1,\n                \"width\": -1\n            },\n            \"sizeMM\": {\n                \"height\": 0,\n                \"width\": 0\n            },\n            \"type\": 0\n        },\n        {\n            \"clones\": [\n                68\n            ],\n            \"connected\": true,\n            \"currentModeId\": \"73\",\n            \"enabled\": true,\n            \"icon\": \"\",\n            \"id\": 69,\n            \"modes\": [\n                {\n                    \"id\": \"239\",\n                    \"name\": \"\",\n                    \"refreshRate\": 60.019741058349609,\n                    \"size\": {\n                        \"height\": 1024,\n                        \"width\": 1280\n                    }\n                },\n                {\n                    \"id\": \"241\",\n                    \"name\": \"\",\n                    \"refreshRate\": 60.003841400146484,\n                    \"size\": {\n                        \"height\": 768,\n                        \"width\": 1024\n                    }\n                },\n                {\n                    \"id\": \"242\",\n                    \"name\": \"\",\n                    \"refreshRate\": 60.316539764404297,\n                    \"size\": {\n                        \"height\": 600,\n                        \"width\": 800\n                    }\n                },\n                {\n                    \"id\": \"244\",\n                    \"name\": \"\",\n                    \"refreshRate\": 59.940475463867188,\n                    \"size\": {\n                        \"height\": 480,\n                        \"width\": 640\n                    }\n                },\n                {\n                    \"id\": \"245\",\n                    \"name\": \"\",\n                    \"refreshRate\": 59.940200805664062,\n                    \"size\": {\n                        \"height\": 1080,\n                        \"width\": 1920\n                    }\n                },\n                {\n                    \"id\": \"246\",\n                    \"name\": \"\",\n                    \"refreshRate\": 30,\n                    \"size\": {\n                        \"height\": 1080,\n                        \"width\": 1920\n                    }\n                },\n                {\n                    \"id\": \"247\",\n                    \"name\": \"\",\n                    \"refreshRate\": 30,\n                    \"size\": {\n                        \"height\": 1080,\n                        \"width\": 1920\n                    }\n                },\n                {\n                    \"id\": \"248\",\n                    \"name\": \"\",\n                    \"refreshRate\": 24,\n                    \"size\": {\n                        \"height\": 1080,\n                        \"width\": 1920\n                    }\n                },\n                {\n                    \"id\": \"249\",\n                    \"name\": \"\",\n                    \"refreshRate\": 29.970100402832031,\n                    \"size\": {\n                        \"height\": 1080,\n                        \"width\": 1920\n                    }\n                },\n                {\n                    \"id\": \"250\",\n                    \"name\": \"\",\n                    \"refreshRate\": 29.970100402832031,\n                    \"size\": {\n                        \"height\": 1080,\n                        \"width\": 1920\n                    }\n                },\n                {\n                    \"id\": \"251\",\n                    \"name\": \"\",\n                    \"refreshRate\": 23.976079940795898,\n                    \"size\": {\n                        \"height\": 1080,\n                        \"width\": 1920\n                    }\n                },\n                {\n                    \"id\": \"252\",\n                    \"name\": \"\",\n                    \"refreshRate\": 59.883251190185547,\n                    \"size\": {\n                        \"height\": 1050,\n                        \"width\": 1680\n                    }\n                },\n                {\n                    \"id\": \"253\",\n                    \"name\": \"\",\n                    \"refreshRate\": 60,\n                    \"size\": {\n                        \"height\": 900,\n                        \"width\": 1600\n                    }\n                },\n                {\n                    \"id\": \"254\",\n                    \"name\": \"\",\n                    \"refreshRate\": 75.024673461914062,\n                    \"size\": {\n                        \"height\": 1024,\n                        \"width\": 1280\n                    }\n                },\n                {\n                    \"id\": \"255\",\n                    \"name\": \"\",\n                    \"refreshRate\": 59.901458740234375,\n                    \"size\": {\n                        \"height\": 900,\n                        \"width\": 1440\n                    }\n                },\n                {\n                    \"id\": \"256\",\n                    \"name\": \"\",\n                    \"refreshRate\": 59.789539337158203,\n                    \"size\": {\n                        \"height\": 768,\n                        \"width\": 1366\n                    }\n                },\n                {\n                    \"id\": \"257\",\n                    \"name\": \"\",\n                    \"refreshRate\": 59.9095458984375,\n                    \"size\": {\n                        \"height\": 800,\n                        \"width\": 1280\n                    }\n                },\n                {\n                    \"id\": \"258\",\n                    \"name\": \"\",\n                    \"refreshRate\": 75,\n                    \"size\": {\n                        \"height\": 864,\n                        \"width\": 1152\n                    }\n                },\n                {\n                    \"id\": \"259\",\n                    \"name\": \"\",\n                    \"refreshRate\": 60,\n                    \"size\": {\n                        \"height\": 720,\n                        \"width\": 1280\n                    }\n                },\n                {\n                    \"id\": \"260\",\n                    \"name\": \"\",\n                    \"refreshRate\": 59.940200805664062,\n                    \"size\": {\n                        \"height\": 720,\n                        \"width\": 1280\n                    }\n                },\n                {\n                    \"id\": \"261\",\n                    \"name\": \"\",\n                    \"refreshRate\": 75.076217651367188,\n                    \"size\": {\n                        \"height\": 768,\n                        \"width\": 1024\n                    }\n                },\n                {\n                    \"id\": \"262\",\n                    \"name\": \"\",\n                    \"refreshRate\": 70.069358825683594,\n                    \"size\": {\n                        \"height\": 768,\n                        \"width\": 1024\n                    }\n                },\n                {\n                    \"id\": \"263\",\n                    \"name\": \"\",\n                    \"refreshRate\": 74.55126953125,\n                    \"size\": {\n                        \"height\": 624,\n                        \"width\": 832\n                    }\n                },\n                {\n                    \"id\": \"264\",\n                    \"name\": \"\",\n                    \"refreshRate\": 72.187568664550781,\n                    \"size\": {\n                        \"height\": 600,\n                        \"width\": 800\n                    }\n                },\n                {\n                    \"id\": \"265\",\n                    \"name\": \"\",\n                    \"refreshRate\": 75,\n                    \"size\": {\n                        \"height\": 600,\n                        \"width\": 800\n                    }\n                },\n                {\n                    \"id\": \"266\",\n                    \"name\": \"\",\n                    \"refreshRate\": 60,\n                    \"size\": {\n                        \"height\": 480,\n                        \"width\": 720\n                    }\n                },\n                {\n                    \"id\": \"267\",\n                    \"name\": \"\",\n                    \"refreshRate\": 59.940059661865234,\n                    \"size\": {\n                        \"height\": 480,\n                        \"width\": 720\n                    }\n                },\n                {\n                    \"id\": \"268\",\n                    \"name\": \"\",\n                    \"refreshRate\": 29.998889923095703,\n                    \"size\": {\n                        \"height\": 480,\n                        \"width\": 720\n                    }\n                },\n                {\n                    \"id\": \"269\",\n                    \"name\": \"\",\n                    \"refreshRate\": 29.970029830932617,\n                    \"size\": {\n                        \"height\": 480,\n                        \"width\": 720\n                    }\n                },\n                {\n                    \"id\": \"270\",\n                    \"name\": \"\",\n                    \"refreshRate\": 75,\n                    \"size\": {\n                        \"height\": 480,\n                        \"width\": 640\n                    }\n                },\n                {\n                    \"id\": \"271\",\n                    \"name\": \"\",\n                    \"refreshRate\": 72.808799743652344,\n                    \"size\": {\n                        \"height\": 480,\n                        \"width\": 640\n                    }\n                },\n                {\n                    \"id\": \"272\",\n                    \"name\": \"\",\n                    \"refreshRate\": 66.666664123535156,\n                    \"size\": {\n                        \"height\": 480,\n                        \"width\": 640\n                    }\n                },\n                {\n                    \"id\": \"273\",\n                    \"name\": \"\",\n                    \"refreshRate\": 60,\n                    \"size\": {\n                        \"height\": 480,\n                        \"width\": 640\n                    }\n                },\n                {\n                    \"id\": \"274\",\n                    \"name\": \"\",\n                    \"refreshRate\": 70.0816650390625,\n                    \"size\": {\n                        \"height\": 400,\n                        \"width\": 720\n                    }\n                },\n                {\n                    \"id\": \"73\",\n                    \"name\": \"\",\n                    \"refreshRate\": 60,\n                    \"size\": {\n                        \"height\": 1080,\n                        \"width\": 1920\n                    }\n                }\n            ],\n            \"name\": \"HDMI1\",\n            \"pos\": {\n                \"x\": 0,\n                \"y\": 0\n            },\n            \"preferredModes\": [\n                \"73\"\n            ],\n            \"primary\": false,\n            \"rotation\": 1,\n            \"size\": {\n                \"height\": 1080,\n                \"width\": 1920\n            },\n            \"sizeMM\": {\n                \"height\": 90,\n                \"width\": 160\n            },\n            \"type\": 0\n        },\n        {\n            \"clones\": [\n            ],\n            \"connected\": false,\n            \"currentModeId\": \"\",\n            \"enabled\": false,\n            \"icon\": \"\",\n            \"id\": 70,\n            \"modes\": [\n            ],\n            \"name\": \"VIRTUAL1\",\n            \"pos\": {\n                \"x\": 0,\n                \"y\": 0\n            },\n            \"preferredModes\": [\n            ],\n            \"primary\": false,\n            \"rotation\": 1,\n            \"size\": {\n                \"height\": -1,\n                \"width\": -1\n            },\n            \"sizeMM\": {\n                \"height\": 0,\n                \"width\": 0\n            },\n            \"type\": 0\n        }\n    ],\n    \"screen\": {\n        \"currentSize\": {\n            \"height\": 1080,\n            \"width\": 1920\n        },\n        \"id\": 4117,\n        \"maxActiveOutputsCount\": 4,\n        \"maxSize\": {\n            \"height\": 32767,\n            \"width\": 32767\n        },\n        \"minSize\": {\n            \"height\": 8,\n            \"width\": 8\n        }\n    }\n}\n"
Comment 1 Jan-Matthias Braun 2016-11-26 16:42:52 UTC
Created attachment 102450 [details]
Fix the formatting by converting the json document to std::string and write it to std::cout.
Comment 2 Christoph Feck 2016-11-29 22:37:55 UTC
The bug triaging team was not sure if this is the right patch and can be applied as is.

If possible, please add a review request for your patch to https://phabricator.kde.org/ or https://reviewboard.kde.org/

These pages make it easier to discuss the patch.
Comment 3 Sebastian Kügler 2016-11-30 10:28:48 UTC
@Jan-Matthias Awesome.

Could you post this patch to phabricator.kde.org, makes it a bit easier to apply, review and discuss for me. Thanks!
Comment 4 Jan-Matthias Braun 2016-11-30 21:13:37 UTC
(In reply to Sebastian Kügler from comment #3)
> @Jan-Matthias Awesome.
> 
> Could you post this patch to phabricator.kde.org, makes it a bit easier to
> apply, review and discuss for me. Thanks!

With best greetings: https://phabricator.kde.org/D3552

Cheers,

Jan
Comment 5 Sebastian Kügler 2016-12-01 11:31:46 UTC
Picking it up on phab, thanks!
Comment 6 Albert Astals Cid 2017-04-05 21:44:27 UTC
Git commit ab1f2c9a3bc491118b51c22b8cfc9a19f1da0116 by Albert Astals Cid, on behalf of Jan-Matthias Braun.
Committed on 05/04/2017 at 21:44.
Pushed by aacid into branch 'master'.

Remove quoting from kscreen-console json-output
Differential Revision: https://phabricator.kde.org/D3552

M  +3    -1    console/console.cpp

https://commits.kde.org/kscreen/ab1f2c9a3bc491118b51c22b8cfc9a19f1da0116