* * *

Author Topic: [SOLVED] Error "List index (0) out of bounds" while opening form in IDE on Linux  (Read 1598 times)

Unvictis

  • New member
  • *
  • Posts: 13
  • Nihil habeo, nihil timeo
Hi, guys! If i open my project in IDE on Windows (XP, 7, 10 - any) its opens normally. If i open same project in Lazarus on my Ubuntu Mate 16.04 x64 desktop, i see error: "List index (0) out of bounds".

Empirically, I found out that this problem occurs when the IDE tries to open the "fDevEditor" in my application. Nothing strange or unusual in the code and file "fDevEditor.lfm" I have not found. Tell me how to solve this problem?

IDE (Windows): Lazarus 1.6.2 (x86)
IDE (Ubuntu 16.04 x64): Lazarus 1.6+dfsg-1 (x86_64-linux-gtk2) [from standart Ubuntu repo]

PS: None of the project files I edited on a straight line - only through IDE.

File fdeveditor.pas:
Code: Pascal  [Select]
  1. unit fDevEditor;
  2.  
  3. {$mode objfpc}{$H+}
  4.  
  5. interface
  6.  
  7. uses
  8.   Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ExtCtrls,
  9.   StdCtrls, DbCtrls, DBGrids, LCLType, uCommon, dOrder;
  10.  
  11. type
  12.  
  13.   { TfmDevEditor }
  14.  
  15.   TfmDevEditor = class(TForm)
  16.     btCancel: TButton;
  17.     btOk: TButton;
  18.     btAddDevice: TButton;
  19.     btDeleteDevice: TButton;
  20.     edNewDevice: TEdit;
  21.     dgDevices: TDBGrid;
  22.     lbNewDevice: TLabel;
  23.     plContents: TPanel;
  24.     plButtonContainer: TPanel;
  25.     procedure btAddDeviceClick(Sender: TObject);
  26.     procedure btDeleteDeviceClick(Sender: TObject);
  27.     procedure edNewDeviceChange(Sender: TObject);
  28.     procedure edNewDeviceKeyDown(Sender: TObject; var Key: Word;
  29.       Shift: TShiftState);
  30.     procedure FormShow(Sender: TObject);
  31.   private
  32.     { private declarations }
  33.   public
  34.     { public declarations }
  35.   end;
  36.  
  37. var
  38.   fmDevEditor: TfmDevEditor;
  39.  
  40. implementation
  41.  
  42. {$R *.lfm}
  43.  
  44. { TfmDevEditor }
  45.  
  46. procedure TfmDevEditor.FormShow(Sender: TObject);
  47. begin
  48.   edNewDevice.Clear;
  49.   btAddDevice.Enabled := False;
  50.   edNewDevice.SetFocus;
  51. end;
  52.  
  53. procedure TfmDevEditor.edNewDeviceChange(Sender: TObject);
  54. begin
  55.   btAddDevice.Enabled := (Length(edNewDevice.Text) >= 2);
  56. end;
  57.  
  58. procedure TfmDevEditor.edNewDeviceKeyDown(Sender: TObject; var Key: Word;
  59.   Shift: TShiftState);
  60. begin
  61.   // Если нажата клавиша "Enter" нажать кнопку "Добавить"
  62.   if (Key = VK_RETURN) and btAddDevice.Enabled then
  63.     btAddDeviceClick(Sender);
  64. end;
  65.  
  66. procedure TfmDevEditor.btAddDeviceClick(Sender: TObject);
  67. begin
  68.   with dmOrder.sqDevice do
  69.     begin
  70.       Insert;
  71.       FieldByName('CREATOR').AsInteger := CurrentUserID;
  72.       FieldByName('EDITOR').AsInteger := CurrentUserID;
  73.       FieldByName('DEVICE').AsString := edNewDevice.Text;
  74.       Post;
  75.     end;
  76.  
  77.   edNewDevice.Clear;
  78. end;
  79.  
  80. procedure TfmDevEditor.btDeleteDeviceClick(Sender: TObject);
  81. begin
  82.   with dmOrder.sqDevice do
  83.     if MessageDlg(cDlgConfirmation, Format(cDlgDeviceDelConfirm,
  84.       [FieldByName('DEVICE').AsString]), mtConfirmation, mbYesNo, 0) = mrYes then
  85.         Delete;
  86. end;
  87.  
  88. end.
  89.  

