mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
media: move addition of pictures out of create_picture()
If we want to make addition of pictures undoable, then create_picture() must not add directly to the dive. Instead, return the dive to which the picture should be added and let the caller perform the addition. This means that the picture-test has to be adapted. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
0935513636
commit
74f03e3537
4 changed files with 45 additions and 25 deletions
|
|
@ -22,7 +22,7 @@ void TestPicture::initTestCase()
|
|||
|
||||
void TestPicture::addPicture()
|
||||
{
|
||||
struct dive *dive;
|
||||
struct dive *dive, *dive1, *dive2;
|
||||
struct picture *pic1, *pic2;
|
||||
verbose = 1;
|
||||
|
||||
|
|
@ -34,9 +34,19 @@ void TestPicture::addPicture()
|
|||
// So far no picture in dive
|
||||
QVERIFY(dive->pictures.nr == 0);
|
||||
|
||||
create_picture(SUBSURFACE_TEST_DATA "/dives/images/wreck.jpg", 0, false);
|
||||
create_picture(SUBSURFACE_TEST_DATA "/dives/images/data_after_EOI.jpg", 0, false);
|
||||
// Now there are two picture2
|
||||
pic1 = create_picture(SUBSURFACE_TEST_DATA "/dives/images/wreck.jpg", 0, false, &dive1);
|
||||
pic2 = create_picture(SUBSURFACE_TEST_DATA "/dives/images/data_after_EOI.jpg", 0, false, &dive2);
|
||||
QVERIFY(pic1 != NULL);
|
||||
QVERIFY(pic2 != NULL);
|
||||
QVERIFY(dive1 == dive);
|
||||
QVERIFY(dive2 == dive);
|
||||
|
||||
add_picture(&dive->pictures, *pic1);
|
||||
add_picture(&dive->pictures, *pic2);
|
||||
free(pic1);
|
||||
free(pic2);
|
||||
|
||||
// Now there are two pictures
|
||||
QVERIFY(dive->pictures.nr == 2);
|
||||
pic1 = &dive->pictures.pictures[0];
|
||||
pic2 = &dive->pictures.pictures[1];
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue