Bug 63517 - Extra lines in kdialog output
Summary: Extra lines in kdialog output
Status: RESOLVED FIXED
Alias: None
Product: kdialog
Classification: Applications
Component: general (show other bugs)
Version: unspecified
Platform: Compiled Sources Linux
: NOR wishlist
Target Milestone: ---
Assignee: David Faure
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-08-31 14:43 UTC by Brad Hards
Modified: 2003-09-01 17:10 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments
fixes for blank lines for --menu and --checklist (2.10 KB, patch)
2003-08-31 14:46 UTC, Brad Hards
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Brad Hards 2003-08-31 14:43:14 UTC
Version:            (using KDE Devel)
Installed from:    Compiled sources
Compiler:          gcc version 3.2 (Mandrake Linux 9.0 3.2-1mdk) 
OS:          Linux

When using --menu (there is already a testcase for this in kdebase/kdialog/test), if you press cancel, you get a blank line (carriage return).

Similarly, when using --checklist without --separate-output, and without any defaults, you get a blank line if you press OK. Note that it is fine if you use --separate-output

I think that in each case, you should get no output - the semantics of "no selection" are the same, and the output should be null, not a carriage return.

Note that you _could_ construct a script that relies on the --checklist behaviour, so I'm not so sure it is a good idea to change it, even if it is wrong (Script Incompatible Change?).
Comment 1 Brad Hards 2003-08-31 14:46:48 UTC
Created attachment 2341 [details]
fixes for blank lines for --menu and --checklist

Per original report, second part of change could break existing scripts.
Comment 2 David Faure 2003-09-01 17:10:21 UTC
Subject: kdebase/kdialog

CVS commit by faure: 

Fix for "When using --menu, if you press cancel you get a blank line"
Patch by Brad Hards <bhards@bigpond.net.au> - thanks!
CCMAIL: 63517-done@bugs.kde.org


  M +6 -2      kdialog.cpp   1.16


--- kdebase/kdialog/kdialog.cpp  #1.15:1.16
@@ -281,5 +281,7 @@ int directCommand(KCmdLineArgs *args)
             QString result;
             bool retcode = Widgets::listBox(0, title, text, list, result);
+            if (1 == retcode) { // OK was selected
             cout << result.local8Bit().data() << endl;
+            }
             return retcode ? 0 : 1;
         }
@@ -302,5 +304,7 @@ int directCommand(KCmdLineArgs *args)
             unsigned int i;
             for (i=0; i<result.count(); i++)
+                if (!result[i].local8Bit().isEmpty()) {
                 cout << result[i].local8Bit().data() << endl;
+                }
             exit( retcode ? 0 : 1 );
         }