Different behaviour with Resource File? R20/R21
I'm experiencing some difficulties in R21 with
__res__and my maindialog.
This is my folder structure and what I currently have implemented:
./plugins/ |-- myplugin/ |-- myplugin.pyp |-- modules/ |-- maindialog.py |-- res/ |-- usual suspects here
myplugin.pyp (I'm using the localimport from Niklas Rosenstein):
# localimport-v1.7.3-blob-mcw99 with localimport('.') as _importer: from modules import maindialog from modules.maindialog import OptionsDialog maindialog.__res__ = __res__
class OptionsDialog(c4d.gui.GeDialog): def CreateLayout(self): #Initialize Resource File from 'res' Folder. c4d.plugins.GeResource().Init(os.path.dirname(__file__)) self.LoadDialogResource(ids.IDD_DIALOG)
While this is working in all versions from R17-R20, I'm experiencing instant crashes and freezes in R21. Any ideas how I can fix this or how I can optimize my code..?
m_adam last edited by
If defining a __res__ variable in your maindialog.py doesn't help then could you please share a minified version of your project?
thanks for taking a look! I've already tried to define it globally and it had the same effect. I'll try to share a minified version as soon as possible!
Wow, after some investigating I noticed that apperently
BitmapButtonCustomGui.SetImagechanged in R21.
def fillResetButtons(self, buttonid): button = self.FindCustomGui(buttonid, c4d.CUSTOMGUI_BITMAPBUTTON) icon = c4d.bitmaps.InitResourceBitmap(c4d.RESOURCEIMAGE_CLEARSELECTION) button.SetImage(icon, copybmp=True)
I just had to set the copybmp to
Falseand seemed to worked fine in all other versions.
m_adam last edited by m_adam
BitmapButtonCustomGui.SetImagewas just extended in R21 to support
c4d.IconDataas well, but the behavior didn't changed.
I guess the issue is more related to R21 What is News - Fixes
- Fixed a memory leak in bitmaps.InitResourceBitmap().
So basically previously c4d.bitmaps.InitResourceBitmap produced a memory leak where the allocated BaseBitmap was never released, so that's why previously without copying it, it was working.
But you should pass True to copyBmp to copy the BaseBitmap now since the BaseBitmap will be released at the destruction of
iconvariable by the Python Garbage Collection, but if you don't copy it, the BitmapButtonCustomGui will still use the previous BaseBitmap pointer, which will produce a crash since it will be dead.
Glad you found the issue.