File fdeveditor.lfm:
Code: Pascal  [Select]
  1. object fmDevEditor: TfmDevEditor
  2.   Left = 324
  3.   Height = 307
  4.   Top = 134
  5.   Width = 281
  6.   BorderStyle = bsDialog
  7.   BorderWidth = 4
  8.   Caption = 'Типы устройств'
  9.   ClientHeight = 307
  10.   ClientWidth = 281
  11.   OnShow = FormShow
  12.   Position = poOwnerFormCenter
  13.   LCLVersion = '1.6.2.0'
  14.   object plButtonContainer: TPanel
  15.     Left = 4
  16.     Height = 25
  17.     Top = 278
  18.     Width = 273
  19.     Align = alBottom
  20.     AutoSize = True
  21.     BorderSpacing.Top = 4
  22.     BevelOuter = bvNone
  23.     ChildSizing.HorizontalSpacing = 4
  24.     ClientHeight = 25
  25.     ClientWidth = 273
  26.     TabOrder = 1
  27.     object btCancel: TButton
  28.       Left = 198
  29.       Height = 25
  30.       Top = 0
  31.       Width = 75
  32.       Align = alRight
  33.       Cancel = True
  34.       Caption = 'Отмена'
  35.       ModalResult = 2
  36.       TabOrder = 1
  37.     end
  38.     object btOk: TButton
  39.       Left = 119
  40.       Height = 25
  41.       Top = 0
  42.       Width = 75
  43.       Align = alRight
  44.       Caption = 'OK'
  45.       Default = True
  46.       ModalResult = 1
  47.       TabOrder = 0
  48.     end
  49.   end
  50.   object plContents: TPanel
  51.     Left = 4
  52.     Height = 270
  53.     Top = 4
  54.     Width = 273
  55.     Align = alClient
  56.     AutoSize = True
  57.     BevelOuter = bvNone
  58.     BorderWidth = 4
  59.     ClientHeight = 270
  60.     ClientWidth = 273
  61.     TabOrder = 0
  62.     object lbNewDevice: TLabel
  63.       AnchorSideLeft.Control = dgDevices
  64.       AnchorSideTop.Control = plContents
  65.       Left = 4
  66.       Height = 15
  67.       Top = 4
  68.       Width = 145
  69.       BorderSpacing.Bottom = 4
  70.       Caption = 'Новый тип оборудования:'
  71.       ParentColor = False
  72.     end
  73.     object btAddDevice: TButton
  74.       AnchorSideTop.Side = asrCenter
  75.       AnchorSideRight.Control = plContents
  76.       AnchorSideRight.Side = asrBottom
  77.       Left = 194
  78.       Height = 25
  79.       Top = 22
  80.       Width = 75
  81.       Anchors = [akTop, akRight]
  82.       BorderSpacing.Bottom = 8
  83.       Caption = 'Добавить'
  84.       Enabled = False
  85.       OnClick = btAddDeviceClick
  86.       TabOrder = 1
  87.     end
  88.     object btDeleteDevice: TButton
  89.       AnchorSideTop.Control = btAddDevice
  90.       AnchorSideTop.Side = asrBottom
  91.       AnchorSideRight.Control = plContents
  92.       AnchorSideRight.Side = asrBottom
  93.       Left = 194
  94.       Height = 25
  95.       Top = 55
  96.       Width = 75
  97.       Anchors = [akTop, akRight]
  98.       BorderSpacing.Bottom = 8
  99.       Caption = 'Удалить'
  100.       OnClick = btDeleteDeviceClick
  101.       TabOrder = 2
  102.     end
  103.     object dgDevices: TDBGrid
  104.       AnchorSideLeft.Control = plContents
  105.       AnchorSideTop.Side = asrBottom
  106.       AnchorSideRight.Side = asrBottom
  107.       AnchorSideBottom.Control = plContents
  108.       AnchorSideBottom.Side = asrBottom
  109.       Left = 4
  110.       Height = 212
  111.       Top = 54
  112.       Width = 182
  113.       Anchors = [akTop, akRight]
  114.       AutoEdit = False
  115.       AutoFillColumns = True
  116.       Color = clWindow
  117.       Columns = <      
  118.         item
  119.           Title.Caption = 'Устройство'
  120.           Width = 161
  121.           FieldName = 'DEVICE'
  122.         end>
  123.       DataSource = dmOrder.dsDevice
  124.       FixedCols = 0
  125.       Options = [dgColumnResize, dgColumnMove, dgTabs, dgAlwaysShowSelection, dgConfirmDelete, dgCancelOnExit, dgTruncCellHints]
  126.       Scrollbars = ssVertical
  127.       TabOrder = 3
  128.     end
  129.     object edNewDevice: TEdit
  130.       AnchorSideLeft.Control = plContents
  131.       AnchorSideTop.Control = lbNewDevice
  132.       AnchorSideTop.Side = asrBottom
  133.       AnchorSideRight.Control = btAddDevice
  134.       Left = 4
  135.       Height = 23
  136.       Top = 23
  137.       Width = 182
  138.       Anchors = [akTop, akRight]
  139.       BorderSpacing.Right = 8
  140.       BorderSpacing.Bottom = 8
  141.       MaxLength = 50
  142.       OnChange = edNewDeviceChange
  143.       OnKeyDown = edNewDeviceKeyDown
  144.       TabOrder = 0
  145.     end
  146.   end
  147. end
  148.  
