@@ -9,7 +9,9 @@ namespace PassXYZLib
99{
1010 public class PxDatabase : PwDatabase
1111 {
12- /// <summary>
12+ private PwGroup m_pwCurrentGroup = null ;
13+
14+ /// <summary>
1315 /// If this is <c>true</c>, a database is currently open.
1416 /// </summary>
1517 public new bool IsOpen
@@ -155,31 +157,57 @@ public class PxDatabase : PwDatabase
155157
156158 public PwGroup CurrentGroup
157159 {
158- get {
159- if ( this . RootGroup . Uuid == this . LastSelectedGroup )
160- { return this . RootGroup ; }
160+ get {
161+ if ( RootGroup . Uuid == LastSelectedGroup || LastSelectedGroup . Equals ( PwUuid . Zero ) )
162+ {
163+ LastSelectedGroup = RootGroup . Uuid ;
164+ m_pwCurrentGroup = RootGroup ;
165+ }
166+ return m_pwCurrentGroup ;
167+ }
168+ set {
169+ if ( value == null ) { Debug . Assert ( false ) ; throw new ArgumentNullException ( "value" ) ; }
170+ LastSelectedGroup = value . Uuid ;
171+ if ( RootGroup . Uuid == LastSelectedGroup || LastSelectedGroup . Equals ( PwUuid . Zero ) )
172+ {
173+ LastSelectedGroup = RootGroup . Uuid ;
174+ m_pwCurrentGroup = RootGroup ;
175+ }
161176 else
162- return this . RootGroup . FindGroup ( this . LastSelectedGroup , true ) ;
177+ m_pwCurrentGroup = RootGroup . FindGroup ( LastSelectedGroup , true ) ;
163178 }
164- set { this . LastSelectedGroup = value . Uuid ; }
165179 }
166180
167181 public string CurrentPath
168182 {
169183 get {
170- var group = this . CurrentGroup ;
171- string path = this . CurrentGroup . Name + "/" ;
172-
173- while ( this . RootGroup . Uuid != group . Uuid )
184+ if ( CurrentGroup == null )
174185 {
175- group = group . ParentGroup ;
176- path = group . Name + "/" + path ;
186+ return null ;
177187 }
188+ else
189+ {
190+ var group = CurrentGroup ;
191+ string path = group . Name + "/" ;
178192
179- return path ;
193+ while ( RootGroup . Uuid != group . Uuid )
194+ {
195+ group = group . ParentGroup ;
196+ path = group . Name + "/" + path ;
197+ }
198+
199+ return path ;
200+ }
180201 }
181202 }
182203
204+ /// <summary>
205+ /// Constructs an empty password manager object.
206+ /// </summary>
207+ public PxDatabase ( ) : base ( )
208+ {
209+ }
210+
183211 private void EnsureRecycleBin ( ref PwGroup pgRecycleBin )
184212 {
185213 if ( pgRecycleBin == this . RootGroup )
0 commit comments