Changeset 66442 in vbox
- Timestamp:
- Apr 5, 2017 2:17:49 PM (8 years ago)
- svn:sync-xref-src-repo-rev:
- 114413
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsSerial.cpp
r66375 r66442 365 365 m_pCache->clear(); 366 366 367 /* Prepare initial data: */368 UIDataSettingsMachineSerial initialData;369 370 /* For each serialport: */367 /* Prepare old parallel data: */ 368 UIDataSettingsMachineSerial oldSerialData; 369 370 /* For each port: */ 371 371 for (int iSlot = 0; iSlot < m_pTabWidget->count(); ++iSlot) 372 372 { 373 /* Prepare port data: */374 UIDataSettingsMachineSerialPort initialPortData;375 376 /* Check ifport is valid: */377 const CSerialPort & port = m_machine.GetSerialPort(iSlot);378 if (! port.isNull())373 /* Prepare old port data: */ 374 UIDataSettingsMachineSerialPort oldPortData; 375 376 /* Check whether port is valid: */ 377 const CSerialPort &comPort = m_machine.GetSerialPort(iSlot); 378 if (!comPort.isNull()) 379 379 { 380 /* Gather o ptions: */381 initialPortData.m_iSlot = iSlot;382 initialPortData.m_fPortEnabled = port.GetEnabled();383 initialPortData.m_uIRQ = port.GetIRQ();384 initialPortData.m_uIOBase = port.GetIOBase();385 initialPortData.m_hostMode = port.GetHostMode();386 initialPortData.m_fServer = port.GetServer();387 initialPortData.m_strPath = port.GetPath();380 /* Gather old port data: */ 381 oldPortData.m_iSlot = iSlot; 382 oldPortData.m_fPortEnabled = comPort.GetEnabled(); 383 oldPortData.m_uIRQ = comPort.GetIRQ(); 384 oldPortData.m_uIOBase = comPort.GetIOBase(); 385 oldPortData.m_hostMode = comPort.GetHostMode(); 386 oldPortData.m_fServer = comPort.GetServer(); 387 oldPortData.m_strPath = comPort.GetPath(); 388 388 } 389 389 390 /* Append initialport data: */391 initialData.m_ports << initialPortData;392 } 393 394 /* Cache initial data: */395 m_pCache->cacheInitialData( initialData);390 /* Cache old port data: */ 391 oldSerialData.m_ports << oldPortData; 392 } 393 394 /* Cache old serial data: */ 395 m_pCache->cacheInitialData(oldSerialData); 396 396 397 397 /* Upload machine to data: */ … … 406 406 QWidget *pLastFocusWidget = m_pTabWidget->focusProxy(); 407 407 408 /* For each serialport: */408 /* For each port: */ 409 409 for (int iPort = 0; iPort < m_pTabWidget->count(); ++iPort) 410 410 { … … 412 412 UIMachineSettingsSerial *pPage = qobject_cast<UIMachineSettingsSerial*>(m_pTabWidget->widget(iPort)); 413 413 414 /* Load port data topage: */414 /* Load old port data to the page: */ 415 415 pPage->loadPortData(m_pCache->base().m_ports.at(iPort)); 416 416 … … 431 431 void UIMachineSettingsSerialPage::putToCache() 432 432 { 433 /* Prepare currentdata: */434 UIDataSettingsMachineSerial currentData;435 436 /* For each serialport: */433 /* Prepare new serial data: */ 434 UIDataSettingsMachineSerial newSerialData; 435 436 /* For each port: */ 437 437 for (int iPort = 0; iPort < m_pTabWidget->count(); ++iPort) 438 438 { … … 440 440 UIMachineSettingsSerial *pTab = qobject_cast<UIMachineSettingsSerial*>(m_pTabWidget->widget(iPort)); 441 441 442 /* Prepare currentport data: */443 UIDataSettingsMachineSerialPort currentPortData;444 445 /* Gather currentport data: */446 pTab->savePortData( currentPortData);447 448 /* Cache currentport data: */449 currentData.m_ports << currentPortData;450 } 451 452 /* Cache currentdata: */453 m_pCache->cacheCurrentData( currentData);442 /* Prepare new port data: */ 443 UIDataSettingsMachineSerialPort newPortData; 444 445 /* Gather new port data: */ 446 pTab->savePortData(newPortData); 447 448 /* Cache new port data: */ 449 newSerialData.m_ports << newPortData; 450 } 451 452 /* Cache new serial data: */ 453 m_pCache->cacheCurrentData(newSerialData); 454 454 } 455 455 … … 459 459 UISettingsPageMachine::fetchData(data); 460 460 461 /* Check if portsdata was changed: */462 if ( m_pCache->wasChanged())461 /* Make sure machine is offline & serial data was changed: */ 462 if (isMachineOffline() && m_pCache->wasChanged()) 463 463 { 464 464 /* For each serial port: */ 465 465 for (int iPort = 0; iPort < m_pTabWidget->count(); ++iPort) 466 466 { 467 /* Check if port data was changed: */ 468 const UIDataSettingsMachineSerialPort &initialPortData = m_pCache->base().m_ports.at(iPort); 469 const UIDataSettingsMachineSerialPort ¤tPortData = m_pCache->data().m_ports.at(iPort); 470 if (currentPortData != initialPortData) 467 /* Get old serial data from the cache: */ 468 const UIDataSettingsMachineSerialPort &oldPortData = m_pCache->base().m_ports.at(iPort); 469 /* Get new serial data from the cache: */ 470 const UIDataSettingsMachineSerialPort &newPortData = m_pCache->data().m_ports.at(iPort); 471 472 /* Make sure port data was changed: */ 473 if (newPortData != oldPortData) 471 474 { 472 475 /* Check if port still valid: */ 473 CSerialPort port = m_machine.GetSerialPort(iPort); 474 if (!port.isNull()) 476 CSerialPort comPort = m_machine.GetSerialPort(iPort); 477 /* Store new adapter data: */ 478 if (!comPort.isNull()) 475 479 { 476 /* Store adapter data: */ 477 if (isMachineOffline()) 478 { 479 /* Whether the port is enabled: */ 480 if ( port.isOk() 481 && currentPortData.m_fPortEnabled != initialPortData.m_fPortEnabled) 482 port.SetEnabled(currentPortData.m_fPortEnabled); 483 /* Port IRQ: */ 484 if ( port.isOk() 485 && currentPortData.m_uIRQ != initialPortData.m_uIRQ) 486 port.SetIRQ(currentPortData.m_uIRQ); 487 /* Port IO base: */ 488 if ( port.isOk() 489 && currentPortData.m_uIOBase != initialPortData.m_uIOBase) 490 port.SetIOBase(currentPortData.m_uIOBase); 491 /* Whether the port is server: */ 492 if ( port.isOk() 493 && currentPortData.m_fServer != initialPortData.m_fServer) 494 port.SetServer(currentPortData.m_fServer); 495 /* Port path: */ 496 if ( port.isOk() 497 && currentPortData.m_strPath != initialPortData.m_strPath) 498 port.SetPath(currentPortData.m_strPath); 499 /* This *must* be last. The host mode will be changed to disconnected if 500 * some of the necessary settings above will not meet the requirements for 501 * the selected mode. */ 502 if ( port.isOk() 503 && currentPortData.m_hostMode != initialPortData.m_hostMode) 504 port.SetHostMode(currentPortData.m_hostMode); 505 } 480 /* Whether the port is enabled: */ 481 if ( comPort.isOk() 482 && newPortData.m_fPortEnabled != oldPortData.m_fPortEnabled) 483 comPort.SetEnabled(newPortData.m_fPortEnabled); 484 /* Port IRQ: */ 485 if ( comPort.isOk() 486 && newPortData.m_uIRQ != oldPortData.m_uIRQ) 487 comPort.SetIRQ(newPortData.m_uIRQ); 488 /* Port IO base: */ 489 if ( comPort.isOk() 490 && newPortData.m_uIOBase != oldPortData.m_uIOBase) 491 comPort.SetIOBase(newPortData.m_uIOBase); 492 /* Whether the port is server: */ 493 if ( comPort.isOk() 494 && newPortData.m_fServer != oldPortData.m_fServer) 495 comPort.SetServer(newPortData.m_fServer); 496 /* Port path: */ 497 if ( comPort.isOk() 498 && newPortData.m_strPath != oldPortData.m_strPath) 499 comPort.SetPath(newPortData.m_strPath); 500 /* This *must* be last. The host mode will be changed to disconnected if 501 * some of the necessary settings above will not meet the requirements for 502 * the selected mode. */ 503 if ( comPort.isOk() 504 && newPortData.m_hostMode != oldPortData.m_hostMode) 505 comPort.SetHostMode(newPortData.m_hostMode); 506 506 } 507 507 }
Note:
See TracChangeset
for help on using the changeset viewer.