Fix SEGV on start and race conditions when using the popup menu from the toolbar

Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>
pull/1/head
Michele Calgaro 4 months ago
parent 4a065bb4cd
commit 014348eb15
Signed by: MicheleC
GPG Key ID: 2A75B7CA8ADED5CF

@ -8,5 +8,6 @@
#cmakedefine WORDS_BIGENDIAN @WORDS_BIGENDIAN@
// Zlibrary defines
#define BASEDIR "@SHARE_INSTALL_PREFIX@"
#define IMAGEDIR "@SHARE_INSTALL_PREFIX@/pixmaps"
#define BASEDIR "@DATA_INSTALL_DIR@"
#define IMAGEDIR "@DATA_INSTALL_DIR@/tde-ebook-reader/icons"
#define ZLBASEDIR "@ZL_SHARE_INSTALL_PREFIX@"

@ -85,7 +85,7 @@ Reader &Reader::Instance() {
}
Reader::Reader(const std::string &bookToOpen) :
ZLApplication("Reader"),
ZLApplication("tde-ebook-reader"),
QuitOnCancelOption(ZLCategoryKey::CONFIG, OPTIONS, "QuitOnCancel", false),
KeyScrollingDelayOption(ZLCategoryKey::CONFIG, "Scrollings", "Delay", 0, 2000, 100),
LinesToScrollOption(ZLCategoryKey::CONFIG, "SmallScrolling", "LinesToScroll", 1, 20, 1),
@ -172,7 +172,7 @@ Reader::Reader(const std::string &bookToOpen) :
myOpenFileHandler = new OpenFileHandler();
ZLCommunicationManager::Instance().registerHandler("openFile", myOpenFileHandler);
ZLNetworkManager::Instance().setUserAgent(std::string("Reader/") + VERSION);
//ZLNetworkManager::Instance().setUserAgent(std::string("Reader/") + VERSION);
}
Reader::~Reader() {

@ -91,6 +91,7 @@ ZLTQtToolButton::ZLTQtToolButton(ZLTQtApplicationWindow &window, ZLToolbar::Abst
myWindow.myPopupIdMap[&menuButtonItem] =
popupData.isNull() ? (size_t)-1 : (popupData->id() - 1);
setPopup(new ZLTQtPopupMenu(this));
setPopupDelay(0);
}
TQString text = TQString::fromUtf8(myItem.tooltip().c_str());
setTextLabel(text);

@ -19,13 +19,20 @@
#include "ZLTQtPopupMenu.h"
#include "tqtimer.h"
ZLTQtPopupMenu::ZLTQtPopupMenu(TQWidget *parent) : TQPopupMenu(parent) {
connect(this, TQ_SIGNAL(activated(int)), this, TQ_SLOT(onActivated(int)));
}
void ZLTQtPopupMenu::onActivated(int itemId) {
myItemId = itemId;
TQTimer::singleShot(0, this, TQ_SLOT(doActivation()) );
}
void ZLTQtPopupMenu::doActivation() {
if (!myPopupData.isNull()) {
myPopupData->run(myItemIdToIndex[itemId]);
myPopupData->run(myItemIdToIndex[myItemId]);
}
}

@ -36,10 +36,12 @@ public:
private slots:
void onActivated(int itemId);
void doActivation();
private:
shared_ptr<ZLPopupData> myPopupData;
std::map<int,int> myItemIdToIndex;
int myItemId;
};
#endif /* __ZLTQTPOPUPMENU_H__ */

Loading…
Cancel
Save