[education/rkward] rkward: Build tree layout is different on Windows

Thomas Friedrichsmeier null at kde.org
Sat Jun 25 09:14:17 BST 2022


Git commit 57f90deac2ffc05b85270e0811a129e07d947465 by Thomas Friedrichsmeier.
Committed on 25/06/2022 at 08:14.
Pushed by tfry into branch 'master'.

Build tree layout is different on Windows

M  +12   -5    rkward/misc/rkcommonfunctions.cpp
M  +1    -1    rkward/rkward.cpp
M  +1    -1    rkward/settings/rksettingsmodule.h

https://invent.kde.org/education/rkward/commit/57f90deac2ffc05b85270e0811a129e07d947465

diff --git a/rkward/misc/rkcommonfunctions.cpp b/rkward/misc/rkcommonfunctions.cpp
index d82ac627..db3f0375 100644
--- a/rkward/misc/rkcommonfunctions.cpp
+++ b/rkward/misc/rkcommonfunctions.cpp
@@ -162,14 +162,21 @@ namespace RKCommonFunctions {
 		}
 	}
 
+	static QString findPathFromAppDir(const QStringList &candidates) {
+		for (int i = 0;  i < candidates.size(); ++i) {
+			QString candidate = QCoreApplication::applicationDirPath() + '/' + candidates[i] + '/';
+			if (QFile::exists(candidate)) return candidate;
+		}
+		return QString();
+	}
+
 	QString getRKWardDataDir () {
 		static QString rkward_data_dir;
 		if (rkward_data_dir.isNull ()) {
-			QString inside_build_tree = QCoreApplication::applicationDirPath() + "/rkwardinstall/";
-			QString inside_build_tree2 = QCoreApplication::applicationDirPath() + "/../rkwardinstall/";
-			if (QFile::exists(inside_build_tree) || QFile::exists(inside_build_tree2)) {
+			QString inside_build_tree = findPathFromAppDir(QStringList() << "rkwardinstall" << "../rkwardinstall" << "../rkward/rkwardinstall");
+			if (!inside_build_tree.isEmpty()) {
 				RK_DEBUG(APP, DL_INFO, "Running from inside build tree");
-				rkward_data_dir = QFile::exists(inside_build_tree) ? inside_build_tree : inside_build_tree2;
+				rkward_data_dir = inside_build_tree;
 				return rkward_data_dir;
 			}
 #if (QT_VERSION >= QT_VERSION_CHECK(5, 4, 0))
@@ -186,7 +193,7 @@ namespace RKCommonFunctions {
 				}
 			}
 			rkward_data_dir = "";   // prevents checking again
-			RK_DEBUG(APP, DL_WARNING, "resource.ver not found. Data path(s): %s", qPrintable (QStandardPaths::standardLocations (QStandardPaths::AppDataLocation).join (':')));
+			RK_DEBUG(APP, DL_ERROR, "resource.ver not found. Data path(s): %s", qPrintable (QStandardPaths::standardLocations (QStandardPaths::AppDataLocation).join (':')));
 		}
 		return rkward_data_dir;
 	}
diff --git a/rkward/rkward.cpp b/rkward/rkward.cpp
index 9f502736..cc9cf057 100644
--- a/rkward/rkward.cpp
+++ b/rkward/rkward.cpp
@@ -378,7 +378,7 @@ void RKWardMainWindow::startR () {
 		QString package = QDir (packages_path).absoluteFilePath (packages[i]);
 		if (RKSettingsModuleGeneral::rkwardVersionChanged ()) {
 			RK_DEBUG(APP, DL_INFO, "RKWard version changed. Discarding cached package at %s", qPrintable (package));
-			RK_ASSERT(QFile::remove(package));
+			if(QFileInfo::exists(package)) RK_ASSERT(QFile::remove(package));
 		}
 		if (!QFileInfo::exists(package)) {
 			QString source = RKCommonFunctions::getRKWardDataDir() + "/rpackages/" + packages[i];
diff --git a/rkward/settings/rksettingsmodule.h b/rkward/settings/rksettingsmodule.h
index 521a6058..51deff67 100644
--- a/rkward/settings/rksettingsmodule.h
+++ b/rkward/settings/rksettingsmodule.h
@@ -81,7 +81,7 @@ public:
 	QComboBox* makeDropDown(const LabelList &entries, RKSettingsModuleWidget* _module, int bit_flag_mask = 0) {
 		static_assert(std::is_same<STORAGE_T, int>::value || std::is_same<STORAGE_T, bool>::value, "makeDropDown can only be used for int or bool");
 		if (bit_flag_mask) {
-			return makeDropDownHelper(entries, _module, value & bit_flag_mask, [this, bit_flag_mask](int val){this->value = (T) ((this->value & ~bit_flag_mask) + val);});
+			return makeDropDownHelper(entries, _module, ((int) value) & bit_flag_mask, [this, bit_flag_mask](int val){this->value = (T) ((((int) this->value) & ~bit_flag_mask) + val);});
 		} else {
 			return makeDropDownHelper(entries, _module, (std::is_same<STORAGE_T, bool>::value && value) ? 1 : (int) value, [this](int val){this->value = (T) val;});
 		}


More information about the rkward-tracker mailing list