View Issue Details

IDProjectCategoryView StatusLast Update
0019821LazarusPatchpublic2011-07-29 14:08
ReporterBart BroersmaAssigned ToMaxim Ganetsky 
PrioritynormalSeverityminorReproducibilityhave not tried
Status closedResolutionfixed 
Platformi386OSWinMeOS VersionMS
Product Version0.9.30.1 (SVN)Product Build31810 
Target Version0.9.31 (SVN)Fixed in Version0.9.31 (SVN) 
Summary0019821: CreateMessageDialog: minor patch (code cleanup)
DescriptionRemoved (local variable) aCaption, which was uninitialized, in the call to TPromptDialog.CreateMessageDialog() and replaced it with a blank (''), thus not relying on the fact that the compiler would initialize aCaption to ''.
TagsNo tags attached.
Fixed in Revision31819
LazTarget-
WidgetsetGTK, GTK 2, Win32/Win64, WinCE, Carbon, Cocoa, QT, fpGUI
Attached Files
  • createmessagedlg.diff (834 bytes)
    Index: lcl/include/promptdialog.inc
    ===================================================================
    --- lcl/include/promptdialog.inc	(revision 31810)
    +++ lcl/include/promptdialog.inc	(working copy)
    @@ -503,12 +503,11 @@
     function CreateMessageDialog(const Msg: string; DlgType: TMsgDlgType; Buttons: TMsgDlgButtons): TForm;
     var
       PDlg: TPromptDialog;
    -  aCaption: String;
       Btns: PLongInt;
       CancelValue, DefaultIndex, ButtonCount: Longint;
     begin
       Btns := GetPromptUserButtons(Buttons, CancelValue, DefaultIndex, ButtonCount, False, mbOk);
    -  PDlg := TPromptDialog.CreateMessageDialog(aCaption, Msg, DialogIds[DlgType], Btns, ButtonCount, DefaultIndex);
    +  PDlg := TPromptDialog.CreateMessageDialog('', Msg, DialogIds[DlgType], Btns, ButtonCount, DefaultIndex);
       Result := TForm(PDlg);
       ReallocMem(Btns, 0);
     end;
    
    createmessagedlg.diff (834 bytes)

Activities

2011-07-27 15:06

 

createmessagedlg.diff (834 bytes)
Index: lcl/include/promptdialog.inc
===================================================================
--- lcl/include/promptdialog.inc	(revision 31810)
+++ lcl/include/promptdialog.inc	(working copy)
@@ -503,12 +503,11 @@
 function CreateMessageDialog(const Msg: string; DlgType: TMsgDlgType; Buttons: TMsgDlgButtons): TForm;
 var
   PDlg: TPromptDialog;
-  aCaption: String;
   Btns: PLongInt;
   CancelValue, DefaultIndex, ButtonCount: Longint;
 begin
   Btns := GetPromptUserButtons(Buttons, CancelValue, DefaultIndex, ButtonCount, False, mbOk);
-  PDlg := TPromptDialog.CreateMessageDialog(aCaption, Msg, DialogIds[DlgType], Btns, ButtonCount, DefaultIndex);
+  PDlg := TPromptDialog.CreateMessageDialog('', Msg, DialogIds[DlgType], Btns, ButtonCount, DefaultIndex);
   Result := TForm(PDlg);
   ReallocMem(Btns, 0);
 end;
createmessagedlg.diff (834 bytes)

Maxim Ganetsky

2011-07-27 22:06

developer   ~0050225

What problem does this patch solve?

aCaption initialization is guaranteed by compiler?

Bart Broersma

2011-07-27 22:16

developer   ~0050226

The local var is not necessary, and it gives a compiler warning. At the very least we get rid of this.
Personally I don't like depending on this sort of compiler behaviour.
If you use a var, initialize it.

If you do not agree, just dismiss and close the issue, that's OK with me.

Maxim Ganetsky

2011-07-28 22:48

developer   ~0050242

Applied, thanks.

Issue History

Date Modified Username Field Change
2011-07-27 15:06 Bart Broersma New Issue
2011-07-27 15:06 Bart Broersma Status new => assigned
2011-07-27 15:06 Bart Broersma Assigned To => Bart Broersma
2011-07-27 15:06 Bart Broersma File Added: createmessagedlg.diff
2011-07-27 15:06 Bart Broersma LazTarget => -
2011-07-27 15:06 Bart Broersma Widgetset => GTK, GTK 2, Win32/Win64, WinCE, Carbon, Cocoa, QT, fpGUI
2011-07-27 22:06 Maxim Ganetsky Note Added: 0050225
2011-07-27 22:06 Maxim Ganetsky Assigned To Bart Broersma =>
2011-07-27 22:06 Maxim Ganetsky Status assigned => feedback
2011-07-27 22:16 Bart Broersma Note Added: 0050226
2011-07-28 22:48 Maxim Ganetsky Fixed in Revision => 31819
2011-07-28 22:48 Maxim Ganetsky Status feedback => resolved
2011-07-28 22:48 Maxim Ganetsky Fixed in Version => 0.9.31 (SVN)
2011-07-28 22:48 Maxim Ganetsky Resolution open => fixed
2011-07-28 22:48 Maxim Ganetsky Assigned To => Maxim Ganetsky
2011-07-28 22:48 Maxim Ganetsky Note Added: 0050242
2011-07-29 14:08 Bart Broersma Status resolved => closed