<commit_before>#include "helpers.h"
#include <QDir>
#include <QMessageBox>
#include <QProcess>
#if defined(Q_OS_MAC)
	#include <QStringList>
#elif !defined(Q_OS_WIN)
	#include <QDesktopServices>
	#include <QUrl>
#endif


/**
 * Popup a message notifying the user that something went wrong.
 * @param	parent	The parent widget
 * @param	error	The error message
 */
void error(QWidget *parent, const QString &error)
{
	QMessageBox::critical(parent, QObject::tr("Error"), error);
}

/**
 * Opens the file explorer and select the file.
 * @param	pathIn	The path to the file.
 */
void showInGraphicalShell(const QString &pathIn)
{
	// Mac & Windows support folder or file.
	#if defined(Q_OS_WIN)
		QString param;
		if (!QFileInfo(pathIn).isDir())
		{ param = QLatin1String("/select,"); }
		param += QDir::toNativeSeparators(pathIn);
		QProcess::startDetached("explorer.exe "+param);
	#elif defined(Q_OS_MAC)
		// Q_UNUSED(parent)
		QStringList scriptArgs;
		scriptArgs << QLatin1String("-e") << QString::fromLatin1("tell application \"Finder\" to reveal POSIX file \"%1\"").arg(pathIn);
		QProcess::execute(QLatin1String("/usr/bin/osascript"), scriptArgs);
		scriptArgs.clear();
		scriptArgs << QLatin1String("-e") << QLatin1String("tell application \"Finder\" to activate");
		QProcess::execute("/usr/bin/osascript", scriptArgs);
	#else
		QDesktopServices::openUrl(QUrl("file:///"+pathIn));
	#endif
}

void clearLayout(QLayout *layout)
{
	if (layout == nullptr)
		return;

	while (layout->count() > 0)
	{
		QLayoutItem *item = layout->takeAt(0);
		if (item->layout())
		{
			clearLayout(item->layout());
			item->layout()->deleteLater();
		}
		item->widget()->deleteLater();
		delete item;
	}
}<commit_msg>Fix 'Unexpected null receiver' warning when clearing QFormLayout<commit_after>#include "helpers.h"
#include <QDir>
#include <QMessageBox>
#include <QProcess>
#if defined(Q_OS_MAC)
	#include <QStringList>
#elif !defined(Q_OS_WIN)
	#include <QDesktopServices>
	#include <QUrl>
#endif


/**
 * Popup a message notifying the user that something went wrong.
 * @param	parent	The parent widget
 * @param	error	The error message
 */
void error(QWidget *parent, const QString &error)
{
	QMessageBox::critical(parent, QObject::tr("Error"), error);
}

/**
 * Opens the file explorer and select the file.
 * @param	pathIn	The path to the file.
 */
void showInGraphicalShell(const QString &pathIn)
{
	// Mac & Windows support folder or file.
	#if defined(Q_OS_WIN)
		QString param;
		if (!QFileInfo(pathIn).isDir())
		{ param = QLatin1String("/select,"); }
		param += QDir::toNativeSeparators(pathIn);
		QProcess::startDetached("explorer.exe "+param);
	#elif defined(Q_OS_MAC)
		// Q_UNUSED(parent)
		QStringList scriptArgs;
		scriptArgs << QLatin1String("-e") << QString::fromLatin1("tell application \"Finder\" to reveal POSIX file \"%1\"").arg(pathIn);
		QProcess::execute(QLatin1String("/usr/bin/osascript"), scriptArgs);
		scriptArgs.clear();
		scriptArgs << QLatin1String("-e") << QLatin1String("tell application \"Finder\" to activate");
		QProcess::execute("/usr/bin/osascript", scriptArgs);
	#else
		QDesktopServices::openUrl(QUrl("file:///"+pathIn));
	#endif
}

void clearLayout(QLayout *layout)
{
	if (layout == nullptr)
		return;

	while (layout->count() > 0)
	{
		QLayoutItem *item = layout->takeAt(0);
		if (item->layout())
		{
			clearLayout(item->layout());
			item->layout()->deleteLater();
		}
		if (item->widget())
		{ item->widget()->deleteLater(); }
		delete item;
	}
}
{'fraction_non_alphanumeric': 0.16326530612244897, 'fraction_numerical': 0.005173900546133947, 'mean_word_length': 5.0311958405545925, 'pattern_counts': {'":': 0, '<': 31, '<?xml version=': 0, '>': 34, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3470500', 'n_tokens_mistral': 1261, 'n_tokens_neox': 1186, 'n_words': 279}