From 58e0585b9bdcabc7bd08184ca2711ed5dbc56db2 Mon Sep 17 00:00:00 2001 From: ZXGuesser Date: Wed, 17 Jul 2019 22:56:21 +0100 Subject: [PATCH] set erase and update flags when a file has changed and the page gets reloaded by filemonitor --- filemonitor.cpp | 1 + packetmag.cpp | 2 ++ ttxpage.cpp | 3 ++- ttxpage.h | 4 ++++ 4 files changed, 9 insertions(+), 1 deletion(-) diff --git a/filemonitor.cpp b/filemonitor.cpp index f2a5ccf..ffe5613 100644 --- a/filemonitor.cpp +++ b/filemonitor.cpp @@ -114,6 +114,7 @@ void FileMonitor::run() // lock q->LoadPage(name); // What if this fails? We can see the bool. What to do ? q->IncrementUpdateCount(); + q->SetFileChangedFlag(); q->GetPageCount(); // renumber the subpages int mag=(q->GetPageNumber() >> 16) & 0x7; diff --git a/packetmag.cpp b/packetmag.cpp index e1b3c7a..61d39b4 100644 --- a/packetmag.cpp +++ b/packetmag.cpp @@ -168,6 +168,8 @@ Packet* PacketMag::GetPacket(Packet* p) if (_page->Changed()) { _status|=PAGESTATUS_C8_UPDATE; + + _status|=PAGESTATUS_C4_ERASEPAGE; // also set the erase flag } } diff --git a/ttxpage.cpp b/ttxpage.cpp index db5c4e7..08cd3c9 100644 --- a/ttxpage.cpp +++ b/ttxpage.cpp @@ -80,7 +80,8 @@ TTXPage::TTXPage(std::string filename) : bool TTXPage::Changed() { - bool changed=false; + bool changed=_fileChanged; // begin with file change state + _fileChanged=false; // clear the flag for (uint8_t row=1;row<=MAXROW;row++) { TTXLine* line=GetRow(row); diff --git a/ttxpage.h b/ttxpage.h index a186006..02d8a97 100644 --- a/ttxpage.h +++ b/ttxpage.h @@ -225,6 +225,8 @@ class TTXPage * This is NOT the same as pageChanged. */ bool Changed(); + + void SetFileChangedFlag(){_fileChanged=true;}; void SetSelected(bool value){_Selected=value;}; /// Set the selected state to value bool Selected(){return _Selected;}; /// Return the selected state @@ -286,6 +288,8 @@ class TTXPage bool m_LoadTTX(std::string filename); bool _Selected; /// True if this page has been selected. + + bool _fileChanged; // page was reloaded by the filemonitor };