Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Particle Panel: stack trace when cancelling Load Params #811

Closed
xordspar0 opened this issue Dec 13, 2019 · 4 comments
Closed

Particle Panel: stack trace when cancelling Load Params #811

xordspar0 opened this issue Dec 13, 2019 · 4 comments
Labels
Milestone

Comments

@xordspar0
Copy link

@xordspar0 xordspar0 commented Dec 13, 2019

I'm running Panda3D 1.10.4.1 with Python 3.7 on macOS.

When I start to load a file in the particle panel, but then change my mind and click "cancel" in the native file selection dialog that pops up, I get a stack trace:

OSError Exception in Tk callback
  Function: <bound method ParticlePanel.loadParticleEffectFromFile of <direct.tkpanels.ParticlePanel.ParticlePanel object at 0x113d83350>> (type: <class 'method'>)
  Args: ()
Traceback (innermost last):
  File "/usr/local/lib/python3.7/site-packages/Pmw/Pmw_2_0_1/lib/PmwBase.py", line 1776, in __call__
    return self.func(*args)
  File "/usr/local/lib/python3.7/site-packages/direct/tkpanels/ParticlePanel.py", line 1278, in loadParticleEffectFromFile
    Filename.fromOsSpecific(particleFilename))
  File "/usr/local/lib/python3.7/site-packages/direct/particles/ParticleEffect.py", line 203, in loadConfig
    data = vfs.readFile(filename, 1)
OSError: Failed to read file: 'None'

I edited ParticlePanel.py to add the following line after getting the filename:

        print(repr(particleFilename))

askopenfilename is indeed returning the string 'None'.

For context, here's where the problem is occurring in Panda3d's code:

particleFilename = askopenfilename(
defaultextension = '.ptf',
filetypes = (('Particle Files', '*.ptf'), ('All files', '*')),
initialdir = path,
title = 'Load Particle Effect',
parent = self.parent)
if particleFilename:
# Delete existing particles and forces
self.particleEffect.loadConfig(
Filename.fromOsSpecific(particleFilename))
self.selectEffectNamed(self.particleEffect.getName())
# Enable effect
self.particleEffect.enable()

I draw two conclusions from this:

  1. There might be a bug in tkinter and/or the Mac file dialog.
  2. The particle panel should check if the file that gets returned by the file picker actually exists. This would also fix race conditions where real files got deleted before we have a chance to read them.
@rdb

This comment has been minimized.

Copy link
Member

@rdb rdb commented Dec 14, 2019

I went to the Particle Panel, clicked File > Load Params, and then clicked Cancel, and no error was displayed anywhere. Did you follow different steps? Perhaps the Mac version of tkinter is doing something odd by returning "Null" instead of None?

@rdb

This comment has been minimized.

Copy link
Member

@rdb rdb commented Dec 14, 2019

Your error message says that it's trying to load "None" instead of "Null", which one is it?

@xordspar0

This comment has been minimized.

Copy link
Author

@xordspar0 xordspar0 commented Dec 16, 2019

Oops, my mistake. Replace all places where I said Null with None.

@xordspar0

This comment has been minimized.

Copy link
Author

@xordspar0 xordspar0 commented Dec 16, 2019

no error was displayed anywhere. Did you follow different steps?

Nope, I can reproduce this with the steps above on a Mac. On my main Ubuntu machine it seems fine. Sometimes the error popup is delayed a few seconds, but usually it pops up right away.

@rdb rdb added the macos label Dec 18, 2019
@rdb rdb added this to the 1.10.5 milestone Dec 30, 2019
@rdb rdb closed this in 7ca66bf Jan 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.