fix: crash when using ibus as the input method

This commit is contained in:
Roy Qu 2023-10-18 14:00:32 +00:00
parent 0bb941e7fd
commit 5bf6da785c
5 changed files with 3 additions and 25 deletions

View File

@ -17,6 +17,7 @@ Red Panda C++ Version 2.25
- enhancement: After compiler settings changed, run/debug current file will auto recompile.
- ehhancement: Show selected char counts in status bar.
- enhancement: Differentiate /* and /** when calculate auto indents.
- fix: crash when using ibus as the input method.
Red Panda C++ Version 2.24

View File

@ -57,8 +57,6 @@
QHash<ParserLanguage,std::weak_ptr<CppParser>> Editor::mSharedParsers;
int Editor::mShouldDisableSuggestionInInputMethodEvent = -1;
Editor::Editor(QWidget *parent):
Editor(parent,"untitled",ENCODING_AUTO_DETECT,nullptr,true,nullptr)
{
@ -1341,20 +1339,6 @@ void Editor::mouseReleaseEvent(QMouseEvent *event)
void Editor::inputMethodEvent(QInputMethodEvent *event)
{
QSynedit::QSynEdit::inputMethodEvent(event);
#ifdef Q_OS_UNIX
if (mShouldDisableSuggestionInInputMethodEvent == -1) {
//not inited
QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
//input method is ibus, disable suggestion
mShouldDisableSuggestionInInputMethodEvent =
(env.value("QT_IM_MODULE")=="ibus" )? 1 : 0;
}
if (mShouldDisableSuggestionInInputMethodEvent == 1) {
if (pMainWindow->completionPopup()->isVisible())
pMainWindow->completionPopup()->close();
return;
}
#endif
QString s = event->commitString();
if (s.isEmpty())
return;

View File

@ -355,9 +355,6 @@ private:
QMap<QString,StatementKind> mIdentCache;
static QHash<ParserLanguage,std::weak_ptr<CppParser>> mSharedParsers;
#ifdef Q_OS_UNIX
static int mShouldDisableSuggestionInInputMethodEvent;
#endif
// QWidget interface
protected:

View File

@ -35,6 +35,8 @@ HeaderCompletionPopup::HeaderCompletionPopup(QWidget* parent):QWidget(parent)
layout()->addWidget(mListView);
layout()->setMargin(0);
mListView->setFocus();
mSearchLocal = false;
mCurrentFile = "";
mPhrase = "";
@ -281,11 +283,6 @@ void HeaderCompletionPopup::setParser(const PCppParser &newParser)
mParser = newParser;
}
void HeaderCompletionPopup::showEvent(QShowEvent *)
{
mListView->setFocus();
}
void HeaderCompletionPopup::hideEvent(QHideEvent *)
{
mCompletionList.clear();

View File

@ -100,7 +100,6 @@ private:
// QWidget interface
protected:
void showEvent(QShowEvent *event) override;
void hideEvent(QHideEvent *event) override;
// QObject interface