Skip to content

Commit

Permalink
Merge 0824e43 into 9b1b7b0
Browse files Browse the repository at this point in the history
  • Loading branch information
peci1 authored Oct 25, 2023
2 parents 9b1b7b0 + 0824e43 commit a4cef4a
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 5 deletions.
4 changes: 4 additions & 0 deletions include/gz/gui/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -75,5 +75,9 @@ target_link_libraries(${PROJECT_LIBRARY_TARGET_NAME}
TINYXML2::TINYXML2
)

target_compile_definitions(${PROJECT_LIBRARY_TARGET_NAME} PRIVATE
SHARED_LIBRARY_PREFIX=\"${CMAKE_SHARED_LIBRARY_PREFIX}\"
SHARED_LIBRARY_SUFFIX=\"${CMAKE_SHARED_LIBRARY_SUFFIX}\")

gz_install_all_headers()

15 changes: 12 additions & 3 deletions src/Application.cc
Original file line number Diff line number Diff line change
Expand Up @@ -843,10 +843,19 @@ std::vector<std::pair<std::string, std::vector<std::string>>>
{
auto plugin = common::basename(*dirIter);

// All we verify is that the file starts with "lib", any further
// checks would require loading the plugin.
// All we verify is that the file starts with shared library prefix and
// ends with shared library suffix, any further checks would require
// loading the plugin.

if (plugin.find("lib") == 0)
// TODO(anyone): Move this logic into gz-plugin to be reusable

// This computation could underflow the unsigned range, but that is okay
// as in such case we would check if the suffix is placed somewhere much
// further than allowed filename length.
const auto suffixPos = plugin.length() - strlen(SHARED_LIBRARY_SUFFIX);

if (plugin.find(SHARED_LIBRARY_PREFIX) == 0 &&
plugin.rfind(SHARED_LIBRARY_SUFFIX) == suffixPos)
ps.push_back(plugin);
}

Expand Down
9 changes: 7 additions & 2 deletions src/MainWindow.cc
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,13 @@ QStringList MainWindow::PluginListModel() const
{
for (auto const &plugin : path.second)
{
// Remove lib and .so
auto pluginName = plugin.substr(3, plugin.find(".") - 3);
// TODO(anyone): Move this into gz-plugin to be reusable

// Remove shared library prefix and shared library suffix
auto pluginName = plugin.substr(
strlen(SHARED_LIBRARY_PREFIX),
plugin.length() - strlen(SHARED_LIBRARY_PREFIX) -
strlen(SHARED_LIBRARY_SUFFIX));

// Split WWWCamelCase3D -> WWW Camel Case 3D
std::regex reg("(\\B[A-Z][a-z])|(\\B[0-9])");
Expand Down

0 comments on commit a4cef4a

Please sign in to comment.