summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichele Calgaro <[email protected]>2024-07-18 10:53:58 +0900
committerMichele Calgaro <[email protected]>2024-07-18 10:53:58 +0900
commit014348eb159b833fa05f7f53a33b9028124c0f75 (patch)
tree65a8a3c6f89a30277261ef166fdac294326a350f
parent4a065bb4cd85979125b3a937b5912105d13ba357 (diff)
downloadtde-ebook-reader-014348eb159b833fa05f7f53a33b9028124c0f75.tar.gz
tde-ebook-reader-014348eb159b833fa05f7f53a33b9028124c0f75.zip
Fix SEGV on start and race conditions when using the popup menu from the toolbar
Signed-off-by: Michele Calgaro <[email protected]>
-rw-r--r--config.h.cmake5
-rw-r--r--reader/src/reader/Reader.cpp4
-rw-r--r--zlibrary/core/src/ui/application-desktop/ZLTQtApplicationWindow.cpp1
-rw-r--r--zlibrary/core/src/ui/application-desktop/ZLTQtPopupMenu.cpp9
-rw-r--r--zlibrary/core/src/ui/application-desktop/ZLTQtPopupMenu.h2
5 files changed, 16 insertions, 5 deletions
diff --git a/config.h.cmake b/config.h.cmake
index d0eb046..2fce79f 100644
--- a/config.h.cmake
+++ b/config.h.cmake
@@ -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@"
diff --git a/reader/src/reader/Reader.cpp b/reader/src/reader/Reader.cpp
index 0c15b9d..22aa527 100644
--- a/reader/src/reader/Reader.cpp
+++ b/reader/src/reader/Reader.cpp
@@ -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() {
diff --git a/zlibrary/core/src/ui/application-desktop/ZLTQtApplicationWindow.cpp b/zlibrary/core/src/ui/application-desktop/ZLTQtApplicationWindow.cpp
index 28edab6..ee0b390 100644
--- a/zlibrary/core/src/ui/application-desktop/ZLTQtApplicationWindow.cpp
+++ b/zlibrary/core/src/ui/application-desktop/ZLTQtApplicationWindow.cpp
@@ -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);
diff --git a/zlibrary/core/src/ui/application-desktop/ZLTQtPopupMenu.cpp b/zlibrary/core/src/ui/application-desktop/ZLTQtPopupMenu.cpp
index e723204..1588132 100644
--- a/zlibrary/core/src/ui/application-desktop/ZLTQtPopupMenu.cpp
+++ b/zlibrary/core/src/ui/application-desktop/ZLTQtPopupMenu.cpp
@@ -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]);
}
}
diff --git a/zlibrary/core/src/ui/application-desktop/ZLTQtPopupMenu.h b/zlibrary/core/src/ui/application-desktop/ZLTQtPopupMenu.h
index 974ed0f..1861192 100644
--- a/zlibrary/core/src/ui/application-desktop/ZLTQtPopupMenu.h
+++ b/zlibrary/core/src/ui/application-desktop/ZLTQtPopupMenu.h
@@ -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__ */