metalman3797 / Cura-Dremel-Printer-Plugin

Dremel Idea Builder plugin for Cura version 3.x and onward. This plugin enables the user to use the Dremel Ideabuilder 3D20, 3D40, and 3D45 printers and use Cura to export the proprietary .g3drem files.
GNU Lesser General Public License v3.0
57 stars 10 forks source link

Cura crashes: 'NoneType' object has no attribute 'save' #63

Closed Ghostkeeper closed 4 years ago

Ghostkeeper commented 4 years ago

We got this issue report through Cura's issue reporter. Cura was crashing somewhere in this plug-in. I thought I'd share it with you guys.

AttributeError Dremel3D20.Dremel3D20 in getBitmapBytes

'NoneType' object has no attribute 'save'

AttributeError: 'NoneType' object has no attribute 'save'
  File "X:\4.5-exe\build\inst\lib\python3.5\site-packages\cura\CuraApplication.py", line 1023, in event
  File "X:\4.5-exe\build\inst\lib\python3.5\site-packages\UM\Qt\QtApplication.py", line 456, in event
  File "X:\4.5-exe\build\inst\lib\python3.5\site-packages\UM\Event.py", line 189, in call
  File "X:\4.5-exe\build\inst\lib\python3.5\site-packages\cura\Utils\Threading.py", line 34, in _handle_call
  File "Dremel3D20\Dremel3D20.py", line 473, in getBitmapBytes
    if not self._snapshot.save(bmpData, "BMP"):

It seems that self._snapshot can contain None?

timmehtimmeh commented 4 years ago

Thanks for the report @Ghostkeeper - I appreciate it 👍

self._snapshot gets set via a call to cura.Snapshot.snapshot() - but looking at the source I see that this can return None in some cases and due to some other errors. I've added additional checks for bmpData is None and self._snapshot is None in the plugin, tested it by forcing the variables to be None inside the function. After the additional checks the plugin doesn't crash.

timmehtimmeh commented 4 years ago

I've submitted version 0.6.2 via the Ultimaker portal that contains the fixes.

Cheers!

timmehtimmeh commented 4 years ago

The new plugin is now published in the Ultimaker Marketplace - thanks for the helpful bug report @Ghostkeeper!