11// This file is part of BowPad.
22//
3- // Copyright (C) 2014-2016, 2020-2023 - Stefan Kueng
3+ // Copyright (C) 2014-2016, 2020-2023, 2025 - Stefan Kueng
44//
55// This program is free software: you can redistribute it and/or modify
66// it under the terms of the GNU General Public License as published by
@@ -58,11 +58,16 @@ void CCmdBookmarks::OnDocumentClose(DocID id)
5858{
5959 auto & settings = CIniSettings::Instance ();
6060 const auto & doc = GetDocumentFromID (id);
61+ auto docPath = doc.m_path ;
6162 if (doc.m_path .empty ())
62- return ;
63+ {
64+ docPath = doc.m_tmpSavePath ;
65+ if (docPath.empty ())
66+ return ;
67+ }
6368
6469 // look if the path is already in our list
65- bool bModified = (m_bookmarks.erase (doc. m_path ) > 0 );
70+ bool bModified = (m_bookmarks.erase (docPath ) > 0 );
6671
6772 // find all bookmarks
6873 std::vector<sptr_t > bookmarkLines;
@@ -76,7 +81,7 @@ void CCmdBookmarks::OnDocumentClose(DocID id)
7681
7782 if (!bookmarkLines.empty ())
7883 {
79- m_bookmarks[doc. m_path ] = std::make_tuple (std::time (nullptr ), std::move (bookmarkLines));
84+ m_bookmarks[docPath ] = std::make_tuple (std::time (nullptr ), std::move (bookmarkLines));
8085 bModified = true ;
8186 }
8287
@@ -123,10 +128,11 @@ void CCmdBookmarks::OnDocumentClose(DocID id)
123128void CCmdBookmarks::OnDocumentOpen (DocID id)
124129{
125130 const CDocument& doc = GetDocumentFromID (id);
131+ auto docPath = doc.m_path ;
126132 if (doc.m_path .empty ())
127133 return ;
128134
129- auto it = m_bookmarks.find (doc. m_path );
135+ auto it = m_bookmarks.find (docPath );
130136 if (it != m_bookmarks.end ())
131137 {
132138 const auto & [time, lines] = it->second ;
0 commit comments