[V4RB] Does order in constructor make difference?

Christer Olsson christer at ljusaideer.se
Sat Jan 24 20:55:42 CST 2004


>on 1/24/04 8:03 PM, Christer Olsson at christer at ljusaideer.se wrote:
>
>>>> I've spent the last five hours to hunt down a problem I've never seen
>>>> before.
>>>> We're adding two new tables ("Rabatter" and "Rabattrader") to our main app,
>>>> and when we tried to add data to the new tables the app crashed every time
>>>> on
>>>> the second table.
>>>> 
>>>> It turned out that both tables were created just fine (i.e we could see and
>>>> read them just fine with VAPP and ViSQL), but the baseObject for the second
>>>> table ("Rabattrader"/"boRabattrader") had no fields...
>>>> 
>>>> After lot's of spellchecking, renamning and recreating of properties,
>>>> methods
>>>> and objects I just switched the order of the new tables in the database
>>>> constructor - and suddenly everything worked just fine.
>>>> 
>>>> So, this didn't work:
>>>> mInstallningar = new boInstallningar(self)
>>>> mKunder = new boKunder(self)
>>>> mArtiklar = new boArtiklar(self )
>>>> mOrder = new boOrder(self)
>>>> mOrderrader = new boOrderrader(self)
>>>> mRabatter = new boRabatter(self)
>>>> mRabattrader = new boRabattRader(self)
>>>> 
>>>> But this did:
>>>> mInstallningar = new boInstallningar(self)
>>>> mKunder = new boKunder(self)
>>>> mArtiklar = new boArtiklar(self )
>>>> mOrder = new boOrder(self)
>>>> mOrderrader = new boOrderrader(self)
>>>> mRabattrader = new boRabattRader(self)
>>>> mRabatter = new boRabatter(self)
>>>> 
>>>> Any ideas?
>>> 
>>> Hi Christer,
>>> 
>>> Yes, order does mater. When you use classes.
>>> It does not mater, if you simply use Vdatabase and SQL.
>>> 
>>> This is why it is danger go to VAPP, add few tables with many  fields,
>>> Then jump to RB and write code.
>>> 
>>> Most probably in this case you will not get the same order.
>>> 
>>> This is why you need create db/tables programmatically.
>> 
>> Both db and tables are created in code. And "Rabatter" is created before
>> "Rabattrader".
>> 
>> As order matters, please tell what rules to follow, as I can't find anything
>> regariding this in the docs.
>
>Aha, then you have other problem I think.
>
>I have describe problem, when you in VAPP create tables,
>Then try in code mirror that,
>
>So you have change order of tables in code,
>And now you can do db.create(), yes?
>Before that it have crash?

I have had no problems with creating tables.

>Then I think in table boRabatter you have an ObjectPtr
>Which points boRabattRader.
>Therefore it must be AFTER you create boRabattRader object.

It's actually the other way around. There's an ObjectPtr in boRabattRader that points to boRabatter.
-- 

  *************************************************************
  Christer Olsson   PO Box 9160        Phone +46 40 25 85 85
  Ljusa Idéer AB    SE-200 39 Malmoe   Fax +46 40 25 85 89
  Kantyxegatan 5    Sweden             http://www.ljusaideer.se


More information about the Valentina mailing list