Skip to content

Commit a0eaec1

Browse files
committed
Fix c++ style
1 parent 87bc4b9 commit a0eaec1

File tree

4 files changed

+18
-10
lines changed

4 files changed

+18
-10
lines changed

src/deployers/PluginsDeployerFactory.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,7 @@ std::vector<std::shared_ptr<PluginsDeployer>> PluginsDeployerFactory::getDeploye
4242
return {getInstance<XcbglIntegrationPluginsDeployer>(moduleName)};
4343
}
4444

45-
if (moduleName == "network") {
46-
if (qtMajorVersion == 6) {
47-
// Qt6 has no bearer plugin.
48-
return {getInstance<BasicPluginsDeployer>(moduleName)};
49-
}
45+
if (moduleName == "network" && qtMajorVersion < 6) {
5046
return {getInstance<BearerPluginsDeployer>(moduleName)};
5147
}
5248

src/deployers/PluginsDeployerFactory.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ namespace linuxdeploy {
2323
const boost::filesystem::path qtInstallQmlPath;
2424
const boost::filesystem::path qtTranslationsPath;
2525
const boost::filesystem::path qtDataPath;
26-
const int qtMajorVersion{5};
26+
const int qtMajorVersion;
2727

2828
template<typename T>
2929
std::shared_ptr<PluginsDeployer> getInstance(const std::string& moduleName) {

src/main.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ int main(const int argc, const char *const *const argv) {
105105
return 1;
106106
}
107107

108-
int qtMajorVersion = atoi(qtVersion.c_str());
108+
int qtMajorVersion = std::stoi(qtVersion, nullptr, 10);
109109
if (qtMajorVersion < 5) {
110110
ldLog() << std::endl << LD_WARNING << "Minimum Qt version supported is 5" << std::endl;
111111
qtMajorVersion = 5;
@@ -172,9 +172,9 @@ int main(const int argc, const char *const *const argv) {
172172
return false;
173173
};
174174

175-
const std::vector<QtModule> *qtmodules = qtMajorVersion == 6 ? &Qt6Modules : &Qt5Modules;
175+
const std::vector<QtModule>& qtmodules = getQtModules(qtMajorVersion);
176176

177-
std::copy_if(qtmodules->begin(), qtmodules->end(), std::back_inserter(foundQtModules),
177+
std::copy_if(qtmodules.begin(), qtmodules.end(), std::back_inserter(foundQtModules),
178178
[&matchesQtModule, &libraryNames](const QtModule &module) {
179179
return std::find_if(libraryNames.begin(), libraryNames.end(),
180180
[&matchesQtModule, &module](const std::string &libraryName) {
@@ -188,7 +188,7 @@ int main(const int argc, const char *const *const argv) {
188188
extraPluginsFromEnv = linuxdeploy::util::split(std::string(extraPluginsFromEnvData), ';');
189189

190190
for (const auto& pluginsList : {static_cast<std::vector<std::string>>(extraPlugins.Get()), extraPluginsFromEnv}) {
191-
std::copy_if(qtmodules->begin(), qtmodules->end(), std::back_inserter(extraQtModules),
191+
std::copy_if(qtmodules.begin(), qtmodules.end(), std::back_inserter(extraQtModules),
192192
[&matchesQtModule, &libraryNames, &pluginsList](const QtModule &module) {
193193
return std::find_if(pluginsList.begin(), pluginsList.end(),
194194
[&matchesQtModule, &module](const std::string &libraryName) {

src/qt-modules.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,3 +166,15 @@ static const std::vector<QtModule> Qt6Modules = {
166166
*/
167167

168168
};
169+
170+
static const std::vector<QtModule> EmptyQtModules = {};
171+
172+
inline const std::vector<QtModule>& getQtModules(const int version) {
173+
if (version == 5) {
174+
return Qt5Modules;
175+
}
176+
else if (version == 6) {
177+
return Qt6Modules;
178+
}
179+
return EmptyQtModules;
180+
}

0 commit comments

Comments
 (0)