diff --git a/bepdf/beos/BepdfApplication.cpp b/bepdf/beos/BepdfApplication.cpp index ad184fa..cb511d1 100644 --- a/bepdf/beos/BepdfApplication.cpp +++ b/bepdf/beos/BepdfApplication.cpp @@ -577,6 +577,7 @@ void BepdfApplication::RefsReceived(BMessage *msg) BRect rect(mSettings->GetWindowRect()); bool ok; bool encrypted = false; + if (mWindow == NULL) { win = new PDFWindow(&ref, rect, owner, user, &encrypted); ok = win->IsOk(); @@ -591,13 +592,15 @@ void BepdfApplication::RefsReceived(BMessage *msg) if (!encrypted) { BAlert *error = new BAlert(B_TRANSLATE("Error"), B_TRANSLATE("BePDF: Error opening file!"), B_TRANSLATE("Close"), NULL, NULL, B_WIDTH_AS_USUAL, B_STOP_ALERT); error->Go(); - } + if (mWindow == NULL) { // fixme: always true even if a PDF window is already open! + OpenFilePanel(); + } + } else { + new PasswordWindow(&ref, rect, this); + } if (mWindow == NULL) delete win; - if (encrypted) { - new PasswordWindow(&ref, rect, this); - } } else if (mWindow == NULL) { mWindow = win; win->Show(); diff --git a/bepdf/beos/PDFView.cpp b/bepdf/beos/PDFView.cpp index f969d98..da295b6 100644 --- a/bepdf/beos/PDFView.cpp +++ b/bepdf/beos/PDFView.cpp @@ -232,6 +232,9 @@ PDFView::MakeTitleString(BPath* path) { bool PDFView::OpenFile(entry_ref *ref, const char *ownerPassword, const char *userPassword, bool *encrypted) { BEntry entry (ref, true); + if (!entry.Exists()) { + return false; + } BPath path; entry.GetPath (&path); @@ -245,11 +248,8 @@ PDFView::OpenFile(entry_ref *ref, const char *ownerPassword, const char *userPas UpdatePanelDirectory(&path); bool ok = newDoc->isOk(); - // xpdf 3.01 returns false even PDF file is password protected?!? - *encrypted = true; // newDoc->isEncrypted(); -// fprintf(stderr, "ok %s encrypted %s\n", -// ok ? "yes" : "no", -// (*encrypted) ? "yes" : "no"); + *encrypted = newDoc->isEncrypted(); + if (ok) { delete mDoc; mDoc = newDoc;