Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
8b5c33ce
Commit
8b5c33ce
authored
Feb 20, 2019
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Instance: use std::unique_ptr<> to manage the Database pointer
parent
6c28adbc
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
13 additions
and
14 deletions
+13
-14
Instance.cxx
src/Instance.cxx
+1
-1
Instance.hxx
src/Instance.hxx
+3
-3
Main.cxx
src/Main.cxx
+3
-4
StateFile.cxx
src/StateFile.cxx
+1
-1
Stats.cxx
src/Stats.cxx
+1
-1
OtherCommands.cxx
src/command/OtherCommands.cxx
+1
-1
StorageCommands.cxx
src/command/StorageCommands.cxx
+2
-2
StorageState.cxx
src/storage/StorageState.cxx
+1
-1
No files found.
src/Instance.cxx
View file @
8b5c33ce
...
...
@@ -58,7 +58,7 @@ Instance::~Instance() noexcept
if
(
database
!=
nullptr
)
{
database
->
Close
();
d
elete
database
;
d
atabase
.
reset
()
;
}
delete
storage
;
...
...
src/Instance.hxx
View file @
8b5c33ce
...
...
@@ -41,7 +41,7 @@ class NeighborGlue;
#ifdef ENABLE_DATABASE
#include "db/DatabaseListener.hxx"
class
Database
;
#include "db/Ptr.hxx"
class
Storage
;
class
UpdateService
;
#endif
...
...
@@ -104,7 +104,7 @@ struct Instance final
#endif
#ifdef ENABLE_DATABASE
Database
*
database
;
Database
Ptr
database
;
/**
* This is really a #CompositeStorage. To avoid heavy include
...
...
@@ -155,7 +155,7 @@ struct Instance final
* music_directory was configured).
*/
Database
*
GetDatabase
()
{
return
database
;
return
database
.
get
()
;
}
/**
...
...
src/Main.cxx
View file @
8b5c33ce
...
...
@@ -188,7 +188,7 @@ glue_db_init_and_load(const ConfigData &config)
instance
->
database
=
CreateConfiguredDatabase
(
config
,
instance
->
event_loop
,
instance
->
io_thread
.
GetEventLoop
(),
*
instance
)
.
release
()
;
*
instance
);
if
(
instance
->
database
==
nullptr
)
return
true
;
...
...
@@ -196,8 +196,7 @@ glue_db_init_and_load(const ConfigData &config)
InitStorage
(
config
,
instance
->
io_thread
.
GetEventLoop
());
if
(
instance
->
storage
==
nullptr
)
{
delete
instance
->
database
;
instance
->
database
=
nullptr
;
instance
->
database
.
reset
();
LogDefault
(
config_domain
,
"Found database setting without "
"music_directory - disabling database"
);
...
...
@@ -216,7 +215,7 @@ glue_db_init_and_load(const ConfigData &config)
std
::
throw_with_nested
(
std
::
runtime_error
(
"Failed to open database plugin"
));
}
auto
*
db
=
dynamic_cast
<
SimpleDatabase
*>
(
instance
->
database
);
auto
*
db
=
dynamic_cast
<
SimpleDatabase
*>
(
instance
->
database
.
get
()
);
if
(
db
==
nullptr
)
return
true
;
...
...
src/StateFile.cxx
View file @
8b5c33ce
...
...
@@ -119,7 +119,7 @@ try {
TextFile
file
(
config
.
path
);
#ifdef ENABLE_DATABASE
const
SongLoader
song_loader
(
partition
.
instance
.
database
,
const
SongLoader
song_loader
(
partition
.
instance
.
GetDatabase
()
,
partition
.
instance
.
storage
);
#else
const
SongLoader
song_loader
(
nullptr
,
nullptr
);
...
...
src/Stats.cxx
View file @
8b5c33ce
...
...
@@ -124,7 +124,7 @@ stats_print(Response &r, const Partition &partition)
std
::
lround
(
partition
.
pc
.
GetTotalPlayTime
().
count
()));
#ifdef ENABLE_DATABASE
const
Database
*
db
=
partition
.
instance
.
database
;
const
Database
*
db
=
partition
.
instance
.
GetDatabase
()
;
if
(
db
!=
nullptr
)
db_stats_print
(
r
,
*
db
);
#endif
...
...
src/command/OtherCommands.cxx
View file @
8b5c33ce
...
...
@@ -294,7 +294,7 @@ handle_update(Client &client, Request args, Response &r, bool discard)
if
(
update
!=
nullptr
)
return
handle_update
(
r
,
*
update
,
path
,
discard
);
Database
*
db
=
client
.
GetInstance
().
database
;
Database
*
db
=
client
.
GetInstance
().
GetDatabase
()
;
if
(
db
!=
nullptr
)
return
handle_update
(
r
,
*
db
,
path
,
discard
);
#else
...
...
src/command/StorageCommands.cxx
View file @
8b5c33ce
...
...
@@ -209,7 +209,7 @@ handle_mount(Client &client, Request args, Response &r)
instance
.
EmitIdle
(
IDLE_MOUNT
);
#ifdef ENABLE_DATABASE
if
(
auto
*
db
=
dynamic_cast
<
SimpleDatabase
*>
(
instance
.
database
))
{
if
(
auto
*
db
=
dynamic_cast
<
SimpleDatabase
*>
(
instance
.
GetDatabase
()
))
{
try
{
db
->
Mount
(
local_uri
,
remote_uri
);
}
catch
(...)
{
...
...
@@ -253,7 +253,7 @@ handle_unmount(Client &client, Request args, Response &r)
destroy here */
instance
.
update
->
CancelMount
(
local_uri
);
if
(
auto
*
db
=
dynamic_cast
<
SimpleDatabase
*>
(
instance
.
database
))
{
if
(
auto
*
db
=
dynamic_cast
<
SimpleDatabase
*>
(
instance
.
GetDatabase
()
))
{
if
(
db
->
Unmount
(
local_uri
))
// TODO: call Instance::OnDatabaseModified()?
instance
.
EmitIdle
(
IDLE_DATABASE
);
...
...
src/storage/StorageState.cxx
View file @
8b5c33ce
...
...
@@ -106,7 +106,7 @@ storage_state_restore(const char *line, TextFile &file, Instance &instance)
return
true
;
}
if
(
auto
*
db
=
dynamic_cast
<
SimpleDatabase
*>
(
instance
.
database
))
{
if
(
auto
*
db
=
dynamic_cast
<
SimpleDatabase
*>
(
instance
.
GetDatabase
()
))
{
try
{
db
->
Mount
(
uri
.
c_str
(),
url
.
c_str
());
}
catch
(...)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment