1313 Node(package='coffee_voice_agent_ui', executable='voice_agent_monitor')
1414"""
1515
16+ # CRITICAL: Set Qt environment variables IMMEDIATELY, before any other imports
17+ import os
1618import sys
19+
20+ # Early Qt environment setup for macOS - MUST be before any Qt imports
21+ if sys .platform == "darwin" :
22+ # Core macOS Qt setup
23+ os .environ ['QT_QPA_PLATFORM' ] = 'cocoa'
24+ os .environ ['QT_MAC_WANTS_LAYER' ] = '1'
25+
1726import signal
1827import rclpy
1928from rclpy .node import Node
2231import threading
2332from datetime import datetime
2433
25- # Set Qt attributes BEFORE importing Qt modules
26- import os
27- os .environ ['QT_AUTO_SCREEN_SCALE_FACTOR' ] = '1'
28-
2934from python_qt_binding .QtWidgets import QApplication , QMainWindow , QVBoxLayout , QWidget , QGridLayout
3035from python_qt_binding .QtCore import Qt , QTimer , pyqtSignal , pyqtSlot , QObject
3136from python_qt_binding .QtGui import QIcon
@@ -414,9 +419,20 @@ def signal_handler(signum, frame):
414419def main (args = None ):
415420 """Main entry point for standalone voice agent monitor application"""
416421
422+ # macOS-specific Qt stability setting
423+ if sys .platform == "darwin" :
424+ # Disable X11/GL integration to prevent conflicts
425+ os .environ ['QT_XCB_GL_INTEGRATION' ] = 'none'
426+
417427 # Set Qt attributes BEFORE creating QApplication
418428 QApplication .setAttribute (Qt .AA_EnableHighDpiScaling , True )
419429 QApplication .setAttribute (Qt .AA_UseHighDpiPixmaps , True )
430+ # Add compatibility attributes for macOS
431+ if sys .platform == "darwin" :
432+ QApplication .setAttribute (Qt .AA_DontUseNativeMenuBar , True )
433+ QApplication .setAttribute (Qt .AA_DontUseNativeDialogs , True )
434+ # Force software rendering BEFORE QApplication creation
435+ QApplication .setAttribute (Qt .AA_UseSoftwareOpenGL , True )
420436
421437 # Set up signal handlers for graceful shutdown
422438 signal .signal (signal .SIGINT , signal_handler )
@@ -430,6 +446,7 @@ def main(args=None):
430446 app .setApplicationName ("Coffee Voice Agent Monitor" )
431447 app .setApplicationDisplayName ("Coffee Voice Agent Monitor" )
432448
449+
433450 # Create main window
434451 main_window = None
435452
0 commit comments