diff --git a/bepdf/Makefile b/bepdf/Makefile index e9f8719..62e465c 100644 --- a/bepdf/Makefile +++ b/bepdf/Makefile @@ -112,7 +112,8 @@ SYSTEM_INCLUDE_PATHS = ../xpdf \ ../xpdf/goo \ ../xpdf/splash \ ../xpdf/xpdf \ - /system/develop/headers/private/interface + /system/develop/headers/private/interface \ + /system/develop/headers/private/storage # Additional paths paths to look for local headers. These use the form # #include "header". Directories that contain the files in SRCS are @@ -147,7 +148,7 @@ SYMBOLS := # Includes debug information, which allows the binary to be debugged easily. # If set to "TRUE", debug info will be created. -DEBUGGER := +DEBUGGER := # Specify any additional compiler flags to be used. COMPILER_FLAGS = -Wno-write-strings diff --git a/bepdf/beos/EntryChangedMonitor.cpp b/bepdf/beos/EntryChangedMonitor.cpp index 984fc5c..3db00d9 100644 --- a/bepdf/beos/EntryChangedMonitor.cpp +++ b/bepdf/beos/EntryChangedMonitor.cpp @@ -42,38 +42,37 @@ void EntryChangedMonitor::StartWatching(entry_ref *ref) { mEntryRef = *ref; mActive = true; - BNode node(ref); - if (node.InitCheck() == B_OK && - node.GetNodeRef(&mNodeRef) == B_OK) { - watch_node(&mNodeRef, B_WATCH_STAT, this); + BEntry entry(ref); + BPath path; + if (entry.InitCheck() == B_OK && + entry.GetPath(&path) == B_OK) { + BPathMonitor::StartWatching(path.Path(),B_WATCH_STAT,this); } } void EntryChangedMonitor::StopWatching() { if (mActive) { - watch_node(&mNodeRef, B_STOP_WATCHING, this); + BEntry entry(&mEntryRef); + BPath path; + entry.GetPath(&path); + BPathMonitor::StopWatching(path.Path(), this); + mActive = false; } } void EntryChangedMonitor::MessageReceived(BMessage* msg) { - if (msg->what != B_NODE_MONITOR) + if (msg->what != B_PATH_MONITOR) return; int32 opcode; if (msg->FindInt32("opcode", &opcode) != B_OK) return; - if (opcode != B_STAT_CHANGED) + if (opcode != B_STAT_CHANGED ) return; - // Haiku sends a B_STAT_CHANGED notification - // when attributes are changed too - // this leads to an infinite loop, as - // BePDF changes file attributes after - // loading a file. - // TODO check if file has changed and only - // then notify the listener + NotifyListener(); } void EntryChangedMonitor::NotifyListener() { diff --git a/bepdf/beos/EntryChangedMonitor.h b/bepdf/beos/EntryChangedMonitor.h index 270c9fa..ac8c944 100644 --- a/bepdf/beos/EntryChangedMonitor.h +++ b/bepdf/beos/EntryChangedMonitor.h @@ -23,10 +23,10 @@ #ifndef ENTRY_CHANGED_MONITOR_H #define ENTRY_CHANGED_MONITOR_H -#include -#include #include -#include +#include +#include +#include class EntryChangedListener { public: @@ -59,7 +59,6 @@ class EntryChangedMonitor : public BHandler { EntryChangedListener* mListener; bool mActive; entry_ref mEntryRef; - node_ref mNodeRef; }; -#endif \ No newline at end of file +#endif diff --git a/bepdf/beos/PDFWindow.cpp b/bepdf/beos/PDFWindow.cpp index 2e84ee4..128ac3f 100644 --- a/bepdf/beos/PDFWindow.cpp +++ b/bepdf/beos/PDFWindow.cpp @@ -344,6 +344,10 @@ bool PDFWindow::IsCurrentFile(entry_ref *ref) const { /////////////////////////////////////////////////////////// bool PDFWindow::LoadFile(entry_ref *ref, const char *ownerPassword, const char *userPassword, bool *encrypted) { if (mMainView != NULL) { + // Haiku sends a B_STAT_CHANGED notification + // when attributes are changed too + // that's why we stop watching when changing attributes + mEntryChangedMonitor.StopWatching(); StoreFileAttributes(); CleanUpBeforeLoad(); // load new file @@ -354,6 +358,10 @@ bool PDFWindow::LoadFile(entry_ref *ref, const char *ownerPassword, const char * InitAfterOpen(); return true; } + //If unable to load the new ref, watch again + entry_ref oldRef; + if (mCurrentFile.GetRef(&oldRef) == B_OK) + mEntryChangedMonitor.StartWatching(&oldRef); } return false; }