Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2017-10

Deleting items in OI

9 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Vojtěch Čihák
Hi,
 
I got this code for design time editing (note the line+comment *** aHook.SelectOnlyThis(aECTC.Tabs);  { force the OI to refresh } ***).
That line should refresh OI so the deleted item (CollectionItem) is removed (node in OI).
It worked in recent Lazarus versions, but it doesn't work in the latest trunk (i.e. item is removed but related node in OI persists).
I don't know which revision broke it.
What should I do?
 
Note: Lazarus (TPageControl) have not this problem. It uses plain DeletePersistent() method (in ComponentEditor.pas) .
 
procedure TECTabCtrlEditor.ExecuteVerb(Index: Integer);
var aECTC: TECTabCtrl;
    aECTab: TECTab;
    aHook: TPropertyEditorHook;
begin
  if Component is TECTabCtrl
    then aECTC:=TECTabCtrl(Component)
    else exit;  { Exit! }
    begin
      aHook:=nil;
      if not GetHook(aHook) then exit;  { Exit! }
      case Index of
        0: begin
             aECTab:=aECTC.AddTab(etaLast, True);
             aHook.PersistentAdded(aECTab, True);
           end;
        1: begin
             aECTab:=aECTC.AddTab(etaBeside, True);
             aHook.PersistentAdded(aECTab, True);
           end;
        2: begin
             aECTab:=aECTC.Tabs[aECTC.TabIndex];
             aHook.PersistentDeleting(aECTab);
             aECTC.DeleteTab(aECTC.TabIndex);
             aHook.SelectOnlyThis(aECTC.Tabs);  { force the OI to refresh }
           end;
        3: aECTC.MovePrevious();
        4: aECTC.MoveNext();
      end;
      Modified;
    end;
end;               
 
V.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20171025/0969aa89/attachment.html>

Reply by email

Juha Manninen
to Vojtěch Čihák
Vojtěch Čihák wrote 12 lines
I got this code for design time editing (note the line+comment *** aHook.SelectOnlyThis(aECTC.Tabs); { force the OI to refresh } ***). That line should refresh OI so the deleted item (CollectionItem) is removed (node in OI). It worked in recent Lazarus versions, but it doesn't work in the latest trunk (i.e. item is removed but related node in OI persists). I don't know which revision broke it. What should I do?

I could is the easiest way to reproduce?

Juha

Reply by email

Mattias Gaertner
to Vojtěch Čihák
Show quoted text 5 lines
Hi,   I just have some more info. Everything was OK to revision 52209. OI was completly broken between 52210 and 52229 (components didn't appear at all). Revision 52230 improved OI but deleting didn't work as described in previous mails, it's up to now.

Please create a bug report.

Mattias

Reply by email

Juha Manninen
to Vojtěch Čihák:   I just have some more info. Everything was OK to revision 52209. OI was completly…
Vojtěch Čihák wrote
I just have some more info. Everything was OK to revision 52209. OI was completly broken between 52210 and 52229 (components didn't appear at all). Revision 52230 improved OI but deleting didn't work as described in previous mails, it's up to now.

Yes, those were my commits. Sorry I did not answer earlier, something always came up when I planned to study the issue.
The changes were more or less valid. At least they fixed bugs and optimized the updates.
However your usage of TPropertyEditorHook looks suspicious and counter-intuitive:

  aHook.PersistentDeleting(aECTab);
  aECTC.DeleteTab(aECTC.TabIndex);
  aHook.SelectOnlyThis(aECTC.Tabs);  { force the OI to refresh }

Calling aHook.DeletePersistent() would be intuitive. It that is not possible in your case, then we should improve the API. Something like "StartDeletingPersistent()" + "EndDeletingPersistent()" pair maybe.
How about calling aHook.Modified?
What would be the most intuitive API in your opinion?

Juha

Reply by email

Vojtěch Čihák
to Vojtěch Čihák:   I just have some more info. Everything was OK to revision 52209. OI was completly…

Hi, thanks for reply.
 
Yes, I need something like
1) say to OI thah I'm going to delete TPersistent
2) delete it (my own code)
3) refresh OI (node must disappear)
 
I tried to search other people's code how they do it but I didn't find any.  
Even worse, there is possibility to delete TPersistent in OI with Delete key which I didn't consider before so I have to redesign several components.  
V.
 
______________________________________________________________

Show quoted text 5 lines
Od: Juha Manninen via Lazarus Komu: Lazarus mailing list Datum: 28.11.2017 13:10 Předmět: Re: [Lazarus] Deleting items in OI
Vojtěch Čihák wrote
I just have some more info. Everything was OK to revision 52209. OI was completly broken between 52210 and 52229 (components didn't appear at all). Revision 52230 improved OI but deleting didn't work as described in previous mails, it's up to now.

Yes, those were my commits. Sorry I did not answer earlier, something always came up when I planned to study the issue.
The changes were more or less valid. At least they fixed bugs and optimized the updates.
However your usage of TPropertyEditorHook looks suspicious and counter-intuitive:

  aHook.PersistentDeleting(aECTab);
  aECTC.DeleteTab(aECTC.TabIndex);
  aHook.SelectOnlyThis(aECTC.Tabs);  { force the OI to refresh }

Calling aHook.DeletePersistent() would be intuitive. It that is not possible in your case, then we should improve the API. Something like "StartDeletingPersistent()" + "EndDeletingPersistent()" pair maybe.
How about calling aHook.Modified?
What would be the most intuitive API in your opinion?

Juha

Reply by email