Index: src/plugin/PluginClass.cpp |
=================================================================== |
--- a/src/plugin/PluginClass.cpp |
+++ b/src/plugin/PluginClass.cpp |
@@ -23,7 +23,6 @@ |
#include "PluginFilter.h" |
#include "PluginMimeFilterClient.h" |
#include "PluginClient.h" |
-#include "PluginClientFactory.h" |
#include "PluginMutex.h" |
#include "sddl.h" |
#include "PluginUtil.h" |
@@ -47,7 +46,7 @@ |
uint32_t iconHeight = 32; |
uint32_t iconWidth = 32; |
-CPluginMimeFilterClient* CPluginClass::s_mimeFilter = NULL; |
+std::shared_ptr<CPluginMimeFilterClient> CPluginClass::s_mimeFilter = NULL; |
CLOSETHEMEDATA pfnClose = NULL; |
DRAWTHEMEBACKGROUND pfnDrawThemeBackground = NULL; |
@@ -247,7 +246,10 @@ |
s_criticalSectionLocal.Lock(); |
{ |
// Always register on startup, then check if we need to unregister in a separate thread |
- s_mimeFilter = CPluginClientFactory::GetMimeFilterClientInstance(); |
+ if (!s_mimeFilter) |
+ { |
+ s_mimeFilter.reset(new CPluginMimeFilterClient()); |
+ } |
s_asyncWebBrowser2 = unknownSite; |
s_instances.insert(this); |
} |
@@ -320,11 +322,6 @@ |
{ |
s_threadInstances.erase(it); |
} |
- if (s_instances.empty()) |
- { |
- // TODO: Explicitly releasing a resource when a container becomes empty looks like a job better suited for shared_ptr |
- CPluginClientFactory::ReleaseMimeFilterClientInstance(); |
- } |
} |
s_criticalSectionLocal.Unlock(); |
@@ -630,7 +627,7 @@ |
if (!settings->GetPluginEnabled()) |
{ |
- s_mimeFilter->Unregister(); |
+ s_mimeFilter.reset(); |
} |
// Load theme module |
@@ -1089,13 +1086,11 @@ |
{ |
if (settings->GetPluginEnabled()) |
{ |
- s_mimeFilter = CPluginClientFactory::GetMimeFilterClientInstance(); |
+ s_mimeFilter.reset(new CPluginMimeFilterClient()); |
} |
else |
{ |
- s_mimeFilter = NULL; |
- |
- CPluginClientFactory::ReleaseMimeFilterClientInstance(); |
+ s_mimeFilter.reset(); |
} |
} |
s_criticalSectionLocal.Unlock(); |