Left: | ||
Right: |
OLD | NEW |
---|---|
1 /* | 1 /* |
2 * This file is part of Adblock Plus <https://adblockplus.org/>, | 2 * This file is part of Adblock Plus <https://adblockplus.org/>, |
3 * Copyright (C) 2006-2015 Eyeo GmbH | 3 * Copyright (C) 2006-2015 Eyeo GmbH |
4 * | 4 * |
5 * Adblock Plus is free software: you can redistribute it and/or modify | 5 * Adblock Plus is free software: you can redistribute it and/or modify |
6 * it under the terms of the GNU General Public License version 3 as | 6 * it under the terms of the GNU General Public License version 3 as |
7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
8 * | 8 * |
9 * Adblock Plus is distributed in the hope that it will be useful, | 9 * Adblock Plus is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 * GNU General Public License for more details. | 12 * GNU General Public License for more details. |
13 * | 13 * |
14 * You should have received a copy of the GNU General Public License | 14 * You should have received a copy of the GNU General Public License |
15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. | 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. |
16 */ | 16 */ |
17 | 17 |
18 #include "PluginStdAfx.h" | 18 #include "PluginStdAfx.h" |
19 | 19 |
20 #include "PluginClientFactory.h" | 20 #include "PluginClientFactory.h" |
21 #include "PluginMimeFilterClient.h" | 21 #include "PluginMimeFilterClient.h" |
22 | 22 |
23 | 23 |
24 CPluginMimeFilterClient* CPluginClientFactory::s_mimeFilterInstance = NULL; | 24 CPluginMimeFilterClient* CPluginClientFactory::s_mimeFilterInstance = NULL; |
25 | 25 |
26 CComAutoCriticalSection CPluginClientFactory::s_criticalSection; | 26 CComAutoCriticalSection CPluginClientFactory::s_criticalSection; |
27 | 27 |
28 CPluginMimeFilterClient* CPluginClientFactory ::GetMimeFilterClientInstance() | 28 CPluginMimeFilterClient* CPluginClientFactory ::GetMimeFilterClientInstance() |
sergei
2015/04/01 18:49:32
Right now we don't need this return value anymore,
| |
29 { | 29 { |
30 CPluginMimeFilterClient* localInstance = NULL; | 30 CPluginMimeFilterClient* localInstance = NULL; |
31 | 31 |
32 s_criticalSection.Lock(); | 32 s_criticalSection.Lock(); |
33 { | 33 { |
34 if (!s_mimeFilterInstance) | 34 if (!s_mimeFilterInstance) |
35 { | 35 { |
36 //we cannot copy the client directly into the instance variable | 36 //we cannot copy the client directly into the instance variable |
37 //if the constructor throws we do not want to alter instance | 37 //if the constructor throws we do not want to alter instance |
Eric
2015/03/27 13:35:50
I don't think I had looked at this comment before,
sergei
2015/04/01 18:49:32
Firstly, when CPluginMimeFilterClient throws the e
| |
38 localInstance = new CPluginMimeFilterClient(); | 38 localInstance = new CPluginMimeFilterClient(); |
39 | 39 |
40 s_mimeFilterInstance = localInstance; | 40 s_mimeFilterInstance = localInstance; |
41 } | 41 } |
42 else | 42 else |
43 { | 43 { |
44 localInstance = s_mimeFilterInstance; | 44 localInstance = s_mimeFilterInstance; |
45 } | 45 } |
46 } | 46 } |
47 s_criticalSection.Unlock(); | 47 s_criticalSection.Unlock(); |
48 | 48 |
49 return localInstance; | 49 return localInstance; |
50 } | 50 } |
51 | 51 |
52 void CPluginClientFactory::ReleaseMimeFilterClientInstance() | 52 void CPluginClientFactory::ReleaseMimeFilterClientInstance() |
53 { | 53 { |
54 s_criticalSection.Lock(); | 54 s_criticalSection.Lock(); |
55 { | 55 { |
56 delete s_mimeFilterInstance; | 56 if (s_mimeFilterInstance) |
Eric
2015/03/27 13:35:50
See comment in Plugin.cpp.
| |
57 | 57 { |
58 delete s_mimeFilterInstance; | |
59 } | |
58 s_mimeFilterInstance = NULL; | 60 s_mimeFilterInstance = NULL; |
59 } | 61 } |
60 s_criticalSection.Unlock(); | 62 s_criticalSection.Unlock(); |
61 } | 63 } |
OLD | NEW |