@@ -448,44 +448,34 @@ def update_service_details(self, service_item_id, details_text):
448448 @Slot (bool )
449449 def set_controls_enabled (self , enabled ):
450450 logger .info (f"SERVICES_PAGE: Setting controls enabled state: { enabled } " )
451- # Check for self.service_widgets itself, though it's initialized in __init__
452451 if hasattr (self , 'service_widgets' ) and self .service_widgets :
453452 for sid , widget in self .service_widgets .items ():
454- # Check if widget is still valid (C++ object not deleted)
455- # A simple check for parent might not be enough if the widget is top-level
456- # but typically item widgets will have a parent.
457- # A more robust check often involves sip.isdeleted() but that's for PyQt.
458- # For PySide, checking if parent() is not None is a reasonable heuristic for child widgets.
459- # Or, more directly, ensure the widget's internal C++ pointer is valid.
460- # For now, let's assume if it's in service_widgets, it might be valid,
461- # but the error occurs when it's accessed *after* deletion.
462- # The timer makes this tricky.
463- # The most direct impact of the error is on calls like setEnabled or set_controls_enabled.
464453 try :
465- if widget : # Basic check
454+ if widget and widget . parent () is not None : # Added parent check
466455 if hasattr (widget , 'set_controls_enabled' ):
467456 widget .set_controls_enabled (enabled )
468457 else :
469458 widget .setEnabled (enabled )
459+ elif widget :
460+ logger .debug (f"SERVICES_PAGE: Widget { sid } has no parent in set_controls_enabled, skipping." )
470461 except RuntimeError as e :
471- logger .warning (f"SERVICES_PAGE: RuntimeErorr accessing widget { sid } in set_controls_enabled: { e } " )
472-
462+ logger .warning (f"SERVICES_PAGE: RuntimeError accessing widget { sid } in set_controls_enabled: { e } " )
473463
474464 if hasattr (self , 'add_service_button' ) and self .add_service_button :
475- # Check if the C++ object is still alive. A simple way is to try accessing a Qt property.
476- # Or check if its parent is still valid if it's supposed to have one.
477- # self.add_service_button.parent() would be its parent QLayout's parent widget.
478465 try :
479- # Attempting a benign call to check if object is alive
480- _ = self .add_service_button .isEnabled () # Or isVisible()
481- self .add_service_button .setEnabled (enabled )
466+ if self .add_service_button .parent () is not None :
467+ self .add_service_button .setEnabled (enabled )
468+ else :
469+ logger .debug (f"SERVICES_PAGE: add_service_button has no parent in set_controls_enabled, skipping." )
482470 except RuntimeError as e :
483471 logger .warning (f"SERVICES_PAGE: RuntimeError accessing add_service_button in set_controls_enabled: { e } " )
484472
485473 if hasattr (self , 'stop_all_button' ) and self .stop_all_button :
486474 try :
487- _ = self .stop_all_button .isEnabled ()
488- self .stop_all_button .setEnabled (enabled )
475+ if self .stop_all_button .parent () is not None :
476+ self .stop_all_button .setEnabled (enabled )
477+ else :
478+ logger .debug (f"SERVICES_PAGE: stop_all_button has no parent in set_controls_enabled, skipping." )
489479 except RuntimeError as e :
490480 logger .warning (f"SERVICES_PAGE: RuntimeError accessing stop_all_button in set_controls_enabled: { e } " )
491481
@@ -537,8 +527,15 @@ def refresh_data(self):
537527 process_id_for_pm = service_def_obj .process_id_template .format (instance_id = config_id )
538528 except KeyError :
539529 logger .error (f"SERVICES_PAGE: process_id_template for { service_type } malformed: { service_def_obj .process_id_template } " ); continue
540- else :
541- logger .warning (f"SERVICES_PAGE: Cannot determine process_id_for_pm for { service_config_json } " ); continue
530+ # If still no process_id_for_pm, check for special handling or log warning
531+ if not process_id_for_pm :
532+ if service_def_obj .service_id == 'node' : # Check against service_id from ServiceDefinition
533+ process_id_for_pm = "nvm_managed" # Assign special string
534+ logger .info (f"SERVICES_PAGE: Node.js service type (config_id: { config_id } ) found. Using '{ process_id_for_pm } ' for process_id_for_pm." )
535+ # We will proceed to create the widget for Node.js with this special process_id_for_pm
536+ else :
537+ logger .warning (f"SERVICES_PAGE: Cannot determine process_id_for_pm for { service_config_json } (type: { service_type } )" )
538+ continue # Skip for other types if no process_id
542539
543540 category = service_def_obj .category if service_def_obj .category else 'Other'
544541 display_name = service_config_json .get ('name' , service_def_obj .display_name )
0 commit comments