[education/rkward] rkward/plugin: Fix error message for optional components
Thomas Friedrichsmeier
null at kde.org
Sat Sep 7 22:35:28 BST 2024
Git commit c53cb0957645626ab8026c98d04ffceb3551ea19 by Thomas Friedrichsmeier.
Committed on 07/09/2024 at 21:35.
Pushed by tfry into branch 'master'.
Fix error message for optional components
M +13 -3 rkward/plugin/rkcomponentmap.cpp
M +1 -0 rkward/plugin/rkcomponentmap.h
https://invent.kde.org/education/rkward/-/commit/c53cb0957645626ab8026c98d04ffceb3551ea19
diff --git a/rkward/plugin/rkcomponentmap.cpp b/rkward/plugin/rkcomponentmap.cpp
index e86169213..ee71904e2 100644
--- a/rkward/plugin/rkcomponentmap.cpp
+++ b/rkward/plugin/rkcomponentmap.cpp
@@ -83,8 +83,9 @@ void RKComponentGUIXML::resolveComponentLabelsAndSortMenu (Menu *menu, const QSt
Entry *entry = group->entries[j];
if (!entry->is_menu) {
RKComponentHandle* handle = RKComponentMap::getComponentHandle (entry->id);
- if (!handle) {
- RK_DEBUG (PLUGIN, DL_ERROR, "No such component found while creating menu-entries or component is not a standalone plugin: \"%s\". No entry created.", qPrintable (entry->id));
+ if (!handle || handle->isNull()) {
+ // HACK: handle->isNull() signifies optional component. Do not warn (but do no place in menu, either).
+ if (!handle) RK_DEBUG (PLUGIN, DL_ERROR, "No such component found while creating menu-entries or component is not a standalone plugin: \"%s\". No entry created.", qPrintable (entry->id));
delete (group->entries.takeAt (j));
--j;
continue;
@@ -637,7 +638,14 @@ RKPluginMapParseResult RKComponentMap::addPluginMap (const QString& plugin_map_f
if (!cdependencies.isNull ()) {
if (!RKComponentDependency::isRKWardVersionCompatible (cdependencies)) {
RK_DEBUG (PLUGIN, DL_INFO, "Skipping component '%1': Not compatible with this version of RKWard", qPrintable (id));
- if (!xml.getBoolAttribute((*it), "optional", false, DL_INFO)) depfailed_local_components.insert(id);
+ if (xml.getBoolAttribute((*it), "optional", false, DL_INFO)) {
+ // HACK: Unavailable optional components are represented by a null handle, which will then be ignored while
+ // creating menu entries
+ RKComponentHandle *handle = new RKComponentHandle(pluginmap_file_desc, QString(), QString());
+ components.insert(id, handle);
+ } else {
+ depfailed_local_components.insert(id);
+ }
continue;
}
}
@@ -838,6 +846,8 @@ QString RKComponentHandle::getPluginmapFilename () const {
RKComponentAboutData RKComponentHandle::getAboutData () {
RK_TRACE (PLUGIN);
+ if (isNull()) return RKComponentAboutData();
+
// NOTE: In order to determine the message catalog to use, we have to open the pluginmap file...
XMLHelper pluginmap_xml (getPluginmapFilename ());
QDomElement pluginmap_doc = pluginmap_xml.openXMLFile (DL_ERROR);
diff --git a/rkward/plugin/rkcomponentmap.h b/rkward/plugin/rkcomponentmap.h
index aa18b0305..f4e83e6cc 100644
--- a/rkward/plugin/rkcomponentmap.h
+++ b/rkward/plugin/rkcomponentmap.h
@@ -67,6 +67,7 @@ public:
QString getFilename () const { return plugin_map->makeFileName (filename); };
QString getLabel () const { return label; };
QString getPluginmapFilename () const;
+ bool isNull() const { return filename.isNull(); };
RKStandardComponent *invoke (RKComponent *parent_component, QWidget *parent_widget);
More information about the rkward-tracker
mailing list