Subject Re: [IBO] Strange behaviour
Author Salvatore Besso
hello Helen,

ok, ok, timeout, I am an IBO student at the first year :-) Maybe I
haven't explained myself correctly, and having now read the Tech Info
about transactions, maybe I can see more light :-) I try to explain
myself again with very few words:

- When my query is opened, IBO automatically starts a *physical*
transaction because I don't explicitly start the transaction by
myself. Infact Transaction.Started is True and
Transaction.InTransaction is False at this point.

- After query opening, there are no logical transactions started or
active because I haven't performed any operation yet. Infact
Transaction.TransactionIsActive is False at this point because there
is *nothing* to commit or rollback.

- Being *nothing* to commit or rollback, why the commit and rollback
buttons of the transaction bar are enabled?

This is my bug doubt. In my opinion the commit and rollback buttons
should be enabled only when some data has been posted and have to be
committed or rolled back; in this case (query opened, physical
transaction started) only the *close transaction* button should be
enabled (in effect it is), because as far as I know (very little :-)
the *close transaction* button purpose is to close a *physical*
transaction, isn't it?

In my opinion this different behaviour would only be confusing for the
programmer and end user. Suppose that I write this hypothetical phrase
in the manual of my application:

"Dear end user, when you will add a new customer, or you will edit or
delete an existing customer, you will see the Commit and Rollback
buttons illuminate (enable), giving you the ability to permanently
store your changes into the database or discard them as a whole".

Well, don't you think that this end user will scratch his head when he
will see the aforementioned buttons illuminated (enabled) having done
nothing yet? And don't you think that this end user will scratch his
head even more, seeing that the illuminated buttons will become grayed
after two minutes without any intervention by himself?

I gave a look at the source code in IB_TransactionBar.pas and I have
noticed this snippet of code:

Buttons[tbCommit].Enabled := Started or
TransactionIsActive or InTransaction;

Buttons[tbRollback].Enabled := Started or
TransactionIsActive or InTransaction;

Buttons[tbClose].Enabled := Started or
TransactionIsActive or InTransaction;

What is the behaviour difference for the three buttons?

And this could be the corrected code for the two buttons?

Buttons[tbCommit].Enabled := TransactionIsActive;

Buttons[tbRollback].Enabled := TransactionIsActive;

Ok, even this time I have written too much :-) I hope I have been more
clear though.