mirror of
https://github.com/netsurf-browser/netsurf
synced 2024-12-18 18:23:25 +03:00
Core hotlist: A NULL save_path makes the hotlist read-only.
This commit is contained in:
parent
6c726473ef
commit
06baaa9f7c
@ -107,7 +107,7 @@ static nserror hotlist_get_temp_path(const char *path, char **temp_path)
|
||||
|
||||
/* Save the hotlist to to a file at the given path
|
||||
*
|
||||
* \param path Path to save hostlist file to.
|
||||
* \param path Path to save hotlist file to. NULL path is a no-op.
|
||||
* \return NSERROR_OK on success, or appropriate error otherwise
|
||||
*/
|
||||
static nserror hotlist_save(const char *path)
|
||||
@ -115,6 +115,11 @@ static nserror hotlist_save(const char *path)
|
||||
nserror res = NSERROR_OK;
|
||||
char *temp_path;
|
||||
|
||||
/* NULL path is a no-op. */
|
||||
if (path == NULL) {
|
||||
return NSERROR_OK;
|
||||
}
|
||||
|
||||
/* Get path to export to */
|
||||
res = hotlist_get_temp_path(path, &temp_path);
|
||||
if (res != NSERROR_OK) {
|
||||
@ -163,7 +168,7 @@ static void hotlist_schedule_save_cb(void *p)
|
||||
*/
|
||||
static nserror hotlist_schedule_save(void)
|
||||
{
|
||||
if (hl_ctx.save_scheduled == false) {
|
||||
if (hl_ctx.save_scheduled == false && hl_ctx.save_path != NULL) {
|
||||
nserror err = guit->misc->schedule(10 * 1000,
|
||||
hotlist_schedule_save_cb, NULL);
|
||||
if (err != NSERROR_OK) {
|
||||
@ -1285,9 +1290,13 @@ nserror hotlist_init(
|
||||
hl_ctx.default_folder = NULL;
|
||||
|
||||
/* Store the save path */
|
||||
hl_ctx.save_path = strdup(save_path);
|
||||
if (hl_ctx.save_path == NULL) {
|
||||
return NSERROR_NOMEM;
|
||||
if (save_path != NULL) {
|
||||
hl_ctx.save_path = strdup(save_path);
|
||||
if (hl_ctx.save_path == NULL) {
|
||||
return NSERROR_NOMEM;
|
||||
}
|
||||
} else {
|
||||
hl_ctx.save_path = NULL;
|
||||
}
|
||||
|
||||
/* Init. hotlist treeview entry fields */
|
||||
|
@ -41,7 +41,7 @@ struct rect;
|
||||
* hotlist can be queried to ask if URLs are present in the hotlist.
|
||||
*
|
||||
* \param load_path The path to load hotlist from.
|
||||
* \param save_path The path to save hotlist to.
|
||||
* \param save_path The path to save hotlist to, or NULL for read-only.
|
||||
* \return NSERROR_OK on success, appropriate error otherwise
|
||||
*/
|
||||
nserror hotlist_init(
|
||||
|
Loading…
Reference in New Issue
Block a user