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:
@@ -82,7 +82,7 @@ Job::Job(const BEntry& job, BHandler* handler)
|
|||||||
p = c; c ++;
|
p = c; c ++;
|
||||||
}
|
}
|
||||||
// and get time from file name
|
// and get time from file name
|
||||||
fTime = atoi(p+1);
|
if (p) fTime = atoi(p+1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// start watching the node
|
// start watching the node
|
||||||
@@ -179,7 +179,7 @@ bool Folder::AddJob(BEntry& entry) {
|
|||||||
Job* job = new Job(entry, this);
|
Job* job = new Job(entry, this);
|
||||||
if (job->InitCheck() == B_OK) {
|
if (job->InitCheck() == B_OK) {
|
||||||
fJobs.AddItem(job);
|
fJobs.AddItem(job);
|
||||||
if (job->IsValid() && job->IsWaiting()) NotifyPrinter();
|
if (job->IsValid() && job->IsWaiting()) NotifyPrintServer();
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
job->Release();
|
job->Release();
|
||||||
@@ -227,7 +227,7 @@ void Folder::AttributeChanged(BMessage* msg) {
|
|||||||
Job* job = Find(node);
|
Job* job = Find(node);
|
||||||
if (job) {
|
if (job) {
|
||||||
job->UpdateAttribute();
|
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);
|
be_app_messenger.SendMessage(PSRV_PRINT_SPOOLED_JOB);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -323,8 +324,6 @@ Job* Folder::GetNextJob() {
|
|||||||
for (int i = 0; i < fJobs.CountItems(); i ++) {
|
for (int i = 0; i < fJobs.CountItems(); i ++) {
|
||||||
Job* job = fJobs.ItemAt(i);
|
Job* job = fJobs.ItemAt(i);
|
||||||
if (job->IsValid() && job->IsWaiting()) {
|
if (job->IsValid() && job->IsWaiting()) {
|
||||||
/*fJobs.RemoveItem(job);
|
|
||||||
job->StopNodeWatching();*/
|
|
||||||
job->Acquire(); return job;
|
job->Acquire(); return job;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,7 +40,7 @@
|
|||||||
#include <String.h>
|
#include <String.h>
|
||||||
#include <StorageDefs.h>
|
#include <StorageDefs.h>
|
||||||
|
|
||||||
enum JobStatus {
|
enum JobStatus { // job file
|
||||||
kWaiting, // to be processed
|
kWaiting, // to be processed
|
||||||
kProcessing, // processed by a printer add-on
|
kProcessing, // processed by a printer add-on
|
||||||
kFailed, // failed to process the job file
|
kFailed, // failed to process the job file
|
||||||
@@ -49,6 +49,7 @@ enum JobStatus {
|
|||||||
|
|
||||||
class Printer;
|
class Printer;
|
||||||
|
|
||||||
|
// Job file in printer folder
|
||||||
class Job : public Object {
|
class Job : public Object {
|
||||||
private:
|
private:
|
||||||
BHandler* fHandler; // the handler that watches the node of the job file
|
BHandler* fHandler; // the handler that watches the node of the job file
|
||||||
@@ -80,7 +81,7 @@ public:
|
|||||||
bool IsWaiting() const { return fStatus == kWaiting; }
|
bool IsWaiting() const { return fStatus == kWaiting; }
|
||||||
Printer* GetPrinter() const { return fPrinter; }
|
Printer* GetPrinter() const { return fPrinter; }
|
||||||
|
|
||||||
// modification
|
// modifiers
|
||||||
void SetPrinter(Printer* p) { fPrinter = p; }
|
void SetPrinter(Printer* p) { fPrinter = p; }
|
||||||
void SetStatus(JobStatus s, bool writeToNode = true);
|
void SetStatus(JobStatus s, bool writeToNode = true);
|
||||||
void UpdateAttribute();
|
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 {
|
class Folder : public BHandler {
|
||||||
typedef BHandler inherited;
|
typedef BHandler inherited;
|
||||||
|
|
||||||
@@ -109,7 +112,7 @@ private:
|
|||||||
void AttributeChanged(BMessage* msg);
|
void AttributeChanged(BMessage* msg);
|
||||||
void HandleNodeMonitorMessage(BMessage* msg);
|
void HandleNodeMonitorMessage(BMessage* msg);
|
||||||
|
|
||||||
void NotifyPrinter();
|
void NotifyPrintServer();
|
||||||
|
|
||||||
void SetupJobList();
|
void SetupJobList();
|
||||||
|
|
||||||
@@ -119,6 +122,8 @@ public:
|
|||||||
|
|
||||||
void MessageReceived(BMessage* msg);
|
void MessageReceived(BMessage* msg);
|
||||||
|
|
||||||
|
BDirectory* GetSpoolDir() { return &fSpoolDir; }
|
||||||
|
|
||||||
// Caller is responsible to set the status of the job appropriately
|
// Caller is responsible to set the status of the job appropriately
|
||||||
// and to release the object when done
|
// and to release the object when done
|
||||||
Job* GetNextJob();
|
Job* GetNextJob();
|
||||||
|
|||||||
Reference in New Issue
Block a user