Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Games
Kajongg
Commits
7514a4fc
Commit
7514a4fc
authored
May 06, 2021
by
Wolfgang Rohdewald
Browse files
make isAlive() work with pyside2
parent
bda0f4f7
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/common.py
View file @
7514a4fc
...
...
@@ -17,15 +17,7 @@ import logging.handlers
import
socket
from
signal
import
signal
,
SIGABRT
,
SIGINT
,
SIGTERM
from
qt
import
QStandardPaths
try
:
from
PyQt5.sip
import
unwrapinstance
except
ImportError
:
try
:
from
sip
import
unwrapinstance
except
ImportError
:
def
unwrapinstance
(
unused
):
"""if there is no sip, we have no Qt objects anyway"""
from
qt
import
QStandardPaths
,
QObject
,
QGraphicsItem
# pylint: disable=invalid-name
...
...
@@ -43,17 +35,25 @@ LIGHTSOURCES = ['NE', 'NW', 'SW', 'SE']
def
isAlive
(
qobj
):
"""is the underlying C++ object still valid?
This function is taken from the book
Up to supporting Pyside2, this function
was taken from the book
"Rapid GUI Programming with Python and Qt"
by Mark Summerfield."""
by Mark Summerfield
but that does not work with Pyside2
."""
if
qobj
is
None
:
return
False
try
:
unwrapinstance
(
qobj
)
except
RuntimeError
:
return
False
if
isinstance
(
qobj
,
QObject
):
try
:
qobj
.
children
()
except
RuntimeError
:
return
False
elif
isinstance
(
qobj
,
QGraphicsItem
):
try
:
qobj
.
parentItem
except
RuntimeError
:
return
False
else
:
return
True
print
(
'isAlive(): qobj type is'
,
type
(
qobj
))
return
True
def
serverAppdataDir
():
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment