Compare commits
3 Commits
master
...
bstoeger-s
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2f044039dd | ||
|
|
515f76e9a9 | ||
|
|
f831027d65 |
@ -91,6 +91,7 @@ static void print_help()
|
|||||||
printf("\n --dc-product=product Set the dive computer to download from");
|
printf("\n --dc-product=product Set the dive computer to download from");
|
||||||
printf("\n --device=device Set the device to download from");
|
printf("\n --device=device Set the device to download from");
|
||||||
#endif
|
#endif
|
||||||
|
printf("\n --no-opengl-sharing Don't share OpenGL contexts between QQuickItems (for testing)");
|
||||||
printf("\n --cloud-timeout=<nr> Set timeout for cloud connection (0 < timeout < 60)\n\n");
|
printf("\n --cloud-timeout=<nr> Set timeout for cloud connection (0 < timeout < 60)\n\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -149,6 +150,10 @@ void parse_argument(const char *arg)
|
|||||||
++force_root;
|
++force_root;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (strcmp(arg, "--no-opengl-sharing") == 0) {
|
||||||
|
// This was already checked in main()
|
||||||
|
return;
|
||||||
|
}
|
||||||
#if SUBSURFACE_DOWNLOADER
|
#if SUBSURFACE_DOWNLOADER
|
||||||
if (strncmp(arg, "--dc-vendor=", sizeof("--dc-vendor=") - 1) == 0) {
|
if (strncmp(arg, "--dc-vendor=", sizeof("--dc-vendor=") - 1) == 0) {
|
||||||
prefs.dive_computer.vendor = strdup(arg + sizeof("--dc-vendor=") - 1);
|
prefs.dive_computer.vendor = strdup(arg + sizeof("--dc-vendor=") - 1);
|
||||||
|
|||||||
@ -91,19 +91,24 @@ StatsWidget::StatsWidget(QWidget *parent) : QWidget(parent)
|
|||||||
|
|
||||||
ui.stats->setSource(urlStatsView);
|
ui.stats->setSource(urlStatsView);
|
||||||
ui.stats->setResizeMode(QQuickWidget::SizeRootObjectToView);
|
ui.stats->setResizeMode(QQuickWidget::SizeRootObjectToView);
|
||||||
(void)getView();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// hack around the Qt6 bug where the QML object gets destroyed and recreated
|
// The Qt-developers do not have their ownership management under control.
|
||||||
|
// This is not surprising to anyone who has looked at their source code.
|
||||||
|
// In contradiction to the documentation, starting with Qt6, QQuickItems
|
||||||
|
// _will_ be deleted when the parent widgets are reparented, even when
|
||||||
|
// CppOwnership is set. This can be prevented for OpenGL backends, but not
|
||||||
|
// for others. Therefore, we have to _always_ refetch the view from the QML page.
|
||||||
|
// For details and precise conditions, see comments and code in
|
||||||
|
// QQuickWidgetPrivate::handleWindowChange().
|
||||||
|
// Ultimately, we will have to change the way widgets are hidden/shown in
|
||||||
|
// the MainWindow.
|
||||||
StatsView *StatsWidget::getView()
|
StatsView *StatsWidget::getView()
|
||||||
{
|
{
|
||||||
StatsView *view = qobject_cast<StatsView *>(ui.stats->rootObject());
|
StatsView *view = qobject_cast<StatsView *>(ui.stats->rootObject());
|
||||||
if (!view)
|
if (!view)
|
||||||
qWarning("Oops. The root of the StatsView is not a StatsView.");
|
qWarning("Oops. The root of the StatsView is not a StatsView.");
|
||||||
if (view) {
|
if (view) {
|
||||||
// try to prevent the JS garbage collection from freeing the object
|
|
||||||
// this appears to fail with Qt6 which is why we still look up the
|
|
||||||
// object from the ui.stats rootObject
|
|
||||||
ui.stats->engine()->setObjectOwnership(view, QQmlEngine::CppOwnership);
|
ui.stats->engine()->setObjectOwnership(view, QQmlEngine::CppOwnership);
|
||||||
view->setParent(this);
|
view->setParent(this);
|
||||||
view->setVisible(isVisible()); // Synchronize visibility of widget and QtQuick-view.
|
view->setVisible(isVisible()); // Synchronize visibility of widget and QtQuick-view.
|
||||||
|
|||||||
@ -13,6 +13,7 @@
|
|||||||
#include "core/qt-gui.h"
|
#include "core/qt-gui.h"
|
||||||
#include "core/qthelper.h"
|
#include "core/qthelper.h"
|
||||||
#include "core/subsurfacestartup.h"
|
#include "core/subsurfacestartup.h"
|
||||||
|
#include "core/subsurface-string.h"
|
||||||
#include "core/settings/qPref.h"
|
#include "core/settings/qPref.h"
|
||||||
#include "core/tag.h"
|
#include "core/tag.h"
|
||||||
#include "desktop-widgets/mainwindow.h"
|
#include "desktop-widgets/mainwindow.h"
|
||||||
@ -38,9 +39,22 @@ int main(int argc, char **argv)
|
|||||||
if (verbose) /* print the version if the Win32 console_init() code enabled verbose. */
|
if (verbose) /* print the version if the Win32 console_init() code enabled verbose. */
|
||||||
print_version();
|
print_version();
|
||||||
|
|
||||||
int i;
|
|
||||||
bool no_filenames = true;
|
bool no_filenames = true;
|
||||||
QLoggingCategory::setFilterRules(QStringLiteral("qt.bluetooth* = true"));
|
QLoggingCategory::setFilterRules(QStringLiteral("qt.bluetooth* = true"));
|
||||||
|
|
||||||
|
// Allow OpenGL-based QtQuick backends to share OpenGL contexts.
|
||||||
|
// This avoids destruction of QQuickItems if their parent widgets are moved between widgets in Qt6.
|
||||||
|
// Sadly, this does not help when running on non-OpenGL backends.
|
||||||
|
// Allow for turning this off to test destruction of QQuickItems.
|
||||||
|
// The parameter is checked here because QCoreApplication::parameters() only
|
||||||
|
// works after instantiation of the QApplication class, but the flag has
|
||||||
|
// to be set bofore.
|
||||||
|
if (std::any_of(argv + 1, argv + argc,
|
||||||
|
[](char *arg) { return same_string(arg, "--no-opengl-sharing"); })) {
|
||||||
|
fprintf(stderr, "Disabling sharing of OpenGL contexts\n");
|
||||||
|
} else {
|
||||||
|
QGuiApplication::setAttribute(Qt::AA_ShareOpenGLContexts);
|
||||||
|
}
|
||||||
std::unique_ptr<QApplication> app(new QApplication(argc, argv));
|
std::unique_ptr<QApplication> app(new QApplication(argc, argv));
|
||||||
QStringList files;
|
QStringList files;
|
||||||
QStringList importedFiles;
|
QStringList importedFiles;
|
||||||
@ -50,7 +64,7 @@ int main(int argc, char **argv)
|
|||||||
const char *default_filename = system_default_filename();
|
const char *default_filename = system_default_filename();
|
||||||
subsurface_mkdir(default_directory);
|
subsurface_mkdir(default_directory);
|
||||||
|
|
||||||
for (i = 1; i < arguments.length(); i++) {
|
for (int i = 1; i < arguments.length(); i++) {
|
||||||
QString a = arguments.at(i);
|
QString a = arguments.at(i);
|
||||||
if (a.isEmpty())
|
if (a.isEmpty())
|
||||||
continue;
|
continue;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user