Browse Source

Trade: AbstractImporter::importerState() expects a file to be opened.

The restriction was there always, but was undocumented and untested.
pull/454/head
Vladimír Vondruš 6 years ago
parent
commit
769e27340f
  1. 5
      src/Magnum/Trade/AbstractImporter.h
  2. 6
      src/Magnum/Trade/Test/AbstractImporterTest.cpp

5
src/Magnum/Trade/AbstractImporter.h

@ -280,8 +280,8 @@ checked by the implementation:
- The @ref doSetFileCallback() function is called only if - The @ref doSetFileCallback() function is called only if
@ref ImporterFeature::FileCallback is supported and there is no file @ref ImporterFeature::FileCallback is supported and there is no file
opened. opened.
- All `do*()` implementations working on an opened file are called only if - All `do*()` implementations working on an opened file as well as
there is any file opened. @ref doImporterState() are called only if there is any file opened.
- All `do*()` implementations taking data ID as parameter are called only if - All `do*()` implementations taking data ID as parameter are called only if
the ID is from valid range. the ID is from valid range.
- For @ref doMesh() and `doImage*()` and @p level parameter being nonzero, - 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 * for currently opened document through this function. See
* documentation of a particular plugin for more information about * documentation of a particular plugin for more information about
* returned type and contents. Returns @cpp nullptr @ce by default. * returned type and contents. Returns @cpp nullptr @ce by default.
* Expects that a file is opened.
* @see @ref AbstractMaterialData::importerState(), * @see @ref AbstractMaterialData::importerState(),
* @ref AnimationData::importerState(), @ref CameraData::importerState(), * @ref AnimationData::importerState(), @ref CameraData::importerState(),
* @ref ImageData::importerState(), @ref LightData::importerState(), * @ref ImageData::importerState(), @ref LightData::importerState(),

6
src/Magnum/Trade/Test/AbstractImporterTest.cpp

@ -1297,6 +1297,8 @@ void AbstractImporterTest::thingNoFile() {
importer.image3D(42); importer.image3D(42);
importer.image3D("foo"); importer.image3D("foo");
importer.importerState();
CORRADE_COMPARE(out.str(), CORRADE_COMPARE(out.str(),
"Trade::AbstractImporter::defaultScene(): no file opened\n" "Trade::AbstractImporter::defaultScene(): no file opened\n"
"Trade::AbstractImporter::scene(): 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::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::image3D(): no file opened\n"
"Trade::AbstractImporter::importerState(): no file opened\n");
} }
void AbstractImporterTest::defaultScene() { void AbstractImporterTest::defaultScene() {

Loading…
Cancel
Save