@@ -149,6 +149,8 @@ class Session
149149 std::shared_ptr<OscilloscopeState> GetOscilloscopeState (std::shared_ptr<Oscilloscope> scope)
150150 {
151151 std::lock_guard<std::mutex> lock (m_scopeMutex);
152+ if (m_oscilloscopes.find (scope) == m_oscilloscopes.end ())
153+ return nullptr ;
152154 return m_oscilloscopes[scope];
153155 }
154156
@@ -158,6 +160,8 @@ class Session
158160 std::shared_ptr<BERTState> GetBERTState (std::shared_ptr<BERT> bert)
159161 {
160162 std::lock_guard<std::mutex> lock (m_scopeMutex);
163+ if (m_berts.find (bert) == m_berts.end ())
164+ return nullptr ;
161165 return m_berts[bert];
162166 }
163167
@@ -167,6 +171,8 @@ class Session
167171 std::shared_ptr<PowerSupplyState> GetPSUState (std::shared_ptr<SCPIPowerSupply> psu)
168172 {
169173 std::lock_guard<std::mutex> lock (m_scopeMutex);
174+ if (m_psus.find (psu) == m_psus.end ())
175+ return nullptr ;
170176 return m_psus[psu];
171177 }
172178
@@ -176,6 +182,8 @@ class Session
176182 std::shared_ptr<FunctionGeneratorState> GetFunctionGeneratorState (std::shared_ptr<FunctionGenerator> awg)
177183 {
178184 std::lock_guard<std::mutex> lock (m_scopeMutex);
185+ if (m_awgs.find (awg) == m_awgs.end ())
186+ return nullptr ;
179187 return m_awgs[awg];
180188 }
181189
@@ -185,6 +193,8 @@ class Session
185193 std::shared_ptr<MultimeterState> GetDmmState (std::shared_ptr<Multimeter> dmm)
186194 {
187195 std::lock_guard<std::mutex> lock (m_scopeMutex);
196+ if (m_meters.find (dmm) == m_meters.end ())
197+ return nullptr ;
188198 return m_meters[dmm];
189199 }
190200
0 commit comments