Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Games
KPat
Commits
10db6757
Commit
10db6757
authored
Dec 27, 2021
by
Albert Astals Cid
Browse files
Manupilate the KSharedDataCache only from one thread
Fixes crash (easy to reproduce when together with MR #20)
parent
3f792f4b
Pipeline
#114787
passed with stage
in 2 minutes
Changes
1
Pipelines
3
Hide whitespace changes
Inline
Side-by-side
src/libkcardgame/kabstractcarddeck.cpp
View file @
10db6757
...
...
@@ -77,14 +77,8 @@ void RenderingThread::run()
if
(
m_haltFlag
)
return
;
QString
key
=
keyForPixmap
(
element
,
size
);
if
(
!
d
->
cache
->
contains
(
key
)
)
{
//qCDebug(LIBKCARDGAME_LOG) << "Renderering" << key << "in rendering thread.";
QImage
img
=
d
->
renderCard
(
element
,
size
);
d
->
cache
->
insertImage
(
key
,
img
);
Q_EMIT
renderingDone
(
element
,
img
);
}
const
QImage
img
=
d
->
renderCard
(
element
,
size
);
Q_EMIT
renderingDone
(
element
,
img
);
}
}
...
...
@@ -228,20 +222,14 @@ void KAbstractCardDeckPrivate::deleteThread()
void
KAbstractCardDeckPrivate
::
submitRendering
(
const
QString
&
elementId
,
const
QImage
&
image
)
{
QPixmap
pix
;
// If the currentCardSize has changed since the rendering was performed,
// we sadly just have to throw it away.
const
auto
dpr
=
qApp
->
devicePixelRatio
();
if
(
image
.
size
()
!=
currentCardSize
*
dpr
)
return
;
// The RenderingThread just put the image in the cache, but due to the
// volatility of the cache there's no guarantee that it'll still be there
// by the time this slot is called, in which case we convert the QImage
// passed in the signal.
if
(
!
cache
->
findPixmap
(
keyForPixmap
(
elementId
,
currentCardSize
*
dpr
),
&
pix
)
)
pix
=
QPixmap
::
fromImage
(
image
);
cache
->
insertImage
(
keyForPixmap
(
elementId
,
currentCardSize
*
dpr
),
image
);
QPixmap
pix
=
QPixmap
::
fromImage
(
image
);
pix
.
setDevicePixelRatio
(
dpr
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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