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
Graphics
digiKam
Commits
4a7af86f
Commit
4a7af86f
authored
Aug 28, 2011
by
Marcel Wiesweg
Browse files
Fail early if an ImageTagPair is created with either invalid image id or invalid tag id
CCBUG: 277169
parent
094f1be0
Changes
1
Hide whitespace changes
Inline
Side-by-side
libs/database/imagetagpair.cpp
View file @
4a7af86f
...
...
@@ -27,6 +27,10 @@
#include
<QSharedData>
// KDE includes
#include
<kdebug.h>
// Local includes
#include
"albumdb.h"
...
...
@@ -41,6 +45,8 @@ class ImageTagPairPriv : public QSharedData
{
public:
static
ImageTagPairPriv
*
createGuarded
(
qlonglong
imageId
,
int
tagId
);
ImageTagPairPriv
()
{
tagId
=
-
1
;
...
...
@@ -66,8 +72,22 @@ public:
};
K_GLOBAL_STATIC
(
ImageTagPairPrivSharedNull
,
imageTagPairPrivSharedNull
)
ImageTagPairPriv
*
ImageTagPairPriv
::
createGuarded
(
qlonglong
imageId
,
int
tagId
)
{
if
(
imageId
<=
0
||
tagId
<=
0
)
{
kDebug
()
<<
"Attempt to create invalid tag pair image id"
<<
imageId
<<
"tag id"
<<
tagId
;
return
*
imageTagPairPrivSharedNull
;
}
return
new
ImageTagPairPriv
;
}
void
ImageTagPairPriv
::
init
(
const
ImageInfo
&
i
,
int
t
)
{
if
(
this
==
*
imageTagPairPrivSharedNull
)
{
return
;
}
tagId
=
t
;
info
=
i
;
isAssigned
=
info
.
tagIds
().
contains
(
tagId
);
...
...
@@ -92,13 +112,13 @@ ImageTagPair::ImageTagPair()
}
ImageTagPair
::
ImageTagPair
(
qlonglong
imageId
,
int
tagId
)
:
d
(
new
ImageTagPairPriv
)
:
d
(
ImageTagPairPriv
::
createGuarded
(
imageId
,
tagId
)
)
{
d
->
init
(
ImageInfo
(
imageId
),
tagId
);
}
ImageTagPair
::
ImageTagPair
(
const
ImageInfo
&
info
,
int
tagId
)
:
d
(
new
ImageTagPairPriv
)
:
d
(
ImageTagPairPriv
::
createGuarded
(
info
.
id
(),
tagId
)
)
{
d
->
init
(
info
,
tagId
);
}
...
...
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