From 8f4fba95c0f39992cc1aac046a4a0c9804e0a3b4 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sat, 27 Jul 2019 10:47:46 +0200 Subject: [PATCH] CIODevice: Add a virtual did_update_fd() no notify subclasses of fd change. This will allow subclasses to react when the file descriptor changes. --- Libraries/LibCore/CIODevice.cpp | 9 +++++++++ Libraries/LibCore/CIODevice.h | 4 +++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/Libraries/LibCore/CIODevice.cpp b/Libraries/LibCore/CIODevice.cpp index 394050d9a0..edfe7ba3c5 100644 --- a/Libraries/LibCore/CIODevice.cpp +++ b/Libraries/LibCore/CIODevice.cpp @@ -241,3 +241,12 @@ int CIODevice::printf(const char* format, ...) va_end(ap); return ret; } + +void CIODevice::set_fd(int fd) +{ + if (m_fd == fd) + return; + + m_fd = fd; + did_update_fd(fd); +} diff --git a/Libraries/LibCore/CIODevice.h b/Libraries/LibCore/CIODevice.h index 1c8dac5831..2af344542c 100644 --- a/Libraries/LibCore/CIODevice.h +++ b/Libraries/LibCore/CIODevice.h @@ -56,11 +56,13 @@ public: protected: explicit CIODevice(CObject* parent = nullptr); - void set_fd(int fd) { m_fd = fd; } + void set_fd(int); void set_mode(OpenMode mode) { m_mode = mode; } void set_error(int error) { m_error = error; } void set_eof(bool eof) { m_eof = eof; } + virtual void did_update_fd(int) {} + private: bool populate_read_buffer(); bool can_read_from_fd() const;