diff --git a/src/libtomahawk/utils/tomahawkutils.cpp b/src/libtomahawk/utils/tomahawkutils.cpp index b47f6748c4..60a5968366 100644 --- a/src/libtomahawk/utils/tomahawkutils.cpp +++ b/src/libtomahawk/utils/tomahawkutils.cpp @@ -530,8 +530,14 @@ setNam( QNetworkAccessManager* nam ) qDebug() << Q_FUNC_INFO; QWidgetList widgetList = qApp->topLevelWidgets(); int i = 0; - while( !widgetList.at( i )->isWindow() ) + while( i < widgetList.count() && widgetList.at( i )->objectName() != "TH_Main_Window" ) i++; + if ( i == widgetList.count() ) + { + qDebug() << Q_FUNC_INFO << " could not find main TH window"; + return; + } + QWidget *widget = widgetList.at( i ); widget->show(); @@ -564,8 +570,14 @@ setNam( QNetworkAccessManager* nam ) qDebug() << Q_FUNC_INFO; QWidgetList widgetList = qApp->topLevelWidgets(); int i = 0; - while( !widgetList.at( i )->isWindow() ) + while( i < widgetList.count() && widgetList.at( i )->objectName() != "TH_Main_Window" ) i++; + if ( i == widgetList.count() ) + { + qDebug() << Q_FUNC_INFO << " could not find main TH window"; + return; + } + QWidget *widget = widgetList.at( i ); widget->show(); diff --git a/src/tomahawkapp.cpp b/src/tomahawkapp.cpp index bd841c2dce..b62bfe7f61 100644 --- a/src/tomahawkapp.cpp +++ b/src/tomahawkapp.cpp @@ -222,6 +222,7 @@ TomahawkApp::init() tDebug() << "Init MainWindow."; m_mainwindow = new TomahawkWindow(); m_mainwindow->setWindowTitle( "Tomahawk" ); + m_mainwindow->setObjectName( "TH_Main_Window" ); m_mainwindow->show(); } #endif