« Last Edit: February 09, 2017, 02:03:18 pm by Unvictis »

howardpc

  • Hero Member
  • *****
  • Posts: 2160
Re: Error "List index (0) out of bounds" while opening form in IDE on Ubuntu
« Reply #1 on: February 08, 2017, 03:12:45 pm »
Diagnosing the cause requires you to publish your project (Project->Publish Project...) and zip the published folder with some actual or dummy data. The unit and .lfm you show depend on other unseen code and data.

Unvictis

  • New member
  • *
  • Posts: 13
  • Nihil habeo, nihil timeo
Re: Error "List index (0) out of bounds" while opening form in IDE on Ubuntu
« Reply #2 on: February 08, 2017, 03:16:39 pm »
Full project source.

Handoko

  • Hero Member
  • *****
  • Posts: 1201
  • My goal: build my own game engine using Lazarus
Re: Error "List index (0) out of bounds" while opening form in IDE on Ubuntu
« Reply #3 on: February 08, 2017, 03:22:55 pm »
Tested and confirmed. I got similar error.

howardpc

  • Hero Member
  • *****
  • Posts: 2160
Re: Error "List index (0) out of bounds" while opening form in IDE on Ubuntu
« Reply #4 on: February 08, 2017, 03:30:36 pm »
I get a different exception:
EIBDatabaseError   icConnection:DoInternalConnect: -cannot attach to password database

Handoko

  • Hero Member
  • *****
  • Posts: 1201
  • My goal: build my own game engine using Lazarus
Re: Error "List index (0) out of bounds" while opening form in IDE on Ubuntu
« Reply #5 on: February 08, 2017, 03:33:21 pm »
Try to open fDevEditor.pas and then switch to the form view.

Unvictis

  • New member
  • *
  • Posts: 13
  • Nihil habeo, nihil timeo
