From 74f03e3537ee530000d4b11013bb12de91cb21dd Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Sun, 19 Apr 2020 16:48:53 +0200 Subject: 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 --- tests/testpicture.cpp | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'tests') diff --git a/tests/testpicture.cpp b/tests/testpicture.cpp index 7bd683523..b5c6ae22a 100644 --- a/tests/testpicture.cpp +++ b/tests/testpicture.cpp @@ -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]; -- cgit v1.2.3-70-g09d2