Skip to content

Commit ba6bc84

Browse files
committed
#3407 ai-autocomplete: fix build issue with Qt5 and older versions of Qt6
Signed-off-by: Patrizio Bekerle <[email protected]>
1 parent b0777a5 commit ba6bc84

File tree

1 file changed

+3
-17
lines changed

1 file changed

+3
-17
lines changed

src/services/openaiservice.cpp

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -44,23 +44,9 @@ OpenAiService::OpenAiService(QObject* parent) : QObject(parent) {
4444
// Forward declaration to avoid circular dependency
4545
class QOwnNotesMarkdownTextEdit;
4646

47-
// Get the active editor using QMetaObject since we can't include the header
48-
QObject* activeEditorObj = nullptr;
49-
QMetaObject::invokeMethod(
50-
nullptr,
51-
[]() -> QObject* {
52-
// Access the static method through the class name
53-
// We need to get QOwnNotesMarkdownTextEdit::getActiveEditorForAutocomplete()
54-
// but we can't call it directly due to circular includes
55-
// So we'll use a different approach - store it in QApplication
56-
return qApp->property("activeAutocompleteEditor").value<QObject*>();
57-
},
58-
Qt::DirectConnection, Q_RETURN_ARG(QObject*, activeEditorObj));
59-
60-
if (!activeEditorObj) {
61-
// Try to get from application property
62-
activeEditorObj = qApp->property("activeAutocompleteEditor").value<QObject*>();
63-
}
47+
// Get the active editor from the application property
48+
// We can't use QMetaObject::invokeMethod with lambdas in Qt5
49+
QObject* activeEditorObj = qApp->property("activeAutocompleteEditor").value<QObject*>();
6450

6551
if (activeEditorObj) {
6652
qDebug() << "*** Calling onAiAutocompleteCompleted on active editor:"

0 commit comments

Comments
 (0)