]> git.lyx.org Git - features.git/commitdiff
Improve these.
authorRichard Heck <rgheck@comcast.net>
Sat, 29 Mar 2008 15:22:58 +0000 (15:22 +0000)
committerRichard Heck <rgheck@comcast.net>
Sat, 29 Mar 2008 15:22:58 +0000 (15:22 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@24038 a592a061-630c-0410-9148-cb99ea01b6c8

src/EmbeddedFiles.cpp
src/EmbeddedFiles.h

index 9202a61d027933669a22e2ad4402705817efbfc8..a6450073cffd0812c48e5b2f12e56c307e07e57b 100644 (file)
@@ -494,8 +494,8 @@ void EmbeddedFileList::registerFile(EmbeddedFile const & file,
        BOOST_ASSERT(!buffer.embedded() || file.enabled());
 
        string newfile = file.absFilename();
-       EmbeddedFile * efp = findFile(newfile);
-       if (efp) {
+       iterator efp = findFile(newfile);
+       if (efp != end()) {
                if (efp->embedded() != file.embedded()) {
                        Alert::error(_("Wrong embedding status."),
                                bformat(_("File %1$s is included in more than one insets, "
@@ -514,27 +514,29 @@ void EmbeddedFileList::registerFile(EmbeddedFile const & file,
 }
 
 
-EmbeddedFile const * EmbeddedFileList::findFile(std::string const & filename) const
+EmbeddedFileList::const_iterator 
+       EmbeddedFileList::findFile(std::string const & filename) const
 {
        // try to find this file from the list
        std::vector<EmbeddedFile>::const_iterator it = begin();
        std::vector<EmbeddedFile>::const_iterator it_end = end();
        for (; it != it_end; ++it)
                if (it->absFilename() == filename)
-                       return &*it;
-       return 0;
+                       return it;
+       return end();
 }
 
 
-EmbeddedFile * EmbeddedFileList::findFile(std::string const & filename)
+EmbeddedFileList::iterator 
+       EmbeddedFileList::findFile(std::string const & filename)
 {
        // try to find this file from the list
        std::vector<EmbeddedFile>::iterator it = begin();
        std::vector<EmbeddedFile>::iterator it_end = end();
        for (; it != it_end; ++it)
                if (it->absFilename() == filename)
-                       return &*it;
-       return 0;
+                       return it;
+       return end();
 }
 
 
index 3dc1550b67989460634d8dc4f4de75607074c968..cca8e5e8e8d762155f1f7744b6d6506496761eeb 100644 (file)
@@ -211,8 +211,8 @@ public:
                Buffer const & buffer);
        /// returns a pointer to the Embedded file representing this object,
        /// or null if not found. The filename should be absolute.
-       EmbeddedFile const * findFile(std::string const & filename) const;
-       EmbeddedFile * findFile(std::string const & filename);
+       const_iterator findFile(std::string const & filename) const;
+       iterator findFile(std::string const & filename);
        /// validate embedded fies after a file is read.
        void validate(Buffer const & buffer);
        /// scan the buffer and get a list of EmbeddedFile