Set default surface format before creating lcApplication instance. Fixes #594 , #577.

This commit is contained in:
Leonardo Zide 2021-01-10 11:03:54 -08:00
parent 6bfc4ff9b1
commit 5ca460c0bf
3 changed files with 32 additions and 15 deletions

View file

@ -140,26 +140,20 @@ void lcPreferences::SetInterfaceColors(lcColorTheme ColorTheme)
lcApplication::lcApplication(int& Argc, char** Argv)
: QApplication(Argc, Argv)
{
setApplicationDisplayName("LeoCAD");
setOrganizationDomain("leocad.org");
setOrganizationName("LeoCAD Software");
setApplicationName("LeoCAD");
setApplicationVersion(LC_VERSION_TEXT);
setApplicationDisplayName(QLatin1String("LeoCAD"));
setOrganizationDomain(QLatin1String("leocad.org"));
setOrganizationName(QLatin1String("LeoCAD Software"));
setApplicationName(QLatin1String("LeoCAD"));
setApplicationVersion(QLatin1String(LC_VERSION_TEXT));
gApplication = this;
mProject = nullptr;
mLibrary = nullptr;
mDefaultStyle = style()->objectName();
mPreferences.LoadDefaults();
UpdateStyle();
}
lcApplication::~lcApplication()
{
delete mProject;
delete mLibrary;
gApplication = nullptr;
}
@ -764,7 +758,10 @@ lcStartupMode lcApplication::Initialize(QList<QPair<QString, bool>>& LibraryPath
if (!SaveAndExit)
{
UpdateStyle();
gMainWindow = new lcMainWindow();
lcLoadDefaultKeyboardShortcuts();
lcLoadDefaultMouseShortcuts();
}
@ -1063,9 +1060,11 @@ void lcApplication::Shutdown()
bool lcApplication::InitializeRenderer(int AASamples)
{
if (AASamples > 1)
{
QSurfaceFormat Format = QSurfaceFormat::defaultFormat();
const int FormatSamples = Format.samples() > 1 ? Format.samples() : 1;
if (AASamples != FormatSamples)
{
Format.setSamples(AASamples);
QSurfaceFormat::setDefaultFormat(Format);
}

View file

@ -98,8 +98,8 @@ public:
void SetClipboard(const QByteArray& Clipboard);
void ExportClipboard(const QByteArray& Clipboard);
Project* mProject;
lcPiecesLibrary* mLibrary;
Project* mProject = nullptr;
lcPiecesLibrary* mLibrary = nullptr;
lcPreferences mPreferences;
QByteArray mClipboard;

View file

@ -121,8 +121,23 @@ static void lcRegisterShellFileTypes()
#endif
static void lcInitializeSurfaceFormat(int argc, char* argv[])
{
lcApplication Application(argc, argv);
const int AASamples = lcGetProfileInt(LC_PROFILE_ANTIALIASING_SAMPLES);
if (AASamples > 1)
{
QSurfaceFormat Format = QSurfaceFormat::defaultFormat();
Format.setSamples(AASamples);
QSurfaceFormat::setDefaultFormat(Format);
}
}
int main(int argc, char *argv[])
{
lcInitializeSurfaceFormat(argc, argv);
QCoreApplication::setAttribute(Qt::AA_ShareOpenGLContexts);
lcApplication Application(argc, argv);
@ -181,7 +196,10 @@ int main(int argc, char *argv[])
lcStartupMode StartupMode = Application.Initialize(LibraryPaths);
if (StartupMode == lcStartupMode::Error)
{
Application.Shutdown();
return 1;
}
int ExecReturn = 0;