Skip to content

Commit 2ccea8e

Browse files
authored
Merge pull request #680 from kiwix/fix_windows_compilation
Add a new private constructor not deprecated for Reader.
2 parents 38fc187 + 84587e7 commit 2ccea8e

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

include/reader.h

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,8 @@ class Reader
9494
*
9595
* @param archive The shared pointer to the Archive object.
9696
*/
97-
explicit DEPRECATED Reader(const std::shared_ptr<zim::Archive> archive);
97+
explicit DEPRECATED Reader(const std::shared_ptr<zim::Archive> archive)
98+
: Reader(archive, true) {};
9899
#ifndef _WIN32
99100
explicit DEPRECATED Reader(int fd);
100101
DEPRECATED Reader(int fd, zim::offset_type offset, zim::size_type size);
@@ -490,6 +491,15 @@ class Reader
490491

491492
private:
492493
std::map<const std::string, unsigned int> parseCounterMetadata() const;
494+
495+
// Reader is deprecated, so we've marked the constructor as deprecated.
496+
// But we still need to construct the reader (in our deprecated code)
497+
// To avoid warning because we use deprecated function, we create a
498+
// constructor not deprecated. The `bool marker` is unused, it sole purpose
499+
// is to change the signature to have a different constructor.
500+
// This one is not deprecated and we must use it in our private code.
501+
Reader(const std::shared_ptr<zim::Archive> archive, bool marker);
502+
friend class Library;
493503
};
494504
}
495505

src/library.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ std::shared_ptr<Reader> Library::getReaderById(const std::string& id)
219219
if ( !archive )
220220
return nullptr;
221221

222-
const auto reader = make_shared<Reader>(archive);
222+
const shared_ptr<Reader> reader(new Reader(archive, true));
223223
std::lock_guard<std::mutex> lock(m_mutex);
224224
m_readers[id] = reader;
225225
return reader;

src/reader.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ Reader::Reader(const string zimFilePath)
5252
srand(time(nullptr));
5353
}
5454

55-
Reader::Reader(const std::shared_ptr<zim::Archive> archive)
55+
Reader::Reader(const std::shared_ptr<zim::Archive> archive, bool _marker)
5656
: zimArchive(archive),
5757
zimFilePath(archive->getFilename())
5858
{}

0 commit comments

Comments
 (0)