db/upnp: move the UPnPDeviceDirectory instance to class UpnpDatabase
Delete the object when closing the database.
This commit is contained in:
parent
a827714823
commit
1a09003a6e
|
@ -163,9 +163,10 @@ UpnpDatabase::Open(Error &error)
|
|||
if (!m_lib)
|
||||
return false;
|
||||
|
||||
m_superdir = UPnPDeviceDirectory::getTheDir();
|
||||
if (!m_superdir || !m_superdir->ok()) {
|
||||
error.Set(upnp_domain, "Discovery services startup failed");
|
||||
m_superdir = new UPnPDeviceDirectory();
|
||||
if (!m_superdir->ok()) {
|
||||
error.Set(m_superdir->GetError());
|
||||
delete m_superdir;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -180,7 +181,8 @@ void
|
|||
UpnpDatabase::Close()
|
||||
{
|
||||
delete m_root;
|
||||
// TBD decide what we do with the lib and superdir objects
|
||||
delete m_superdir;
|
||||
// TBD decide what we do with the lib object
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -275,17 +275,6 @@ UPnPDeviceDirectory::search()
|
|||
return true;
|
||||
}
|
||||
|
||||
UPnPDeviceDirectory *UPnPDeviceDirectory::getTheDir()
|
||||
{
|
||||
// TODO: elimate static variable
|
||||
static UPnPDeviceDirectory *theDevDir;
|
||||
if (theDevDir == nullptr)
|
||||
theDevDir = new UPnPDeviceDirectory();
|
||||
if (theDevDir && !theDevDir->ok())
|
||||
return 0;
|
||||
return theDevDir;
|
||||
}
|
||||
|
||||
bool
|
||||
UPnPDeviceDirectory::getDirServices(std::vector<ContentDirectoryService> &out)
|
||||
{
|
||||
|
|
|
@ -46,14 +46,12 @@ class UPnPDeviceDirectory {
|
|||
|
||||
time_t m_lastSearch;
|
||||
|
||||
UPnPDeviceDirectory();
|
||||
public:
|
||||
UPnPDeviceDirectory();
|
||||
|
||||
UPnPDeviceDirectory(const UPnPDeviceDirectory &) = delete;
|
||||
UPnPDeviceDirectory& operator=(const UPnPDeviceDirectory &) = delete;
|
||||
|
||||
/** This class is a singleton. Get the instance here */
|
||||
static UPnPDeviceDirectory *getTheDir();
|
||||
|
||||
/** Retrieve the directory services currently seen on the network */
|
||||
bool getDirServices(std::vector<ContentDirectoryService> &);
|
||||
|
||||
|
|
Loading…
Reference in New Issue