Skip to content

Commit

Permalink
fix: crash when startup.
Browse files Browse the repository at this point in the history
  • Loading branch information
royqh1979 committed Dec 5, 2024
1 parent b53742c commit b751edd
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
12 changes: 7 additions & 5 deletions RedPandaIDE/widgets/codecompletionpopup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,11 @@

CodeCompletionPopup::CodeCompletionPopup(QWidget *parent) :
QWidget(parent),
mListView(nullptr),
mMutex()
{
setWindowFlags(Qt::Popup);

mListView = new CodeCompletionListView(this);
mModel=new CodeCompletionListModel(&mCompletionStatementList);
mDelegate = new CodeCompletionListItemDelegate(mModel,this);
Expand All @@ -57,9 +60,6 @@ CodeCompletionPopup::CodeCompletionPopup(QWidget *parent) :

mHideSymbolsStartWithTwoUnderline = false;
mHideSymbolsStartWithUnderline = false;

// may trigger font change event, place it after member initialization
setWindowFlags(Qt::Popup);
}

CodeCompletionPopup::~CodeCompletionPopup()
Expand Down Expand Up @@ -1262,8 +1262,10 @@ bool CodeCompletionPopup::event(QEvent *event)
{
bool result = QWidget::event(event);
if (event->type() == QEvent::FontChange) {
mListView->setFont(font());
mDelegate->setFont(font());
if (mListView) {
mListView->setFont(font());
mDelegate->setFont(font());
}
}
return result;
}
Expand Down
20 changes: 9 additions & 11 deletions RedPandaIDE/widgets/headercompletionpopup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,11 @@
#include "../colorscheme.h"
#include <qsynedit/constants.h>

HeaderCompletionPopup::HeaderCompletionPopup(QWidget* parent):QWidget(parent)
HeaderCompletionPopup::HeaderCompletionPopup(QWidget* parent):QWidget{parent},
mListView{nullptr}
{
setWindowFlags(Qt::Popup);

mListView = new CodeCompletionListView(this);
mModel=new HeaderCompletionListModel(&mCompletionList, 0);
QItemSelectionModel *m=mListView->selectionModel();
Expand All @@ -46,9 +49,6 @@ HeaderCompletionPopup::HeaderCompletionPopup(QWidget* parent):QWidget(parent)
mCurrentFile = "";
mPhrase = "";
mIgnoreCase = false;

// may trigger font change event, place it after member initialization
setWindowFlags(Qt::Popup);
}

HeaderCompletionPopup::~HeaderCompletionPopup()
Expand Down Expand Up @@ -320,13 +320,11 @@ void HeaderCompletionPopup::hideEvent(QHideEvent *)
bool HeaderCompletionPopup::event(QEvent *event)
{
bool result = QWidget::event(event);
switch (event->type()) {
case QEvent::FontChange:
mListView->setFont(font());
mDelegate->setFont(font());
break;
default:
break;
if (event->type() == QEvent::FontChange) {
if (mListView) {
mListView->setFont(font());
mDelegate->setFont(font());
}
}
return result;
}
Expand Down

0 comments on commit b751edd

Please sign in to comment.