Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Donald Haase
Cockatrice
Commits
3bce98e3
Commit
3bce98e3
authored
Aug 07, 2014
by
Fabio Bas
Browse files
Fix crashes trying to load the picture of a card with no <set>
parent
0de0658a
Changes
2
Show whitespace changes
Inline
Side-by-side
cockatrice/src/carddatabase.cpp
View file @
3bce98e3
...
@@ -93,6 +93,14 @@ bool PictureToLoad::nextSet()
...
@@ -93,6 +93,14 @@ bool PictureToLoad::nextSet()
return
true
;
return
true
;
}
}
QString
PictureToLoad
::
getSetName
()
const
{
if
(
setIndex
<
sortedSets
.
size
()
-
1
)
return
sortedSets
[
setIndex
]
->
getCorrectedShortName
();
else
return
QString
(
""
);
}
PictureLoader
::
PictureLoader
(
const
QString
&
__picsPath
,
bool
_picDownload
,
bool
_picDownloadHq
,
QObject
*
parent
)
PictureLoader
::
PictureLoader
(
const
QString
&
__picsPath
,
bool
_picDownload
,
bool
_picDownloadHq
,
QObject
*
parent
)
:
QObject
(
parent
),
:
QObject
(
parent
),
_picsPath
(
__picsPath
),
picDownload
(
_picDownload
),
picDownloadHq
(
_picDownloadHq
),
_picsPath
(
__picsPath
),
picDownload
(
_picDownload
),
picDownloadHq
(
_picDownloadHq
),
...
@@ -127,9 +135,15 @@ void PictureLoader::processLoadQueue()
...
@@ -127,9 +135,15 @@ void PictureLoader::processLoadQueue()
mutex
.
unlock
();
mutex
.
unlock
();
//The list of paths to the folders in which to search for images
//The list of paths to the folders in which to search for images
QList
<
QString
>
picsPaths
=
QList
<
QString
>
()
<<
_picsPath
+
"/CUSTOM/"
+
ptl
.
getCard
()
->
getCorrectedName
()
+
".full"
QList
<
QString
>
picsPaths
=
QList
<
QString
>
()
<<
_picsPath
+
"/CUSTOM/"
+
ptl
.
getCard
()
->
getCorrectedName
()
+
".full"
;
<<
_picsPath
+
"/"
+
ptl
.
getSetName
()
+
"/"
+
ptl
.
getCard
()
->
getCorrectedName
()
+
".full"
<<
_picsPath
+
"/downloadedPics/"
+
ptl
.
getSetName
()
+
"/"
+
ptl
.
getCard
()
->
getCorrectedName
()
+
".full"
;
QString
setName
=
ptl
.
getSetName
();
if
(
!
setName
.
isEmpty
())
{
picsPaths
<<
_picsPath
+
"/"
+
setName
+
"/"
+
ptl
.
getCard
()
->
getCorrectedName
()
+
".full"
<<
_picsPath
+
"/downloadedPics/"
+
setName
+
"/"
+
ptl
.
getCard
()
->
getCorrectedName
()
+
".full"
;
}
QImage
image
;
QImage
image
;
QImageReader
imgReader
;
QImageReader
imgReader
;
...
@@ -166,6 +180,10 @@ QString PictureLoader::getPicUrl(CardInfo *card)
...
@@ -166,6 +180,10 @@ QString PictureLoader::getPicUrl(CardInfo *card)
CardSet
*
set
=
card
->
getPreferredSet
();
CardSet
*
set
=
card
->
getPreferredSet
();
QString
picUrl
=
QString
(
""
);
QString
picUrl
=
QString
(
""
);
// if sets have been defined for the card, they can contain custom picUrls
if
(
set
)
{
// first check if Hq is enabled and a custom Hq card url exists in cards.xml
// first check if Hq is enabled and a custom Hq card url exists in cards.xml
if
(
picDownloadHq
)
if
(
picDownloadHq
)
{
{
...
@@ -178,6 +196,7 @@ QString PictureLoader::getPicUrl(CardInfo *card)
...
@@ -178,6 +196,7 @@ QString PictureLoader::getPicUrl(CardInfo *card)
picUrl
=
card
->
getCustomPicURL
(
set
->
getShortName
());
picUrl
=
card
->
getCustomPicURL
(
set
->
getShortName
());
if
(
!
picUrl
.
isEmpty
())
if
(
!
picUrl
.
isEmpty
())
return
picUrl
;
return
picUrl
;
}
// otherwise, fallback to the default url
// otherwise, fallback to the default url
picUrl
=
picDownloadHq
?
settingsCache
->
getPicUrlHq
()
:
settingsCache
->
getPicUrl
();
picUrl
=
picDownloadHq
?
settingsCache
->
getPicUrlHq
()
:
settingsCache
->
getPicUrl
();
...
@@ -456,6 +475,8 @@ void CardInfo::updatePixmapCache()
...
@@ -456,6 +475,8 @@ void CardInfo::updatePixmapCache()
CardSet
*
CardInfo
::
getPreferredSet
()
CardSet
*
CardInfo
::
getPreferredSet
()
{
{
if
(
sets
.
isEmpty
())
return
0
;
SetList
sortedSets
=
sets
;
SetList
sortedSets
=
sets
;
sortedSets
.
sortByKey
();
sortedSets
.
sortByKey
();
return
sortedSets
.
first
();
return
sortedSets
.
first
();
...
@@ -463,7 +484,8 @@ CardSet* CardInfo::getPreferredSet()
...
@@ -463,7 +484,8 @@ CardSet* CardInfo::getPreferredSet()
int
CardInfo
::
getPreferredMuId
()
int
CardInfo
::
getPreferredMuId
()
{
{
return
muIds
[
getPreferredSet
()
->
getShortName
()];
CardSet
*
set
=
getPreferredSet
();
return
set
?
muIds
[
set
->
getShortName
()]
:
0
;
}
}
QString
CardInfo
::
simplifyName
(
const
QString
&
name
)
{
QString
CardInfo
::
simplifyName
(
const
QString
&
name
)
{
...
...
cockatrice/src/carddatabase.h
View file @
3bce98e3
...
@@ -55,7 +55,7 @@ public:
...
@@ -55,7 +55,7 @@ public:
PictureToLoad
(
CardInfo
*
_card
=
0
,
bool
_stripped
=
false
,
bool
_hq
=
true
);
PictureToLoad
(
CardInfo
*
_card
=
0
,
bool
_stripped
=
false
,
bool
_hq
=
true
);
CardInfo
*
getCard
()
const
{
return
card
;
}
CardInfo
*
getCard
()
const
{
return
card
;
}
bool
getStripped
()
const
{
return
stripped
;
}
bool
getStripped
()
const
{
return
stripped
;
}
QString
getSetName
()
const
{
return
sortedSets
[
setIndex
]
->
getCorrectedShortName
();
}
QString
getSetName
()
const
;
bool
nextSet
();
bool
nextSet
();
bool
getHq
()
const
{
return
hq
;
}
bool
getHq
()
const
{
return
hq
;
}
void
setHq
(
bool
_hq
)
{
hq
=
_hq
;
}
void
setHq
(
bool
_hq
)
{
hq
=
_hq
;
}
...
...
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