From 769e27340f180b02b7622e452de75659b73ea41f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Fri, 26 Jun 2020 12:53:52 +0200 Subject: [PATCH] Trade: AbstractImporter::importerState() expects a file to be opened. The restriction was there always, but was undocumented and untested. --- src/Magnum/Trade/AbstractImporter.h | 5 +++-- src/Magnum/Trade/Test/AbstractImporterTest.cpp | 6 +++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/Magnum/Trade/AbstractImporter.h b/src/Magnum/Trade/AbstractImporter.h index a83e03e86..39dfec9c6 100644 --- a/src/Magnum/Trade/AbstractImporter.h +++ b/src/Magnum/Trade/AbstractImporter.h @@ -280,8 +280,8 @@ checked by the implementation: - The @ref doSetFileCallback() function is called only if @ref ImporterFeature::FileCallback is supported and there is no file opened. -- All `do*()` implementations working on an opened file are called only if - there is any file opened. +- All `do*()` implementations working on an opened file as well as + @ref doImporterState() are called only if there is any file opened. - All `do*()` implementations taking data ID as parameter are called only if the ID is from valid range. - For @ref doMesh() and `doImage*()` and @p level parameter being nonzero, @@ -1280,6 +1280,7 @@ class MAGNUM_TRADE_EXPORT AbstractImporter: public PluginManager::AbstractManagi * for currently opened document through this function. See * documentation of a particular plugin for more information about * returned type and contents. Returns @cpp nullptr @ce by default. + * Expects that a file is opened. * @see @ref AbstractMaterialData::importerState(), * @ref AnimationData::importerState(), @ref CameraData::importerState(), * @ref ImageData::importerState(), @ref LightData::importerState(), diff --git a/src/Magnum/Trade/Test/AbstractImporterTest.cpp b/src/Magnum/Trade/Test/AbstractImporterTest.cpp index a2ef717fb..d71d54210 100644 --- a/src/Magnum/Trade/Test/AbstractImporterTest.cpp +++ b/src/Magnum/Trade/Test/AbstractImporterTest.cpp @@ -1297,6 +1297,8 @@ void AbstractImporterTest::thingNoFile() { importer.image3D(42); importer.image3D("foo"); + importer.importerState(); + CORRADE_COMPARE(out.str(), "Trade::AbstractImporter::defaultScene(): no file opened\n" "Trade::AbstractImporter::scene(): no file opened\n" @@ -1325,7 +1327,9 @@ void AbstractImporterTest::thingNoFile() { "Trade::AbstractImporter::image2D(): no file opened\n" "Trade::AbstractImporter::image2D(): no file opened\n" "Trade::AbstractImporter::image3D(): no file opened\n" - "Trade::AbstractImporter::image3D(): no file opened\n"); + "Trade::AbstractImporter::image3D(): no file opened\n" + + "Trade::AbstractImporter::importerState(): no file opened\n"); } void AbstractImporterTest::defaultScene() {