@@ -104,18 +104,21 @@ class PiMock {
104
104
// Create new mock plugin platform and plugin handles
105
105
// Note: Mock plugin will be generated if it has not been yet.
106
106
MPlatformImpl = GetMockPlatformImpl ();
107
- const detail::plugin &OriginalPiPlugin = MPlatformImpl->getPlugin ();
108
- // Copy the PiPlugin, thus untying our to-be mock platform from other
109
- // platforms within the context. Reset our platform to use the new plugin.
110
- auto NewPluginPtr = std::make_shared<detail::plugin>(
111
- OriginalPiPlugin.getPiPluginPtr (), OriginalPiPlugin.getBackend (),
112
- OriginalPiPlugin.getLibraryHandle ());
107
+ std::shared_ptr<detail::plugin> NewPluginPtr;
108
+ {
109
+ const detail::plugin &OriginalPiPlugin = MPlatformImpl->getPlugin ();
110
+ // Copy the PiPlugin, thus untying our to-be mock platform from other
111
+ // platforms within the context. Reset our platform to use the new plugin.
112
+ NewPluginPtr = std::make_shared<detail::plugin>(
113
+ OriginalPiPlugin.getPiPluginPtr (), OriginalPiPlugin.getBackend (),
114
+ OriginalPiPlugin.getLibraryHandle ());
115
+ // Save a copy of the platform resource
116
+ OrigFuncTable = OriginalPiPlugin.getPiPlugin ().PiFunctionTable ;
117
+ }
113
118
MPlatformImpl->setPlugin (NewPluginPtr);
114
119
// Extract the new PiPlugin instance by a non-const pointer,
115
120
// explicitly allowing modification
116
121
MPiPluginMockPtr = &NewPluginPtr->getPiPlugin ();
117
- // Save a copy of the platform resource
118
- OrigFuncTable = OriginalPiPlugin.getPiPlugin ().PiFunctionTable ;
119
122
}
120
123
121
124
PiMock (PiMock &&Other) {
0 commit comments