From e2ac46b9a4f3afeccf656bf04d4fa6c2a8e69a77 Mon Sep 17 00:00:00 2001
From: Rene Brun <Rene.Brun@cern.ch>
Date: Mon, 17 Nov 2008 11:00:01 +0000
Subject: [PATCH] From David Maline  The TGInputDialog class documentation has
 been improved, specially to avoid the user calling the constructor with
 uninitialized string to retrieve the value of the dialog.

git-svn-id: http://root.cern.ch/svn/root/trunk@26223 27541ba8-7e3a-0410-8455-c3a389f83636
---
 gui/gui/src/TGInputDialog.cxx | 24 +++++++++++++++++++++---
 1 file changed, 21 insertions(+), 3 deletions(-)

diff --git a/gui/gui/src/TGInputDialog.cxx b/gui/gui/src/TGInputDialog.cxx
index 3d13a37db06..361cdf4c12c 100644
--- a/gui/gui/src/TGInputDialog.cxx
+++ b/gui/gui/src/TGInputDialog.cxx
@@ -31,7 +31,22 @@ TGInputDialog::TGInputDialog(const TGWindow *p, const TGWindow *main,
                              char *retstr, UInt_t options) :
       TGTransientFrame(p, main, 10, 10, options)
 {
-   // Create simple input dialog.
+   /** Create simple input dialog.  
+
+   It is important to know that the case where the constructor in
+   which all the variables are initialized to their default values is
+   only used for the TBrowser to inspect on the classes. For normal
+   use the only variable that should be free is options.
+
+   Variables prompt, defval are the content of the input dialog while
+   retstr has to be initialized to a char[256]. In case these are not
+   initialized, they will show default values while retstr will be
+   automatically allocated by the dialog. However this will make
+   impossible to retrieve the value entered by the dialog.
+
+   To see TGInputDialog in use see:
+   $ROOTSYS/tutorials/testInputDialog.cxx
+   */
 
    if (!p && !main) {
       MakeZombie();
@@ -39,10 +54,10 @@ TGInputDialog::TGInputDialog(const TGWindow *p, const TGWindow *main,
    }
    SetCleanup(kDeepCleanup);
    // create prompt label and textentry widget
-   fLabel = new TGLabel(this, prompt);
+   fLabel = new TGLabel(this, prompt?prompt:"Introduce value:");
 
    TGTextBuffer *tbuf = new TGTextBuffer(256);  //will be deleted by TGtextEntry
-   tbuf->AddText(0, defval);
+   tbuf->AddText(0, defval?defval:"");
 
    fTE = new TGTextEntry(this, tbuf);
    fTE->Resize(260, fTE->GetDefaultHeight());
@@ -103,6 +118,9 @@ TGInputDialog::TGInputDialog(const TGWindow *p, const TGWindow *main,
    MapWindow();
    fTE->SetFocus();
 
+   if (retstr == 0)
+      retstr = new char[256];
+
    fRetStr = retstr;
 
    gClient->WaitFor(this);
-- 
GitLab