[Kexi-devel] koffice/kexi/core

Jarosław Staniek js at iidea.pl
Wed Nov 23 21:00:45 CET 2005


Martin Ellis said the following, On 2005-11-23 20:03:

> SVN commit 482671 by martin:
> 
> Takes things a bit easier for g++: prevents compiler warning.
> When is p_id < 0 anyway?

p_id is < 0 for every (not yet) stored part item (instance, eg. 
table/query/form/report). Thus, we're not wasting our time with retrieving a 
new id for an item that can be removed from memory without saving (user can 
choose to do this). Moreover, every stored item will have smallest possible 
identifier.
See also how d->tempPartItemID_Counter is used in KexiProject::createPartItem().

>  M  +12 -8     kexidialogbase.cpp  
> 
> 
> --- trunk/koffice/kexi/core/kexidialogbase.cpp #482670:482671
> @@ -485,20 +485,24 @@
>  
>  		//temp. hack: avoid problems with autonumber
>  		// see http://bugs.kde.org/show_bug.cgi?id=89381
> -		int p_id = part()->info()->projectPartID(); 
> -		// = KexiPart::LastObjectType+1; //min is == 3+1
> +		int p_id = part()->info()->projectPartID();
> +
>  		if (p_id<0) {
> -			//find 1st maximum custom id
> +			// Find first available custom part ID by taking the greatest
> +			// existing custom ID (if it exists) and adding 1.
>  			p_id = (int)KexiPart::UserObjectType;
> -			if (!m_parentWindow->project()->dbConnection()->querySingleNumber(
> -				"SELECT max(p_id) FROM kexi__parts", p_id))
> +			tristate success = m_parentWindow->project()->dbConnection()->querySingleNumber(
> +				"SELECT max(p_id) FROM kexi__parts", p_id);
> +			if (!success) {
> +			       	// Couldn't read part id's from the kexi__parts table
>  				return false;
> -			else {//ok or not record found:
> -				p_id = QMAX(++p_id, (int)KexiPart::UserObjectType);
> +			} else {
> +			       	// Got a maximum part ID, or there were no parts
> +				p_id = p_id + 1;
> +				p_id = QMAX(p_id, (int)KexiPart::UserObjectType);
>  			}
>  		}
>  
> -//		KexiDB::FieldList *fl = ts->subList("p_name", "p_mime", "p_url");
>  		KexiDB::FieldList *fl = ts->subList("p_id", "p_name", "p_mime", "p_url");
>  		kexidbg << "KexiMainWindowImpl::newObject(): fieldlist: " 
>  			<< (fl ? fl->debugString() : QString::null) << endl;
> 


-- 
regards / pozdrawiam,
  Jaroslaw Staniek / OpenOffice Polska
  Kexi Developer:
      http://www.kexi-project.org | http://koffice.org/kexi
  Kexi support:
      http://www.kexi-project.org/support.html
  KDE3, KDE4 libraries for developing MS Windows applications:
      http://wiki.kde.org/tiki-index.php?page=KDElibs+for+win32


More information about the Kexi-devel mailing list