Skip to content

Commit

Permalink
Merge pull request #3413 from ann0see/iOS/FixCrashChat
Browse files Browse the repository at this point in the history
Fix crash on closing iOS chat dialog

Merging to get a beta out with this in for more general testing
  • Loading branch information
pljones authored Dec 18, 2024
2 parents b2f5196 + 9cf708c commit 0cd0044
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
24 changes: 21 additions & 3 deletions src/chatdlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,11 @@ CChatDlg::CChatDlg ( QWidget* parent ) : CBaseDlg ( parent, Qt::Window ) // use

pMenu->addMenu ( pEditMenu );
#if defined( Q_OS_IOS )
QAction* action = pMenu->addAction ( tr ( "&Close" ) );
connect ( action, SIGNAL ( triggered() ), this, SLOT ( close() ) );
QAction* closeAction = pMenu->addAction ( tr ( "&Close" ) );
#endif

#if defined( ANDROID ) || defined( Q_OS_ANDROID )
pEditMenu->addAction ( tr ( "&Close" ), this, SLOT ( close() ), QKeySequence ( Qt::CTRL + Qt::Key_W ) );
pEditMenu->addAction ( tr ( "&Close" ), this, SLOT ( OnCloseClicked() ), QKeySequence ( Qt::CTRL + Qt::Key_W ) );
#endif

// Now tell the layout about the menu
Expand All @@ -78,6 +77,10 @@ CChatDlg::CChatDlg ( QWidget* parent ) : CBaseDlg ( parent, Qt::Window ) // use
QObject::connect ( butSend, &QPushButton::clicked, this, &CChatDlg::OnSendText );

QObject::connect ( txvChatWindow, &QTextBrowser::anchorClicked, this, &CChatDlg::OnAnchorClicked );

#if defined( Q_OS_IOS )
QObject::connect ( closeAction, &QAction::triggered, this, &CChatDlg::OnCloseClicked );
#endif
}

void CChatDlg::OnLocalInputTextTextChanged ( const QString& strNewText )
Expand Down Expand Up @@ -149,3 +152,18 @@ void CChatDlg::OnAnchorClicked ( const QUrl& Url )
}
}
}

#if defined( Q_OS_IOS ) || defined( ANDROID ) || defined( Q_OS_ANDROID )
void CChatDlg::OnCloseClicked()
{
// on mobile add a close button or menu entry
# if defined( Q_OS_IOS )
// On Qt6, iOS crashes if we call close() due to unknown reasons, therefore we just hide() the dialog. A Qt bug is suspected.
// Checkout https://github.com/jamulussoftware/jamulus/pull/3413
hide();
# endif
# if defined( ANDROID ) || defined( Q_OS_ANDROID )
close();
# endif
}
#endif
3 changes: 3 additions & 0 deletions src/chatdlg.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ public slots:
void OnLocalInputTextTextChanged ( const QString& strNewText );
void OnClearChatHistory();
void OnAnchorClicked ( const QUrl& Url );
#if defined( Q_OS_IOS ) || defined( ANDROID ) || defined( Q_OS_ANDROID )
void OnCloseClicked();
#endif

signals:
void NewLocalInputText ( QString strNewText );
Expand Down

0 comments on commit 0cd0044

Please sign in to comment.