Comments (11)
I believe it should never get garbage collected by default as it creates a singleton internally? That's also why you can retrieve it with QApplication.instance()
right? (Edit: I see this actually came up in the link too)
Anyway, I wonder why this hasn't been a problem for any other hosts (even those without Qt). Am I missing something obvious?
from core.
To be honest: I have no idea if it should or should not get garbage collected. The fact is, it somehow was. Or to be precise: the underlying C++
object was gone.
Would it hurt to make sure a reference is kept to the QApplication?
Have there been any other hosts (apart from Blender) who don't have Qt? For the Blender integration it isn't a problem, because it creates a QApplication by itself, so it doesn't rely on the code in tools.lib.application
.
from core.
I can confirm that I'm getting the same issue with the Photoshop integration.
Every second opening of any of the tools, will crash the web server without any error messages.
For example commenting out https://github.com/getavalon/core/blob/master/avalon/tools/contextmanager/app.py#L218-L222 will allow me to open the context app more than once.
from core.
For example commenting out https://github.com/getavalon/core/blob/master/avalon/tools/contextmanager/app.py#L218-L222 will allow me to open the context app more than once.
Actually, isn't that the opposite behavior? This actually sounds logical to me. Whenever the last Qt application's window closes I believe by default the QApplication instance is supposed to "close off" which likely leaves the Window object in an invalid state. Basically meaning the Window would be destroyed meaning whatever is stored in module.window
is basically a dangling pointer to nothingness. Making this crash resolved with a simple "check" whether QWindow is still valid.
Does adding this help?
if module.window:
It seems in the current code we're trying to close a QWindow that doesn't actually exist anymore.
I'm not sure that's the valid way to check whether the QObject still exists in memory, but I'm expecting it would be. This however hints that it could be more complicated than just the if
statement.
@tokejepsen the other way around is to force the QApplication to persist even after closing the last window:
app.setQuitOnLastWindowClosed(False)
Does that also fix the crash?
from core.
Whenever the last Qt application's window closes I believe by default the QApplication instance is supposed to "close off" which likely leaves the Window object in an invalid state.
Yeah, you are right!
Does adding this help?
The module.window
point to an invalid window, but I'm not sure how to figure out whether its valid or not, cause its the QApplication instance that is gone and not the window instance.
Will investigate this.
from core.
This issue can be solved by introducing an existing_app
variable on the lib
module. Then we can query whether its a new application or an existing one.
But I would also like to figure out, why do we need to close and delete the existing window in those lines?
I tried to show the context manager multiple times in Nuke, and didnt get any duplicated windows.
from core.
I tried to show the context manager multiple times in Nuke, and didnt get any duplicated windows.
Tried in Maya, and its seems like it does make duplicate windows there, so will need those lines of code. Not sure why it does not make duplicates in Nuke.
from core.
Does holding onto the instance of a QApplication
solve this issue? What if it's being held onto at the module-level, like tools are, from the lib.application()
call?
Lines 21 to 31 in ace0c79
E.g.
def application():
app = module._app or QApplication()
...
module._app = app
With an underscore, to prevent accessing it from the outside.
from core.
Does holding onto the instance of a QApplication solve this issue? What if it's being held onto at the module-level, like tools are, from the lib.application() call?
I have tried to store the QApplication
on the module level, but on the second try of launching the tool becomes unresponsive and I dont get why that is?
def show(parent=None):
try:
module.window.show()
except (RuntimeError, AttributeError):
# RuntimeError if the module.window C++ object has been deleted.
# AttributeError if the module.window is None.
with lib.application() as app:
window = Window(parent)
window.show()
window.setStyleSheet(style.load_stylesheet())
module.window = window
module.qapp = app
window.activateWindow()
This is tested with the upcoming webserver, which is the base for the Photoshop integration. Its running the tools standalone, similar to how the TV Paint integration would which is the original issue here.
from core.
I would take a step back. Ensure you can get a QPushButton
running first. Off the top of my head, it looks like the QApplication isn't running on that second try. What you're seeing is what would happen if you didn't start one to begin with.
from core.
Ok, I seem to be able to hold onto the QApplication
at the module level but when holding onto the window then I get the above unresponsive dialog that takes the webserver down with it.
from core.
Related Issues (20)
- Make debug behaviour consistent for all tools HOT 5
- Photoshop Integration HOT 13
- Unity Integration HOT 2
- TVPaint integration HOT 7
- Toon Boom Harmony Integration HOT 13
- Workfiles App Project Folders HOT 5
- Work Files tool save modified changes on scene open prompt confusing HOT 2
- Project Manager allows to add assets with new line characters HOT 3
- Scene Inventory action selection cannot pass into other actions
- No Qt Platform Plugin Initialized - but Launcher loads HOT 3
- Link Loader action against specific panel/UI of host based on user decision HOT 2
- Workfiles close on Open HOT 1
- Workfiles tool add toggle to keep open or close after scene open HOT 2
- CI test failing on sending coverage report
- Performance optimizations using Mongo Aggregation
- CI build pass even when test failed
- Opt-in Python-3.7 in CI test
- Pype & Avalon - let's sync the cores HOT 7
- Houdini: lsattr maybe use Houdini's own nodesearch
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from core.