Bug fix to avoid null pointer access.
Clean up. git-svn-id: file:///srv/svn/repos/haiku/trunk/current@1201 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
b0ab449a96
commit
d16c075486
|
@ -82,7 +82,7 @@ Job::Job(const BEntry& job, BHandler* handler)
|
|||
p = c; c ++;
|
||||
}
|
||||
// and get time from file name
|
||||
fTime = atoi(p+1);
|
||||
if (p) fTime = atoi(p+1);
|
||||
}
|
||||
|
||||
// start watching the node
|
||||
|
@ -179,7 +179,7 @@ bool Folder::AddJob(BEntry& entry) {
|
|||
Job* job = new Job(entry, this);
|
||||
if (job->InitCheck() == B_OK) {
|
||||
fJobs.AddItem(job);
|
||||
if (job->IsValid() && job->IsWaiting()) NotifyPrinter();
|
||||
if (job->IsValid() && job->IsWaiting()) NotifyPrintServer();
|
||||
return true;
|
||||
} else {
|
||||
job->Release();
|
||||
|
@ -227,7 +227,7 @@ void Folder::AttributeChanged(BMessage* msg) {
|
|||
Job* job = Find(node);
|
||||
if (job) {
|
||||
job->UpdateAttribute();
|
||||
if (job->IsValid() && job->IsWaiting()) NotifyPrinter();
|
||||
if (job->IsValid() && job->IsWaiting()) NotifyPrintServer();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -252,7 +252,8 @@ void Folder::HandleNodeMonitorMessage(BMessage* msg) {
|
|||
}
|
||||
}
|
||||
|
||||
void Folder::NotifyPrinter() {
|
||||
// Notify print_server that there is a job file waiting for printing
|
||||
void Folder::NotifyPrintServer() {
|
||||
be_app_messenger.SendMessage(PSRV_PRINT_SPOOLED_JOB);
|
||||
}
|
||||
|
||||
|
@ -323,8 +324,6 @@ Job* Folder::GetNextJob() {
|
|||
for (int i = 0; i < fJobs.CountItems(); i ++) {
|
||||
Job* job = fJobs.ItemAt(i);
|
||||
if (job->IsValid() && job->IsWaiting()) {
|
||||
/*fJobs.RemoveItem(job);
|
||||
job->StopNodeWatching();*/
|
||||
job->Acquire(); return job;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,15 +40,16 @@
|
|||
#include <String.h>
|
||||
#include <StorageDefs.h>
|
||||
|
||||
enum JobStatus {
|
||||
kWaiting, // to be processed
|
||||
kProcessing, // processed by a printer add-on
|
||||
kFailed, // failed to process the job file
|
||||
kUnknown, // other
|
||||
enum JobStatus { // job file
|
||||
kWaiting, // to be processed
|
||||
kProcessing, // processed by a printer add-on
|
||||
kFailed, // failed to process the job file
|
||||
kUnknown, // other
|
||||
};
|
||||
|
||||
class Printer;
|
||||
|
||||
// Job file in printer folder
|
||||
class Job : public Object {
|
||||
private:
|
||||
BHandler* fHandler; // the handler that watches the node of the job file
|
||||
|
@ -80,7 +81,7 @@ public:
|
|||
bool IsWaiting() const { return fStatus == kWaiting; }
|
||||
Printer* GetPrinter() const { return fPrinter; }
|
||||
|
||||
// modification
|
||||
// modifiers
|
||||
void SetPrinter(Printer* p) { fPrinter = p; }
|
||||
void SetStatus(JobStatus s, bool writeToNode = true);
|
||||
void UpdateAttribute();
|
||||
|
@ -91,6 +92,8 @@ public:
|
|||
};
|
||||
|
||||
|
||||
// Printer folder watches creation, deletion and attribute changes of job files
|
||||
// and notifies print_server if a job is waiting for processing
|
||||
class Folder : public BHandler {
|
||||
typedef BHandler inherited;
|
||||
|
||||
|
@ -109,7 +112,7 @@ private:
|
|||
void AttributeChanged(BMessage* msg);
|
||||
void HandleNodeMonitorMessage(BMessage* msg);
|
||||
|
||||
void NotifyPrinter();
|
||||
void NotifyPrintServer();
|
||||
|
||||
void SetupJobList();
|
||||
|
||||
|
@ -119,6 +122,8 @@ public:
|
|||
|
||||
void MessageReceived(BMessage* msg);
|
||||
|
||||
BDirectory* GetSpoolDir() { return &fSpoolDir; }
|
||||
|
||||
// Caller is responsible to set the status of the job appropriately
|
||||
// and to release the object when done
|
||||
Job* GetNextJob();
|
||||
|
|
Loading…
Reference in New Issue