* keep the USBPrinterRoster as a member or local to better control stop and deletion. Should fix #6916.
* style cleanup git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39685 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
150b717e5b
commit
25be3898d1
@ -79,14 +79,13 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
USBPrinter *fPrinter;
|
USBPrinter *fPrinter;
|
||||||
|
USBPrinterRoster *fRoster;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// Set transport_features so we stay loaded
|
// Set transport_features so we stay loaded
|
||||||
uint32 transport_features = B_TRANSPORT_IS_HOTPLUG;
|
uint32 transport_features = B_TRANSPORT_IS_HOTPLUG;
|
||||||
|
|
||||||
USBPrinterRoster gUSBPrinterRoster;
|
|
||||||
|
|
||||||
|
|
||||||
USBPrinterRoster::USBPrinterRoster()
|
USBPrinterRoster::USBPrinterRoster()
|
||||||
{
|
{
|
||||||
@ -233,8 +232,8 @@ USBPrinter::Read(void *buf, size_t size)
|
|||||||
BDataIO *
|
BDataIO *
|
||||||
instantiate_transport(BDirectory *printer, BMessage *msg)
|
instantiate_transport(BDirectory *printer, BMessage *msg)
|
||||||
{
|
{
|
||||||
USBTransport * transport = new USBTransport(printer, msg);
|
USBTransport *transport = new(std::nothrow) USBTransport(printer, msg);
|
||||||
if (transport->InitCheck() == B_OK)
|
if (transport != NULL && transport->InitCheck() == B_OK)
|
||||||
return transport;
|
return transport;
|
||||||
|
|
||||||
delete transport;
|
delete transport;
|
||||||
@ -246,7 +245,10 @@ instantiate_transport(BDirectory *printer, BMessage *msg)
|
|||||||
status_t
|
status_t
|
||||||
list_transport_ports(BMessage *msg)
|
list_transport_ports(BMessage *msg)
|
||||||
{
|
{
|
||||||
return gUSBPrinterRoster.ListPrinters(msg);
|
USBPrinterRoster roster;
|
||||||
|
status_t status = roster.ListPrinters(msg);
|
||||||
|
roster.Stop();
|
||||||
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -256,15 +258,19 @@ USBTransport::USBTransport(BDirectory *printer, BMessage *msg)
|
|||||||
{
|
{
|
||||||
BString key;
|
BString key;
|
||||||
|
|
||||||
if (printer->ReadAttrString("transport_address", &key) < 0)
|
if (printer->ReadAttrString("transport_address", &key) != B_OK)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
fPrinter = gUSBPrinterRoster.Printer(key.String());
|
fRoster = new(std::nothrow) USBPrinterRoster;
|
||||||
if (!fPrinter)
|
if (fRoster == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
fPrinter = fRoster->Printer(key.String());
|
||||||
|
if (fPrinter == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// If caller doesn't care...
|
// If caller doesn't care...
|
||||||
if (!msg)
|
if (msg == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Fill up the message
|
// Fill up the message
|
||||||
@ -274,7 +280,10 @@ USBTransport::USBTransport(BDirectory *printer, BMessage *msg)
|
|||||||
|
|
||||||
USBTransport::~USBTransport()
|
USBTransport::~USBTransport()
|
||||||
{
|
{
|
||||||
gUSBPrinterRoster.Stop();
|
if (fRoster != NULL) {
|
||||||
|
fRoster->Stop();
|
||||||
|
delete fRoster;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user