mirror of https://github.com/odrling/Aegisub
Fix leak of the Options object in agi::Path and potential overwriting of the config file with an out of date version on shutdown
Originally committed to SVN as r5477.
This commit is contained in:
parent
26695a8cc8
commit
c32e372dd4
|
@ -22,24 +22,25 @@
|
|||
#include <vector>
|
||||
#endif
|
||||
|
||||
#include "libaegisub/path.h"
|
||||
|
||||
#include "libaegisub/access.h"
|
||||
#include "libaegisub/log.h"
|
||||
#include "libaegisub/path.h"
|
||||
#include "libaegisub/option.h"
|
||||
#include "libaegisub/option_value.h"
|
||||
|
||||
namespace agi {
|
||||
|
||||
Path::Path(const std::string &file, const std::string& default_path)
|
||||
: path_file(file),
|
||||
path_default(default_path) {
|
||||
opt = new agi::Options(file, default_path);
|
||||
: path_file(file)
|
||||
, path_default(default_path)
|
||||
, opt(new agi::Options(file, default_path, Options::FLUSH_SKIP))
|
||||
{
|
||||
opt->ConfigUser();
|
||||
LOG_D("agi/path") << "New Path object";
|
||||
}
|
||||
|
||||
Path::~Path() {
|
||||
opt->Flush();
|
||||
}
|
||||
|
||||
|
||||
|
@ -71,7 +72,6 @@ void Path::Set(const char *name, const std::string &path) {
|
|||
} catch (OptionErrorNotFound&) {
|
||||
throw PathErrorNotFound("Invalid path key");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
#endif
|
||||
|
||||
#include <libaegisub/exception.h>
|
||||
#include <libaegisub/scoped_ptr.h>
|
||||
|
||||
namespace agi {
|
||||
|
||||
|
@ -97,7 +98,7 @@ private:
|
|||
void Encode(std::string &path);
|
||||
|
||||
/// Options object.
|
||||
Options *opt;
|
||||
scoped_ptr<Options> opt;
|
||||
|
||||
/// @brief Locale files
|
||||
/// @return Locale location
|
||||
|
|
Loading…
Reference in New Issue