Ignore:
Timestamp:
2019-07-07T01:56:46+02:00 (5 years ago)
Author:
Don-vip
Message:

see #17848 - update to metadata-extractor 2.12.0

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/com/drew/metadata/tiff/DirectoryTiffHandler.java

    r13061 r15217  
    11/*
    2  * Copyright 2002-2017 Drew Noakes
     2 * Copyright 2002-2019 Drew Noakes and contributors
    33 *
    44 *    Licensed under the Apache License, Version 2.0 (the "License");
     
    2424import com.drew.lang.Rational;
    2525import com.drew.lang.annotations.NotNull;
     26import com.drew.lang.annotations.Nullable;
    2627import com.drew.metadata.Directory;
    2728import com.drew.metadata.ErrorDirectory;
     
    4041    private final Stack<Directory> _directoryStack = new Stack<Directory>();
    4142
    42     protected Directory _currentDirectory;
     43    @Nullable private Directory _rootParentDirectory;
     44    @Nullable protected Directory _currentDirectory;
    4345    protected final Metadata _metadata;
    4446
    45     protected DirectoryTiffHandler(Metadata metadata)
     47    protected DirectoryTiffHandler(Metadata metadata, @Nullable Directory parentDirectory)
    4648    {
    4749        _metadata = metadata;
     50        _rootParentDirectory = parentDirectory;
    4851    }
    4952
     
    5558    protected void pushDirectory(@NotNull Class<? extends Directory> directoryClass)
    5659    {
    57         Directory newDirectory = null;
     60        Directory newDirectory;
    5861
    5962        try {
     
    6568        }
    6669
    67         if (newDirectory != null)
    68         {
    69             // If this is the first directory, don't add to the stack
    70             if (_currentDirectory != null)
    71             {
    72                 _directoryStack.push(_currentDirectory);
    73                 newDirectory.setParent(_currentDirectory);
     70        // If this is the first directory, don't add to the stack
     71        if (_currentDirectory == null) {
     72            // Apply any pending root parent to this new directory
     73            if (_rootParentDirectory != null) {
     74                newDirectory.setParent(_rootParentDirectory);
     75                _rootParentDirectory = null;
    7476            }
    75             _currentDirectory = newDirectory;
    76             _metadata.addDirectory(_currentDirectory);
    7777        }
     78        else {
     79            // The current directory is pushed onto the stack, and set as the new directory's parent
     80            _directoryStack.push(_currentDirectory);
     81            newDirectory.setParent(_currentDirectory);
     82        }
     83
     84        _currentDirectory = newDirectory;
     85        _metadata.addDirectory(_currentDirectory);
    7886    }
    7987
Note: See TracChangeset for help on using the changeset viewer.