[Qt] add more NULL pointer checks in bitcoingui

- add missing checks for clientModel and optionsModel
- small cleanups for an #ifdef on Mac
- remove an unneeded else
This commit is contained in:
Philip Kaufmann 2014-09-22 14:41:54 +02:00
parent ea69592a2f
commit e6beedc496

View File

@ -662,6 +662,9 @@ void BitcoinGUI::setNumConnections(int count)
void BitcoinGUI::setNumBlocks(int count) void BitcoinGUI::setNumBlocks(int count)
{ {
if(!clientModel)
return;
// Prevent orphan statusbar messages (e.g. hover Quit in main menu, wait until chain-sync starts -> garbelled text) // Prevent orphan statusbar messages (e.g. hover Quit in main menu, wait until chain-sync starts -> garbelled text)
statusBar()->clearMessage(); statusBar()->clearMessage();
@ -832,7 +835,7 @@ void BitcoinGUI::changeEvent(QEvent *e)
#ifndef Q_OS_MAC // Ignored on Mac #ifndef Q_OS_MAC // Ignored on Mac
if(e->type() == QEvent::WindowStateChange) if(e->type() == QEvent::WindowStateChange)
{ {
if(clientModel && clientModel->getOptionsModel()->getMinimizeToTray()) if(clientModel && clientModel->getOptionsModel() && clientModel->getOptionsModel()->getMinimizeToTray())
{ {
QWindowStateChangeEvent *wsevt = static_cast<QWindowStateChangeEvent*>(e); QWindowStateChangeEvent *wsevt = static_cast<QWindowStateChangeEvent*>(e);
if(!(wsevt->oldState() & Qt::WindowMinimized) && isMinimized()) if(!(wsevt->oldState() & Qt::WindowMinimized) && isMinimized())
@ -846,17 +849,17 @@ void BitcoinGUI::changeEvent(QEvent *e)
} }
void BitcoinGUI::closeEvent(QCloseEvent *event) void BitcoinGUI::closeEvent(QCloseEvent *event)
{
if(clientModel)
{ {
#ifndef Q_OS_MAC // Ignored on Mac #ifndef Q_OS_MAC // Ignored on Mac
if(clientModel && clientModel->getOptionsModel())
{
if(!clientModel->getOptionsModel()->getMinimizeToTray() && if(!clientModel->getOptionsModel()->getMinimizeToTray() &&
!clientModel->getOptionsModel()->getMinimizeOnClose()) !clientModel->getOptionsModel()->getMinimizeOnClose())
{ {
QApplication::quit(); QApplication::quit();
} }
#endif
} }
#endif
QMainWindow::closeEvent(event); QMainWindow::closeEvent(event);
} }
@ -917,7 +920,6 @@ bool BitcoinGUI::handlePaymentRequest(const SendCoinsRecipient& recipient)
gotoSendCoinsPage(); gotoSendCoinsPage();
return true; return true;
} }
else
return false; return false;
} }