Plugin Cafe Homepage
Forum Home Forum Home > Plugin Cafe > SDK Help
  New Posts New Posts
  FAQ FAQ  Forum Search   Register Register  Login Login

Set BaseLink in a custom thread

 Post Reply Post Reply
Author
Message
peterakos View Drop Down
Member
Member


Joined: 2015 Jul 13
Online Status: Offline
Posts: 331
Post Options Post Options   Quote peterakos Quote  Post ReplyReply Direct Link To This Post Topic: Set BaseLink in a custom thread
    Posted: 2018 Apr 13 at 1:57am

User Information:

Cinema 4D Version:   R18 
Platform:   Windows  ;   
Language(s):     C++  ;   

---------

Hello.

I've got a huge problem dealing with BaseLink data and I was wondering if you could help me.
First of all, I'm aware of that I should never keep direct pointers to hierarchy objects or materials and that I should always refer to them via BaseLinks.

I have to deal with a weird bug in which I have 2 base links, I set them with the exact same pointer (hierarchy object) and after a couple of ctrl-z and ctrl-y on that object, one of these base links give me a NULL pointer, while the other contains the correct updated pointer in the hierarchy.

I assume the problem here is that I set the base links in a custom thread. How safe is that ?

Thank you.
Back to Top
Andreas Block View Drop Down
Forum Moderator
Forum Moderator
Avatar

Joined: 2014 Oct 01
Location: Hannover
Online Status: Offline
Posts: 1754
Post Options Post Options   Quote Andreas Block Quote  Post ReplyReply Direct Link To This Post Posted: 2018 Apr 16 at 10:15am
Hi,

this is a bit difficult to answer. Can you please describe the situation in a bit more detail? What type of plugin? How/when/In which thread is the BaseLink set?  How/when/In which thread(s) is the BaseLink read? What are the document contexts in these situations? Does the use of ForceGetLink() make any difference (if so, please don't see it as fix, but rather some additional info for discussion with us)?

Cheers,
Andreas
SDK Support Engineer
Back to Top
peterakos View Drop Down
Member
Member


Joined: 2015 Jul 13
Online Status: Offline
Posts: 331
Post Options Post Options   Quote peterakos Quote  Post ReplyReply Direct Link To This Post Posted: 2018 Apr 17 at 1:23am
Hello.
The two BaseLinks are set in the main thread and they are read in the custom thread.
They point to the same BaseMaterial based on MaterialData plugin.

The document contains a Cloner with a random effector. The cloner has a polygon as child and the polygon has the above material.
The material contains a mograph color shader.

I render the above scene in my render engine and at some point I clear the mograph shader and I start playing with ctrl-z and ctrl-y.
That causes of course the material pointer to change and there is a time in the custom thread (where I read the base links) that one of these baselinks return NULL.

Thank you for your time.


Edited by peterakos - 2018 Apr 17 at 1:24am
Back to Top
Andreas Block View Drop Down
Forum Moderator
Forum Moderator
Avatar

Joined: 2014 Oct 01
Location: Hannover
Online Status: Offline
Posts: 1754
Post Options Post Options   Quote Andreas Block Quote  Post ReplyReply Direct Link To This Post Posted: 2018 Apr 18 at 9:24am
Hi,

unfortunately I need to ask you for a bit of patience. I try to get back to you as soon as possible. Sorry!
In the meantime can you maybe do the quick test with checking the result of ForceGetLink(), when GetLink() delivers nulltpr?

Cheers,
Andreas
SDK Support Engineer
Back to Top
peterakos View Drop Down
Member
Member


Joined: 2015 Jul 13
Online Status: Offline
Posts: 331
Post Options Post Options   Quote peterakos Quote  Post ReplyReply Direct Link To This Post Posted: Yesterday at 3:04am
Hello.

ForceGetLink returns the pointer of the material. The 2 base links have 2 different pointers even though they are supposed to point in the same material.

I assume my mistake is that I read the baselinks in the custom thread, while somehow it is set in the main thread.

Thank you !




Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Bulletin Board Software by Web Wiz Forums® version 9.61 [Free Express Edition]
Copyright ©2001-2009 Web Wiz

This page was generated in 0.094 seconds.