mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-08-13 01:54:13 +02:00
5dec36cb29
Stacked on the steps 1-3 branch (feature-diagnostic-logging, PR #646). Kept as its own PR rather than folded into that one, matching the discussion's own framing: step 4 is explicitly "the highest-risk piece ... lands last, behind its own switch." ## Step 4 -- crash-time ring flush (CrashHandler) Installs a handler for SIGSEGV/SIGABRT/SIGBUS/SIGFPE/SIGILL (POSIX) / SetUnhandledExceptionFilter (Windows) that flushes the in-memory ring to a fixed crash_dump.log before the process dies. This required reworking LogRing (step 3) to be genuinely lock-free, not just mutex-protected: a signal handler that blocks on a lock the crashing thread (or another thread) already holds turns a clean crash into a hang -- no ring dump *and* no core dump, worse than doing nothing. append() now claims a slot with a single atomic fetch-add; dumpToFd() reads the preallocated entries directly and writes them with write(2) only, looping on EINTR/short writes. Accepted tradeoff: at most one entry can be read torn if a crash lands mid-append into that exact slot -- documented in logring.h, and the alternative (a seqlock to detect and retry) wasn't judged worth the complexity for that window. Other invariants implemented per the discussion: - sigaltstack with a static 64 KiB buffer, SA_ONSTACK -- a stack- overflow SIGSEGV has no usable stack for a handler without one. - Nothing under the actual handler touches Qt, QString or the allocator: the dump path and a small header (version/git/OS/Qt) are precomputed into fixed char buffers by install(), which runs once at startup in normal context. - Atomic test-and-set so only the first crash writes a dump; a second concurrent/nested fault goes straight to restore-and-re-raise. - After writing, the handler restores SIG_DFL and re-raises (POSIX) / returns EXCEPTION_CONTINUE_SEARCH (Windows) so the OS's own crash path -- core dump, Windows Error Reporting -- still runs. A handler that "fixed" the crash by swallowing the signal would destroy exactly the post-mortem evidence this whole design exists to preserve. Tested in this environment: POSIX/Linux only, all five signals. Sent each directly to a running process and confirmed (a) crash_dump.log is written with the correct header and ring contents, mode 0600, and (b) the process still terminates via the signal with the kernel's own "core dumped" flag set (exit code 128+signal, confirmed for all five). The Windows path is implemented per the discussion's guidance but is untested -- no Windows build available in this sandbox. ## Step 5 -- getting the data back out - QETApp::checkCrashDump(), called from checkBackupFiles() only when there's no stale project file to recover this run (so the two prompts never both show, per the discussion), offers an unretrieved crash dump via DiagnosticsReportDialog and then deletes it regardless of the user's choice -- offered exactly once. - A new "Aide > Enregistrer un rapport de diagnostic..." action (QETMainWindow) builds the same kind of report from the *current* session (QetLogger::buildDiagnosticsReport(): header + this session's log file) for a manual "attach this to a bug report" flow, not tied to a crash. - Both go through QetLogger::redact() before ever reaching the user: the one redaction implemented is a literal replace of the home directory with "~", since an absolute path under it leaks the account name. The discussion's fancier "optionally redact project filenames too" isn't attempted -- reliably telling a project path apart from arbitrary log text is a much fuzzier problem than a literal prefix match. - DiagnosticsReportDialog shows the full (already-redacted) content before saving, per the discussion: "the user is about to attach this to a public tracker." Verified in a real GUI session (Xvfb): triggered a SIGSEGV, relaunched, confirmed the crash-report dialog appears with the right header/content, confirmed it does not reappear on a second relaunch, and confirmed the manual "Save report" action produces a correctly-formatted report and saves it to a chosen path. Built clean, no new warnings. ## Build systems Registered in both: cmake/qet_compilation_vars.cmake, and qelectrotech.pro. The .pro needed explicit globs for the new sources/logging/ui/ subfolder -- sources/logging/*.{h,cpp} was already globbed, but unlike the other ui/ subfolders that one had no entry of its own, so diagnosticsreportdialog.{h,cpp} would not have been built under qmake.
382 lines
15 KiB
Prolog
382 lines
15 KiB
Prolog
######################################################################
|
|
# Fichier projet de QElectroTech #
|
|
######################################################################
|
|
|
|
# Chemins utilises pour la compilation et l'installation de QET
|
|
unix {
|
|
# Chemins UNIX
|
|
COMPIL_PREFIX = '/usr/local/'
|
|
INSTALL_PREFIX = '/usr/local/'
|
|
QET_BINARY_PATH = 'bin/'
|
|
QET_COMMON_COLLECTION_PATH = 'share/qelectrotech/elements/'
|
|
QET_COMMON_TBT_PATH = 'share/qelectrotech/titleblocks/'
|
|
QET_LANG_PATH = 'share/qelectrotech/lang/'
|
|
QET_EXAMPLES_PATH = 'share/qelectrotech/examples/'
|
|
QET_LICENSE_PATH = 'doc/qelectrotech/'
|
|
QET_MIME_PACKAGE_PATH = '../share/mime/packages/'
|
|
QET_DESKTOP_PATH = 'share/applications/'
|
|
QET_ICONS_PATH = 'share/icons/hicolor/'
|
|
QET_MAN_PATH = 'man/'
|
|
QET_APPDATA_PATH = 'share/appdata'
|
|
}
|
|
win32 {
|
|
# Chemins Windows
|
|
COMPIL_PREFIX = './'
|
|
INSTALL_PREFIX = './'
|
|
QET_BINARY_PATH = './'
|
|
QET_COMMON_COLLECTION_PATH = 'elements/'
|
|
QET_COMMON_TBT_PATH = 'titleblocks/'
|
|
QET_LANG_PATH = 'lang/'
|
|
QET_LICENSE_PATH = './'
|
|
# Liste des ressources Windows
|
|
#RC_FILE = qelectrotech.rc
|
|
}
|
|
macx {
|
|
# Chemins MacOS X
|
|
COMPIL_PREFIX = './'
|
|
INSTALL_PREFIX = '/usr/local/'
|
|
QET_BINARY_PATH = 'bin/'
|
|
QET_COMMON_COLLECTION_PATH = '../Resources/elements/'
|
|
QET_COMMON_TBT_PATH = '../Resources/titleblocks/'
|
|
QET_LANG_PATH = '../Resources/lang/'
|
|
QET_EXAMPLES_PATH = 'share/qelectrotech/examples/'
|
|
QET_LICENSE_PATH = 'doc/qelectrotech/'
|
|
QET_DESKTOP_PATH = 'share/applications/'
|
|
QET_ICONS_PATH = 'share/icons/hicolor/'
|
|
QET_MAN_PATH = 'man/'
|
|
ICON = 'ico/mac_icon/qelectrotech.icns'
|
|
|
|
}
|
|
|
|
# Commenter la ligne ci-dessous pour desactiver l'option --common-elements-dir
|
|
DEFINES += QET_ALLOW_OVERRIDE_CED_OPTION
|
|
|
|
# Comment the line below to disable the --common-tbt-dir option
|
|
DEFINES += QET_ALLOW_OVERRIDE_CTBTD_OPTION
|
|
|
|
# Commenter la ligne ci-dessous pour desactiver l'option --config-dir
|
|
DEFINES += QET_ALLOW_OVERRIDE_CD_OPTION
|
|
|
|
# Commenter la ligne ci-dessous pour desactiver l'option --data-dir
|
|
DEFINES += QET_ALLOW_OVERRIDE_DD_OPTION
|
|
|
|
#comment the line below to disable the project database export
|
|
DEFINES += QET_EXPORT_PROJECT_DB
|
|
|
|
# warn on *any* usage of deprecated APIs
|
|
#DEFINES += QT_DEPRECATED_WARNINGS
|
|
|
|
|
|
######################################################################
|
|
|
|
include(sources/PropertiesEditor/PropertiesEditor.pri)
|
|
include(sources/QetGraphicsItemModeler/QetGraphicsItemModeler.pri)
|
|
include(sources/QPropertyUndoCommand/QPropertyUndoCommand.pri)
|
|
include(SingleApplication/singleapplication.pri)
|
|
include(sources/QWidgetAnimation/QWidgetAnimation.pri)
|
|
|
|
DEFINES += QAPPLICATION_CLASS=QApplication
|
|
DEFINES += QT_MESSAGELOGCONTEXT
|
|
DEFINES += GIT_COMMIT_SHA="\\\"$(shell git -C \""$$_PRO_FILE_PWD_"\" rev-parse --verify HEAD 2>/dev/null || true)\\\""
|
|
|
|
# You can make your code fail to compile if it uses deprecated APIs.
|
|
# In order to do so, uncomment the following line.
|
|
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
|
|
|
|
# You can make your code warn on compile time for the TODO's
|
|
# In order to do so, uncomment the following line.
|
|
#DEFINES += TODO_LIST
|
|
|
|
TEMPLATE = app
|
|
|
|
#ToDo comment close the gap with Cmake
|
|
#this is my next problem now
|
|
INCLUDEPATH += sources/ui
|
|
|
|
#comment close the gap with Cmake (De-Backer)
|
|
#DEPENDPATH += .
|
|
#INCLUDEPATH += sources \
|
|
# sources/titleblock \
|
|
# sources/ui \
|
|
# sources/qetgraphicsitem \
|
|
# sources/qetgraphicsitem/ViewItem \
|
|
# sources/qetgraphicsitem/ViewItem/ui \
|
|
# sources/richtext \
|
|
# sources/factory \
|
|
# sources/properties \
|
|
# sources/dvevent \
|
|
# sources/editor \
|
|
# sources/editor/esevent \
|
|
# sources/editor/graphicspart \
|
|
# sources/editor/ui \
|
|
# sources/editor/UndoCommand \
|
|
# sources/undocommand \
|
|
# sources/diagramevent \
|
|
# sources/ElementsCollection \
|
|
# sources/ElementsCollection/ui \
|
|
# sources/autoNum \
|
|
# sources/autoNum/ui \
|
|
# sources/ui/configpage \
|
|
# sources/SearchAndReplace \
|
|
# sources/SearchAndReplace/ui \
|
|
# sources/NameList \
|
|
# sources/NameList/ui \
|
|
# sources/utils \
|
|
# pugixml \
|
|
# sources/dataBase \
|
|
# sources/dataBase/ui \
|
|
# sources/factory/ui \
|
|
# sources/print
|
|
|
|
# Fichiers sources
|
|
HEADERS += $$files(sources/*.h) \
|
|
$$files(sources/project/*.h) \
|
|
$$files(sources/ui/*.h) \
|
|
$$files(sources/editor/*.h) \
|
|
$$files(sources/titleblock/*.h) \
|
|
$$files(sources/richtext/*.h) \
|
|
$$files(sources/qetgraphicsitem/*.h) \
|
|
$$files(sources/qetgraphicsitem/ViewItem/*.h) \
|
|
$$files(sources/qetgraphicsitem/ViewItem/ui/*.h) \
|
|
$$files(sources/factory/*.h) \
|
|
$$files(sources/properties/*.h) \
|
|
$$files(sources/editor/ui/*.h) \
|
|
$$files(sources/editor/esevent/*.h) \
|
|
$$files(sources/editor/graphicspart/*.h) \
|
|
$$files(sources/editor/UndoCommand/*h) \
|
|
$$files(sources/dvevent/*.h) \
|
|
$$files(sources/undocommand/*.h) \
|
|
$$files(sources/diagramevent/*.h) \
|
|
$$files(sources/ElementsCollection/*.h) \
|
|
$$files(sources/ElementsCollection/ui/*.h) \
|
|
$$files(sources/autoNum/*.h) \
|
|
$$files(sources/autoNum/ui/*.h) \
|
|
$$files(sources/ui/configpage/*.h) \
|
|
$$files(sources/SearchAndReplace/*.h) \
|
|
$$files(sources/SearchAndReplace/ui/*.h) \
|
|
$$files(sources/NameList/*.h) \
|
|
$$files(sources/NameList/ui/*.h) \
|
|
$$files(sources/utils/*.h) \
|
|
$$files(pugixml/src/*.hpp) \
|
|
$$files(sources/dataBase/*.h) \
|
|
$$files(sources/dataBase/ui/*.h) \
|
|
$$files(sources/factory/ui/*.h) \
|
|
$$files(sources/print/*.h) \
|
|
$$files(sources/TerminalStrip/*.h) \
|
|
$$files(sources/TerminalStrip/ui/*.h) \
|
|
$$files(sources/TerminalStrip/ui/ConfigPage/*h) \
|
|
$$files(sources/TerminalStrip/UndoCommand/*.h) \
|
|
$$files(sources/TerminalStrip/GraphicsItem/*.h) \
|
|
$$files(sources/TerminalStrip/GraphicsItem/properties/*.h) \
|
|
$$files(sources/xml/*.h) \
|
|
$$files(sources/dxf/*.h) \
|
|
$$files(sources/qet_elementscaler/*.h) \
|
|
$$files(sources/svg/*.h) \
|
|
$$files(sources/import/edz/*.h) \
|
|
$$files(sources/import/edz/lzma/*.h) \
|
|
$$files(sources/logging/*.h) \
|
|
$$files(sources/logging/ui/*.h)
|
|
|
|
SOURCES += $$files(sources/*.cpp) \
|
|
$$files(sources/editor/*.cpp) \
|
|
$$files(sources/project/*.cpp) \
|
|
$$files(sources/titleblock/*.cpp) \
|
|
$$files(sources/richtext/*.cpp) \
|
|
$$files(sources/ui/*.cpp) \
|
|
$$files(sources/qetgraphicsitem/*.cpp) \
|
|
$$files(sources/qetgraphicsitem/ViewItem/*.cpp) \
|
|
$$files(sources/qetgraphicsitem/ViewItem/ui/*.cpp) \
|
|
$$files(sources/factory/*.cpp) \
|
|
$$files(sources/properties/*.cpp) \
|
|
$$files(sources/editor/ui/*.cpp) \
|
|
$$files(sources/editor/esevent/*.cpp) \
|
|
$$files(sources/editor/graphicspart/*.cpp) \
|
|
$$files(sources/editor/UndoCommand/*cpp) \
|
|
$$files(sources/dvevent/*.cpp) \
|
|
$$files(sources/undocommand/*.cpp) \
|
|
$$files(sources/diagramevent/*.cpp) \
|
|
$$files(sources/ElementsCollection/*.cpp) \
|
|
$$files(sources/ElementsCollection/ui/*.cpp) \
|
|
$$files(sources/autoNum/*.cpp) \
|
|
$$files(sources/autoNum/ui/*.cpp) \
|
|
$$files(sources/ui/configpage/*.cpp) \
|
|
$$files(sources/SearchAndReplace/*.cpp) \
|
|
$$files(sources/SearchAndReplace/ui/*.cpp) \
|
|
$$files(sources/NameList/*.cpp) \
|
|
$$files(sources/NameList/ui/*.cpp) \
|
|
$$files(sources/utils/*.cpp) \
|
|
$$files(pugixml/src/*.cpp) \
|
|
$$files(sources/dataBase/*.cpp) \
|
|
$$files(sources/dataBase/ui/*.cpp) \
|
|
$$files(sources/factory/ui/*.cpp) \
|
|
$$files(sources/print/*.cpp) \
|
|
$$files(sources/TerminalStrip/*.cpp) \
|
|
$$files(sources/TerminalStrip/ui/*.cpp) \
|
|
$$files(sources/TerminalStrip/ui/ConfigPage/*cpp) \
|
|
$$files(sources/TerminalStrip/UndoCommand/*.cpp) \
|
|
$$files(sources/TerminalStrip/GraphicsItem/*.cpp) \
|
|
$$files(sources/TerminalStrip/GraphicsItem/properties/*.cpp) \
|
|
$$files(sources/xml/*.cpp) \
|
|
$$files(sources/dxf/*.cpp) \
|
|
$$files(sources/qet_elementscaler/*.cpp) \
|
|
$$files(sources/svg/*.cpp) \
|
|
$$files(sources/import/edz/*.cpp) \
|
|
$$files(sources/import/edz/lzma/*.c) \
|
|
$$files(sources/logging/*.cpp) \
|
|
$$files(sources/logging/ui/*.cpp)
|
|
|
|
|
|
# Needed for use promote QTreeWidget in terminalstripeditor.ui
|
|
INCLUDEPATH += sources/TerminalStrip/ui
|
|
|
|
# Needed for the EPLAN .edz importer (PR #513) and its bundled lzma/7z sources
|
|
INCLUDEPATH += sources/import/edz
|
|
INCLUDEPATH += sources/import/edz/lzma
|
|
|
|
# Liste des fichiers qui seront incorpores au binaire en tant que ressources Qt
|
|
RESOURCES += qelectrotech.qrc
|
|
|
|
# Liste des ressources Windows
|
|
#RC_FILE = ico/windows_icon/qelectrotech.rc
|
|
|
|
# Fichiers de traduction qui seront installes
|
|
TRANSLATIONS += lang/*.ts
|
|
|
|
# Modules Qt utilises par l'application
|
|
QT += xml svg network sql widgets printsupport concurrent gui-private
|
|
|
|
# KDE Frameworks 5 (KWidgetsAddons, KCoreAddons) are optional.
|
|
#
|
|
# Pass CONFIG+=no_kf5 to qmake to build against the Qt-only replacements in
|
|
# sources/ui/nokde instead. This mirrors the CMake option BUILD_WITH_KF5=OFF
|
|
# and is the easiest route on Windows/MinGW, where KF5 is awkward to obtain.
|
|
#
|
|
# qmake CONFIG+=no_kf5 qelectrotech.pro
|
|
#
|
|
# sources/ui/nokde is only added to the include path in that configuration, so
|
|
# a normal KF5 build is unaffected.
|
|
no_kf5 {
|
|
DEFINES += BUILD_WITHOUT_KF5
|
|
INCLUDEPATH += sources/ui/nokde
|
|
HEADERS += $$files(sources/ui/nokde/*.h)
|
|
SOURCES += $$files(sources/ui/nokde/*.cpp)
|
|
} else {
|
|
QT += KWidgetsAddons KCoreAddons
|
|
}
|
|
|
|
# Private Qt GUI headers (needed for QPdfEngine::drawHyperlink)
|
|
# gui-private should add this automatically, but some distros need it explicit
|
|
INCLUDEPATH += $$[QT_INSTALL_HEADERS]/QtGui/$$[QT_VERSION]/QtGui
|
|
|
|
# UI DESIGNER FILES AND GENERATION SOURCES FILES
|
|
FORMS += $$files(sources/richtext/*.ui) \
|
|
$$files(sources/ui/*.ui) \
|
|
$$files(sources/editor/ui/*.ui) \
|
|
$$files(sources/ElementsCollection/ui/*.ui) \
|
|
$$files(sources/autoNum/ui/*.ui) \
|
|
$$files(sources/ui/configpage/*.ui) \
|
|
$$files(sources/SearchAndReplace/ui/*.ui) \
|
|
$$files(sources/NameList/ui/*.ui) \
|
|
$$files(sources/qetgraphicsitem/ViewItem/ui/*.ui) \
|
|
$$files(sources/dataBase/ui/*.ui) \
|
|
$$files(sources/factory/ui/*.ui) \
|
|
$$files(sources/print/*.ui) \
|
|
$$files(sources/TerminalStrip/ui/*.ui) \
|
|
$$files(sources/TerminalStrip/ui/ConfigPage/*.ui)
|
|
|
|
UI_SOURCES_DIR = sources/ui/
|
|
UI_HEADERS_DIR = sources/ui/
|
|
|
|
# Configuration de la compilation
|
|
CONFIG += c++17 debug_and_release warn_on link_pkgconfig
|
|
|
|
# Nom du binaire genere par la compilation
|
|
TARGET = qelectrotech
|
|
|
|
# Ajustement des bibliotheques utilisees lors de l'edition des liens
|
|
unix:QMAKE_LIBS_THREAD -= -lpthread
|
|
unix|win32: PKGCONFIG += sqlite3
|
|
|
|
# Enable C++17
|
|
QMAKE_CXXFLAGS += -std=c++17
|
|
|
|
# Description de l'installation
|
|
target.path = $$join(INSTALL_PREFIX,,,$${QET_BINARY_PATH})
|
|
|
|
elements.path = $$join(INSTALL_PREFIX,,,$${QET_COMMON_COLLECTION_PATH})
|
|
elements.files = elements/*
|
|
|
|
tbt.path = $$join(INSTALL_PREFIX,,,$${QET_COMMON_TBT_PATH})
|
|
tbt.files = titleblocks/*
|
|
|
|
lang.path = $$join(INSTALL_PREFIX,,,$${QET_LANG_PATH})
|
|
lang.files = $$replace(TRANSLATIONS, '.ts', '.qm')
|
|
|
|
examples.path = $$join(INSTALL_PREFIX,,,$${QET_EXAMPLES_PATH})
|
|
examples.files = examples/*
|
|
|
|
copyright.path = $$join(INSTALL_PREFIX,,,$${QET_LICENSE_PATH})
|
|
copyright.files = LICENSE ELEMENTS.LICENSE CREDIT README ChangeLog
|
|
|
|
mime_package.path = $$join(INSTALL_PREFIX,,,$${QET_MIME_PACKAGE_PATH})
|
|
mime_package.files = misc/qelectrotech.xml
|
|
|
|
desktop.path = $$join(INSTALL_PREFIX,,,$${QET_DESKTOP_PATH})
|
|
desktop.files = misc/org.qelectrotech.qelectrotech.desktop
|
|
|
|
appdata.path = $$join(INSTALL_PREFIX,,,$${QET_APPDATA_PATH})
|
|
appdata.files = misc/qelectrotech.appdata.xml
|
|
|
|
icons.path = $$join(INSTALL_PREFIX,,,$${QET_ICONS_PATH})
|
|
icons.files = ico/breeze-icons/16x16 \
|
|
ico/breeze-icons/22x22 \
|
|
ico/breeze-icons/32x32 \
|
|
ico/breeze-icons/48x48 \
|
|
ico/breeze-icons/64x64 \
|
|
ico/breeze-icons/128x128 \
|
|
ico/breeze-icons/256x256
|
|
|
|
man.path = $$join(INSTALL_PREFIX,,,$${QET_MAN_PATH})
|
|
man.files = man/files/*
|
|
man.extra = sh man/compress_man_pages.sh
|
|
|
|
# L'installation comprend la copie du binaire, des elements, des fichiers de langue et du fichier LICENSE
|
|
INSTALLS += target elements tbt lang copyright
|
|
# Sous Unix, on installe egalement l'icone, un fichier .desktop, des fichiers mime et les pages de manuel
|
|
unix {
|
|
INSTALLS += desktop mime_package icons man examples appdata
|
|
}
|
|
|
|
# Options de compilation communes a Unix et MacOS X
|
|
unix {
|
|
# Chemin des fichiers de traduction ; par defaut : lang/ dans le repertoire d'execution
|
|
DEFINES += QET_LANG_PATH=$$join(COMPIL_PREFIX,,,$${QET_LANG_PATH})
|
|
|
|
# Chemin de la collection commune ; par defaut : elements/ dans le repertoire d'execution
|
|
DEFINES += QET_COMMON_COLLECTION_PATH=$$join(COMPIL_PREFIX,,,$${QET_COMMON_COLLECTION_PATH})
|
|
|
|
DEFINES += QET_COMMON_TBT_PATH=$$join(COMPIL_PREFIX,,,$${QET_COMMON_TBT_PATH})
|
|
}
|
|
|
|
# Options de compilation specifiques a MacOS X
|
|
macx {
|
|
# les chemins definis precedemment sont relatifs au dossier contenant le binaire executable
|
|
DEFINES += QET_LANG_PATH_RELATIVE_TO_BINARY_PATH
|
|
DEFINES += QET_COMMON_COLLECTION_PATH_RELATIVE_TO_BINARY_PATH
|
|
|
|
|
|
equals(QMAKE_TARGET.arch, x86) {
|
|
message( "It's x86" )
|
|
LIBS += /opt/digikam.org.x86_64/lib/libsqlite3.0.dylib
|
|
}
|
|
equals(QMAKE_TARGET.arch, arm64) {
|
|
message( "It's arm64" )
|
|
LIBS += /opt/digikam.org.arm64/lib/libsqlite3.0.dylib
|
|
}
|
|
}
|
|
|
|
# Compilers-specific options
|
|
unix {
|
|
QMAKE_COPY_DIR = 'cp -f -r --preserve=timestamps'
|
|
}
|