EhLib.Com https://forum.ehlib.com/en/ |
|
Ehlib_6 infinity loop Disbled Controls DataSet.Fields.Clear https://forum.ehlib.com/en/viewtopic.php?f=5&t=186 |
Page 1 of 1 |
Author: | nikolayv81 [ 13 Nov 2012, 09:04 ] |
Post subject: | Ehlib_6 infinity loop Disbled Controls DataSet.Fields.Clear |
При тесте возможности перехода с EhLib 4 на EhLib 6 получили следующую проблему если к DataSet привязан DBGridEh (DBGridEh.DataSource.DataSet) то сдедующий код приводит к зависанию программы (после нажатия на кнопку): Code: procedure TForm2.Button2Click(Sender: TObject); begin pFIBDataSet1.DisableControls; try pFIBDataSet1.CloseOpen(False); finally pFIBDataSet1.EnableControls; end; end; procedure TForm2.pFIBDataSet1BeforeOpen(DataSet: TDataSet); var FieldDef : TFieldDef; fldNew : TField; i : Integer; is1 : Boolean; ds : TDataSource; begin TpFIBDataSet(DataSet).Prepare; DataSet.Fields.Clear; //Очистка полей [color=#FF0000]<- Тут происходит зависание[/color] for i := 0 to DataSet.FieldDefs.Count - 1 // Пересоздание полей по умолчанию do begin FieldDef := DataSet.FieldDefs.Items[i]; fldNew := FieldDef.CreateField(DataSet, nil, '', false); end; end; исходники и пример: http://yadi.sk/d/n1fagXE_0hgn3 проблема возникает только с DBGridEh (с TDBGrid проблемы нет, с версиями 4-й ветки EhLib тоже всё нормально) Зацикливается TCustomDBGridEh.Notification(AComponent: TComponent; Operation: TOperation); Code: procedure TCustomDBGridEh.Notification(AComponent: TComponent; Operation: TOperation); var I: Integer; NeedLayout: Boolean; begin inherited Notification(AComponent, Operation); if (Operation = opRemove) then begin if (AComponent is TPopupMenu) then begin for I := 0 to Columns.Count - 1 do if Columns[I].PopupMenu = AComponent then Columns[I].PopupMenu := nil; end else if (AComponent is TCustomImageList) then begin if TitleImages = AComponent then TitleImages := nil; for I := 0 to Columns.Count - 1 do if Columns[I].ImageList = AComponent then Columns[I].ImageList := nil; end else if (AComponent is TScrollBar) then begin if VertScrollBar.ExtScrollBar = AComponent then VertScrollBar.ExtScrollBar := nil else if HorzScrollBar.ExtScrollBar = AComponent then HorzScrollBar.ExtScrollBar := nil end else if (AComponent is TDataSource) then begin for I := 0 to Columns.Count - 1 do if Columns[I].DropDownBox.ListSource = AComponent then Columns[I].DropDownBox.ListSource := nil; if (FDataLink <> nil) and (AComponent = DataSource) then DataSource := nil; end else if (FDataLink <> nil) then if (AComponent is TField) then begin // [color=#BF0000]if FDatalink.Dataset.ControlsDisabled then exit; [/color] //Решает проблему но какими будут последствия? NeedLayout := False; for I := 0 to Columns.Count - 1 do with Columns[I] do if Field = AComponent then NeedLayout := True; if NeedLayout then begin BeginLayout; try for I := 0 to Columns.Count - 1 do with Columns[I] do if Field = AComponent then begin [color=#FF0000]Field := nil;[/color] // проблема где то здесь //NeedLayout := True; end; finally if Assigned(FDatalink.Dataset) and not FDatalink.Dataset.ControlsDisabled then EndLayout else DeferLayout; end; end; end else if (AComponent is TDataSet) then begin CheckIMemTable; if ViewScroll then begin UpdateRowCount; MTViewDataEvent(-1, mtViewDataChangedEh, -1); end; LayoutChanged; end; end; end; Ehlib 6.0 Full Source, Fib 7.3, D2007, W7x64 and WXPx32 |
Page 1 of 1 | All times are UTC |
Powered by phpBB® Forum Software © phpBB Group http://www.phpbb.com/ |