Re: Error "List index (0) out of bounds" while opening form in IDE on Ubuntu
« Reply #6 on: February 08, 2017, 03:56:33 pm »
I get a different exception:
EIBDatabaseError   icConnection:DoInternalConnect: -cannot attach to password database
I do not include database with source (size > 1 MB).

Handoko

  • Hero Member
  • *****
  • Posts: 1201
  • My goal: build my own game engine using Lazarus
Re: Error "List index (0) out of bounds" while opening form in IDE on Ubuntu
« Reply #7 on: February 08, 2017, 05:48:54 pm »
Hi Unvictis.

After some testings, I found the culprit. I can't explain why, but I have solution to fix the error.

Use your text editor to open fDevEditor.pas and add dgIndicator in the line 125. So it will become:
Quote
Options = [dgIndicator, dgColumnResize, dgColumnMove, dgTabs, dgAlwaysShowSelection, dgConfirmDelete, dgCancelOnExit, dgTruncCellHints]

I have tested several times. Without dgIndicator the form will cause error when opening. But if dgIndicator is added, problem solved.

Unvictis

  • New member
  • *
  • Posts: 13
  • Nihil habeo, nihil timeo
Re: Error "List index (0) out of bounds" while opening form in IDE on Ubuntu
« Reply #8 on: February 08, 2017, 05:55:44 pm »
Hi Unvictis.

After some testings, I found the culprit. I can't explain why, but I have solution to fix the error.

Use your text editor to open fDevEditor.pas and add dgIndicator in the line 125. So it will become:
Quote
Options = [dgIndicator, dgColumnResize, dgColumnMove, dgTabs, dgAlwaysShowSelection, dgConfirmDelete, dgCancelOnExit, dgTruncCellHints]

I have tested several times. Without dgIndicator the form will cause error when opening. But if dgIndicator is added, problem solved.

Thank you! I test it tomorrow, on work!

Unvictis

  • New member
  • *
  • Posts: 13
  • Nihil habeo, nihil timeo
Re: Error "List index (0) out of bounds" while opening form in IDE on Ubuntu
« Reply #9 on: February 09, 2017, 02:01:21 pm »
Hi Unvictis.

After some testings, I found the culprit. I can't explain why, but I have solution to fix the error.

Use your text editor to open fDevEditor.pas and add dgIndicator in the line 125. So it will become:
Quote
Options = [dgIndicator, dgColumnResize, dgColumnMove, dgTabs, dgAlwaysShowSelection, dgConfirmDelete, dgCancelOnExit, dgTruncCellHints]

I have tested several times. Without dgIndicator the form will cause error when opening. But if dgIndicator is added, problem solved.
Again, thank you very much for your time! After your actions proposed by the error message no longer appears. However, apparently this is a bug, and I think it should be sent to Lazarus bugtracker.

Handoko

  • Hero Member
  • *****
  • Posts: 1201
  • My goal: build my own game engine using Lazarus
If you have time, please report it to the bugtracker:
http://bugs.freepascal.org/my_view_page.php

I'm not familiar with TDBGrid so better not me to submit the bug.  :-[

Unvictis

  • New member
  • *
  • Posts: 13
  • Nihil habeo, nihil timeo
OK. I post this error on bugtracker.

Handoko

  • Hero Member
  • *****
  • Posts: 1201
  • My goal: build my own game engine using Lazarus
Thank you.

I saw it's now in the bugtracker:
http://bugs.freepascal.org/view.php?id=31380

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2917
  • I like bugs.
I saw it's now in the bugtracker:
http://bugs.freepascal.org/view.php?id=31380
See also the comments / questions there.
A backtrace would also be helpful.
Please pay attention to the quality of bug reports.
« Last Edit: February 12, 2017, 01:50:10 pm by JuhaManninen »

Unvictis

  • New member
  • *
  • Posts: 13
  • Nihil habeo, nihil timeo

 

Recent

Get Lazarus at SourceForge.net. Fast, secure and Free Open Source software downloads Open Hub project report for Lazarus