Skip to content

Commit

Permalink
Birdtray fails to start while waiting for the SystemTray to become av…
Browse files Browse the repository at this point in the history
…ailable.

Per the QT documentation for QT4 & 5: https://doc.qt.io/qt-5/qsystemtrayicon.html#isSystemTrayAvailable

The system tray icon will be automatically added if the system tray is visible (even if it was
not available at launch).

Fixes issue gyunaev#357
  • Loading branch information
neoh4x0r committed Jun 25, 2020
1 parent 3541386 commit c75759c
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 20 deletions.
16 changes: 0 additions & 16 deletions src/birdtrayapp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ BirdtrayApp::BirdtrayApp(int &argc, char** argv) : QApplication(argc, argv)

Log::debug( "Birdtray version %d.%d.%d started", VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH );

ensureSystemTrayAvailable();
// Load settings
settings = new Settings();
if (commandLineParser.isSet("reset-settings")) {
Expand Down Expand Up @@ -255,18 +254,3 @@ void BirdtrayApp::onSecondInstanceCommand(QLocalSocket* clientSocket) {
trayIcon->showSettings();
}
}

void BirdtrayApp::ensureSystemTrayAvailable() {
int passed = 0;
while (!QSystemTrayIcon::isSystemTrayAvailable()) {
if (passed == 0) {
qDebug("Waiting for system tray to become available");
}
passed++;
if (passed > 120) {
Log::fatal( QApplication::tr("Sorry, system tray cannot be controlled "
"through this add-on on your operating system.") );
}
QThread::msleep(500);
}
}
4 changes: 0 additions & 4 deletions src/birdtrayapp.h
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,6 @@ protected Q_SLOTS:
*/
void onSecondInstanceCommand(QLocalSocket* clientSocket);

/**
* Wait for the system tray to become available and exit if it doesn't within 60 seconds.
*/
static void ensureSystemTrayAvailable();
};


Expand Down

0 comments on commit c75759c

Please sign in to comment.