QAbstractFileEngine member classes: sort out construction
QAbstractFileEngine::(Un)?MapExtension(Option|Return) didn't initialize their members in their default constructors. The two Option types were each insantiated in one place that set each field, so give them overt constructors taking the field values. For the Return type, apply NSDMI to its one data member. The code using it does ignore the data member unless extension() succeeds, but a derived class that wronlgy neglects to set it while succeeding would have caused trouble. Disable copy and move for all three, overtly declare the default constructor for the Result. Task-number: QTBUG-122619 Change-Id: I4b30d383c59e52735d54d9f709c532d504bdea60 Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>bb10
parent
6e8f97b83b
commit
2341dc9ad1
|
|
@ -779,10 +779,7 @@ bool QAbstractFileEngine::atEnd() const
|
|||
|
||||
uchar *QAbstractFileEngine::map(qint64 offset, qint64 size, QFile::MemoryMapFlags flags)
|
||||
{
|
||||
MapExtensionOption option;
|
||||
option.offset = offset;
|
||||
option.size = size;
|
||||
option.flags = flags;
|
||||
const MapExtensionOption option(offset, size, flags);
|
||||
MapExtensionReturn r;
|
||||
if (!extension(MapExtension, &option, &r))
|
||||
return nullptr;
|
||||
|
|
@ -803,8 +800,7 @@ uchar *QAbstractFileEngine::map(qint64 offset, qint64 size, QFile::MemoryMapFlag
|
|||
*/
|
||||
bool QAbstractFileEngine::unmap(uchar *address)
|
||||
{
|
||||
UnMapExtensionOption options;
|
||||
options.address = address;
|
||||
const UnMapExtensionOption options(address);
|
||||
return extension(UnMapExtension, &options);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -147,19 +147,26 @@ public:
|
|||
{};
|
||||
|
||||
class MapExtensionOption : public ExtensionOption {
|
||||
Q_DISABLE_COPY_MOVE(MapExtensionOption)
|
||||
public:
|
||||
qint64 offset;
|
||||
qint64 size;
|
||||
QFile::MemoryMapFlags flags;
|
||||
constexpr MapExtensionOption(qint64 off, qint64 sz, QFile::MemoryMapFlags f)
|
||||
: offset(off), size(sz), flags(f) {}
|
||||
};
|
||||
class MapExtensionReturn : public ExtensionReturn {
|
||||
Q_DISABLE_COPY_MOVE(MapExtensionReturn)
|
||||
public:
|
||||
uchar *address;
|
||||
MapExtensionReturn() = default;
|
||||
uchar *address = nullptr;
|
||||
};
|
||||
|
||||
class UnMapExtensionOption : public ExtensionOption {
|
||||
Q_DISABLE_COPY_MOVE(UnMapExtensionOption)
|
||||
public:
|
||||
uchar *address;
|
||||
uchar *address = nullptr;
|
||||
constexpr UnMapExtensionOption(uchar *p) : address(p) {}
|
||||
};
|
||||
|
||||
virtual bool extension(Extension extension, const ExtensionOption *option = nullptr, ExtensionReturn *output = nullptr);
|
||||
|
|
|
|||
Loading…
Reference in New Issue