Skip to content

Commit

Permalink
Merge pull request #1147 from letsfindaway/fix-crash-background-loading
Browse files Browse the repository at this point in the history
fix: crash when closing while scene is loading
  • Loading branch information
kaamui authored Oct 28, 2024
2 parents 78ee945 + 0835bc2 commit 8740de5
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/core/UBApplication.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ UBDocumentController* UBApplication::documentController = 0;

UBMainWindow* UBApplication::mainWindow = 0;

bool UBApplication::isClosing = false;

const QString UBApplication::mimeTypeUniboardDocument = QString("application/vnd.mnemis-uniboard-document");
const QString UBApplication::mimeTypeUniboardPage = QString("application/vnd.mnemis-uniboard-page");
const QString UBApplication::mimeTypeUniboardPageItem = QString("application/vnd.mnemis-uniboard-page-item");
Expand Down Expand Up @@ -507,6 +509,8 @@ void UBApplication::closeEvent(QCloseEvent *event)

void UBApplication::closing()
{
isClosing = true;

if (UBSettings::settings()->emptyTrashForOlderDocuments->get().toBool())
{
UBDocumentTreeModel *docModel = UBPersistenceManager::persistenceManager()->mDocumentTreeStructureModel;
Expand Down
2 changes: 2 additions & 0 deletions src/core/UBApplication.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ class UBApplication : public SingleApplication

static UBMainWindow* mainWindow;

static bool isClosing;

static UBApplication* app()
{
return dynamic_cast<UBApplication*>qApp;
Expand Down
7 changes: 7 additions & 0 deletions src/core/UBSceneCache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,13 @@ void UBSceneCache::SceneCacheEntry::startLoading()
{
mTimer = new QTimer;
QObject::connect(mTimer, &QTimer::timeout, mTimer, [this](){
if (UBApplication::isClosing)
{
mTimer->stop();
delete mTimer;
return;
}

if (mContext)
{
mContext->step();
Expand Down

0 comments on commit 8740de5

Please sign in to comment.