Skip to content

Commit

Permalink
Fix crash in release
Browse files Browse the repository at this point in the history
  • Loading branch information
mhtvsSFrpHdE committed Sep 11, 2022
1 parent 25ede4e commit 44cc23c
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
4 changes: 4 additions & 0 deletions qpp/prefetch/Source/Interface/TrayIcon/Action/custom_action.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
#include <QAction>
#include <QString>

// Pointer to function does not support point to member function
// Only pass static function pointer here
// GCC may allow the code to compile, but Qt doesn't support:
// Code will crash in internal Qt, even after parameter function is returned successfully.
typedef void (*ParameterSlot)(void *);

// QAction, connect void signal to parameter slot
Expand Down
2 changes: 1 addition & 1 deletion qpp/prefetch/Source/Interface/TrayIcon/tray_icon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ void TrayIcon::init()

// Create action
auto customMenu = new CustomAction(menuName, qMenu);
customMenu->init(new QString(menuCommand), ParameterSlot(&TrayIcon::action_custom));
customMenu->init(new QString(menuCommand), &action_custom);
connect(customMenu, SIGNAL(triggered()), customMenu, SLOT(triggered_slot()));
qMenu->addAction(customMenu);

Expand Down
2 changes: 1 addition & 1 deletion qpp/prefetch/Source/Interface/TrayIcon/tray_icon.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public slots:
void action_traydc_void();
void action_test();
void action_updateMenu(QSystemTrayIcon::ActivationReason activationReason);
void action_custom(void *command);
static void action_custom(void *command);

private:
static QSystemTrayIcon *systemTrayIcon;
Expand Down

0 comments on commit 44cc23c

Please sign in to comment.