Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 2

Qt-interest Archive, May 2007
return value of beginTransaction


Message 1 in thread

Hi,

wouldn't it make sense to let the default return value of beginTransaction and 
commitTransaction to be true? Else you'll always have to write one function 
wich makes nothing else then to check if transactions are supported, and then 
call the underlaying transaction methods:

if( drv->hasFeature(Transactions) && !beginTransaction() )
	return error;
...
if( noerror )
{
if( drv->hasFeature(Transactions) && commitTransaction() )
	return error;
}
else
{
if( drv->hasFeature(Transactions) && !rollbackTransaction()
	return error;
}

What should it be good for?

--
 [ signature omitted ] 

Message 2 in thread

J. Preiss schrieb:
> Hi,
> 
> wouldn't it make sense to let the default return value of beginTransaction and 
> commitTransaction to be true? Else you'll always have to write one function 
> wich makes nothing else then to check if transactions are supported, and then 
> call the underlaying transaction methods:
> 
> if( drv->hasFeature(Transactions) && !beginTransaction() )
> 	return error;
> ...

I don't think that's a good idea. First it would break working code (so 
it wouldn't be changed before Qt 5), and second I think if there are no 
transactions available Qt shouldn't act as if, for clarities sake. 
Checking the feature may be inconvenient, but just returning true could 
cause bugs...
BTW, why not check for transaction support once and then store it into a 
bool?

bool ta = drv->hasFeature(Transactions);
if(ta && ...)

My 5 cents.

Martin

-- 
 [ signature omitted ]