Merge branch 'Issue_1151_ResidualGapOnFillGaps' of https://github.com/TomDoingArt/tahoma2d into Issue_1151_ResidualGapOnFillGaps

This commit is contained in:
Tom 2023-09-14 21:46:56 -04:00
commit 20b10d6ef7
8 changed files with 238 additions and 92 deletions

View file

@ -15,6 +15,7 @@ source /opt/qt515/bin/qt515-env.sh
export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
cmake ../sources \
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DWITH_GPHOTO2:BOOL=ON \
-DWITH_SYSTEM_SUPERLU=ON

View file

@ -78,7 +78,7 @@ then
fi
export LD_LIBRARY_PATH=appdir/usr/lib/tahoma2d
./linuxdeployqt*.AppImage appdir/usr/bin/Tahoma2D -bundle-non-qt-libs -verbose=0 -always-overwrite \
./linuxdeployqt*.AppImage appdir/usr/bin/Tahoma2D -bundle-non-qt-libs -verbose=0 -always-overwrite -no-strip \
-executable=appdir/usr/bin/lzocompress \
-executable=appdir/usr/bin/lzodecompress \
-executable=appdir/usr/bin/tcleanup \
@ -91,7 +91,7 @@ rm appdir/AppRun
cp ../sources/scripts/AppRun appdir
chmod 775 appdir/AppRun
./linuxdeployqt*.AppImage appdir/usr/bin/Tahoma2D -appimage
./linuxdeployqt*.AppImage appdir/usr/bin/Tahoma2D -appimage -no-strip
mv Tahoma2D*.AppImage Tahoma2D/Tahoma2D.AppImage

View file

@ -29,6 +29,7 @@ fi
export PKG_CONFIG_PATH="$PKG_CONFIG_PATH:/usr/local/opt/jpeg-turbo/lib/pkgconfig"
cmake ../sources $CANON_FLAG \
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DWITH_GPHOTO2=ON \
-DQT_PATH=$USEQTLIB \
-DTIFF_INCLUDE_DIR=../../thirdparty/tiff-4.2.0/libtiff/ \

View file

@ -13,7 +13,7 @@ then
export TOONZDIR=$TOONZDIR/Release
fi
echo ">>> Copying stuff to $TOONZDIR/Tahoma2D.app/tahomastuff"
echo ">>> Copying stuff to Tahoma2D.app/tahomastuff"
if [ -d $TOONZDIR/Tahoma2D.app/tahomastuff ]
then
# In case of prior builds, replace stuff folder
@ -26,7 +26,7 @@ find $TOONZDIR/Tahoma2D.app/tahomastuff -name .gitkeep -exec rm -f {} \;
if [ -d thirdparty/apps/ffmpeg/bin ]
then
echo ">>> Copying FFmpeg to $TOONZDIR/Tahoma2D.app/ffmpeg"
echo ">>> Copying FFmpeg to Tahoma2D.app/ffmpeg"
if [ -d $TOONZDIR/Tahoma2D.app/ffmpeg ]
then
# In case of prior builds, replace ffmpeg folder
@ -39,7 +39,7 @@ fi
if [ -d thirdparty/apps/rhubarb ]
then
echo ">>> Copying Rhubarb Lip Sync to $TOONZDIR/Tahoma2D.app/rhubarb"
echo ">>> Copying Rhubarb Lip Sync to Tahoma2D.app/rhubarb"
if [ -d $TOONZDIR/Tahoma2D.app/rhubarb ]
then
# In case of prior builds, replace rhubarb folder
@ -57,17 +57,40 @@ fi
if [ -d thirdparty/canon/Framework ]
then
echo ">>> Copying canon framework to $TOONZDIR/Tahoma2D.app/Contents/Frameworks/EDSDK.Framework"
cp -R thirdparty/canon/Framework/ $TOONZDIR/Tahoma2D.app/Contents/Frameworks
chmod -R 755 $TOONZDIR/Tahoma2D.app/Contents/Frameworks/EDSDK.framework
if [ ! -d $TOONZDIR/Tahoma2D.app/Contents/Frameworks/EDSDK.framework ]
then
echo ">>> Copying canon framework to Tahoma2D.app/Contents/Frameworks/EDSDK.Framework"
cp -R thirdparty/canon/Framework/ $TOONZDIR/Tahoma2D.app/Contents/Frameworks
chmod -R 755 $TOONZDIR/Tahoma2D.app/Contents/Frameworks/EDSDK.framework
fi
fi
echo ">>> Copying libghoto2 supporting directories"
cp -R /usr/local/lib/libgphoto2 $TOONZDIR/Tahoma2D.app/Contents/Frameworks
cp -R /usr/local/lib/libgphoto2_port $TOONZDIR/Tahoma2D.app/Contents/Frameworks
if [ ! -d $TOONZDIR/Tahoma2D.app/Contents/Frameworks/libgphoto2 ]
then
echo ">>> Copying libghoto2 supporting directories to Tahoma2D.app/Contents/Frameworks"
cp -R /usr/local/lib/libgphoto2 $TOONZDIR/Tahoma2D.app/Contents/Frameworks
cp -R /usr/local/lib/libgphoto2_port $TOONZDIR/Tahoma2D.app/Contents/Frameworks
rm $TOONZDIR/Tahoma2D.app/Contents/Frameworks/libgphoto2/print-camera-list
find $TOONZDIR/Tahoma2D.app/Contents/Frameworks/libgphoto2* -name *.la -exec rm -f {} \;
rm $TOONZDIR/Tahoma2D.app/Contents/Frameworks/libgphoto2/print-camera-list
find $TOONZDIR/Tahoma2D.app/Contents/Frameworks/libgphoto2* -name *.la -exec rm -f {} \;
fi
echo ">>> Creating DSYM files"
if [ -d $TOONZDIR/DSYM ]
then
rm -rf $TOONZDIR/DSYM
fi
for X in `find $TOONZDIR/Tahoma2D.app/Contents/MacOS -type f`
do
dsymutil -o $TOONZDIR/DSYM $X
strip -S $X
done
if [ -d $TOONZDIR/Tahoma2D.app/DSYM ]
then
rm -rf $TOONZDIR/Tahoma2D.app/DSYM
fi
echo ">>> Configuring Tahoma2D.app for deployment"
@ -80,36 +103,81 @@ $QTDIR/bin/macdeployqt $TOONZDIR/Tahoma2D.app -verbose=0 -always-overwrite \
-executable=$TOONZDIR/Tahoma2D.app/Contents/MacOS/tfarmcontroller \
-executable=$TOONZDIR/Tahoma2D.app/Contents/MacOS/tfarmserver
echo ">>> Correcting library paths"
for X in `find $TOONZDIR/Tahoma2D.app/Contents -type f '(' -name *.dylib -o -name *.so ')' -exec otool -l {} \; | grep -e "^toonz" -e"name \/usr\/local" -e"@rpath" | sed -e"s/://" -e"s/ (.*$//" -e"s/^ *name //"`
for FW in `echo "QtDBus QtPdf QtQml QtQmlModels QtQuick QtVirtualKeyboard"`
do
Z=`echo $X | cut -c 1-1`
if [ "$Z" != "/" -a "$Z" != "@" ]
if [ ! -d $TOONZDIR/Tahoma2D.app/Contents/Frameworks/$FW.framework ]
then
LIBFILE=$X
else
Y=`basename $X`
W=`basename $LIBFILE`
if [ ! -f $TOONZDIR/Tahoma2D.app/Contents/Frameworks/$Y ]
then
echo "Copying $X to Frameworks"
cp $X $TOONZDIR/Tahoma2D.app/Contents/Frameworks
chmod 644 $TOONZDIR/Tahoma2D.app/Contents/Frameworks/$Y
fi
if [ "$Y" != "$W" ]
then
echo "Fixing $X in $LIBFILE"
install_name_tool -change $X @executable_path/../Frameworks/$Y $LIBFILE
FIXCHECK=`otool -D $LIBFILE | grep -e"\/usr\/local"`
if [ "$FIXCHECK" == "$X" ]
then
echo " Fixed ID!"
install_name_tool -id @executable_path/../Frameworks/$Y $LIBFILE
fi
fi
echo ">>> Copying missing $FW.framework to Tahoma2D.app/Contents/Frameworks"
cp -r $QTDIR/Frameworks/$FW.framework $TOONZDIR/Tahoma2D.app/Contents/Frameworks
fi
done
if [ ! -d $TOONZDIR/Tahoma2D.app/Contents/lib ]
then
echo ">>> Adding Contents/lib symbolic link to Tahoma2D.app/Contents/Frameworks"
ln -s Frameworks $TOONZDIR/Tahoma2D.app/Contents/lib
fi
echo ">>> Correcting library paths"
function checkLibFile() {
local LIBFILE=$1
for DEPFILE in `otool -L $LIBFILE | sed -e "s/ (.*$//" | grep -e"\/usr\/local" -e"@rpath" -e"\.\./\.\./\.\." | grep -v "/qt"`
do
local Z=`echo $DEPFILE | cut -c 1-1`
if [ "$Z" = "/" -o "$Z" = "@" ]
then
local Y=`basename $DEPFILE`
local W=`basename $LIBFILE`
local X=`echo $DEPFILE | grep "\.framework\/"`
if [ "$X" = "" -a ! -f $TOONZDIR/Tahoma2D.app/Contents/Frameworks/$Y ]
then
local SRC=$DEPFILE
local Z=`echo $DEPFILE | cut -c 1-16`
local Z2=`echo $DEPFILE | cut -c 1-6`
if [ "$Z" = "@loader_path/../" ]
then
local V=`echo $DEPFILE | sed -e"s/^.*\/\.\.\///"`
local SRC=/usr/local/$V
elif [ "$Z2" = "@rpath" ]
then
local SRC=/usr/local/lib/$Y
fi
echo "Copying $SRC to Frameworks"
cp $SRC $TOONZDIR/Tahoma2D.app/Contents/Frameworks
chmod 644 $TOONZDIR/Tahoma2D.app/Contents/Frameworks/$Y
local ORIGDEPFILE=$DEPFILE
checkLibFile $TOONZDIR/Tahoma2D.app/Contents/Frameworks/$Y
DEPFILE=$ORIGDEPFILE
fi
if [ "$Y" != "$W" ]
then
echo "Fixing $DEPFILE in $LIBFILE"
if [ "$X" != "" ]
then
local Y=`echo $DEPFILE | sed -e"s/^.*\/\.\.\///"`
install_name_tool -change $DEPFILE @executable_path/../Frameworks/$Y $LIBFILE
else
install_name_tool -change $DEPFILE @executable_path/../Frameworks/$Y $LIBFILE
fi
fi
FIXCHECK=`otool -D $LIBFILE | grep -v ":" | grep -e"\/usr\/local"`
if [ "$FIXCHECK" == "$DEPFILE" ]
then
echo " Fixed ID!"
install_name_tool -id @executable_path/../Frameworks/$Y $LIBFILE
fi
fi
done
}
for FILE in `find $TOONZDIR/Tahoma2D.app/Contents -type f | grep -v -e"\.h" -e"\.prl" -e"\.plist" -e"\.conf" -e"\.icns" -e"EDSDK" -e"\/Headers\/"`
do
checkLibFile $FILE
done
echo ">>> Moving DYSM to Tahoma2D.app"
mv $TOONZDIR/DSYM $TOONZDIR/Tahoma2D.app
echo ">>> Creating Tahoma2D-osx.dmg"
$QTDIR/bin/macdeployqt $TOONZDIR/Tahoma2D.app -dmg -verbose=0

View file

@ -549,7 +549,7 @@ elseif(BUILD_ENV_UNIXLIKE)
Tahoma2D Qt5::Core Qt5::Gui Qt5::Network Qt5::OpenGL Qt5::Svg Qt5::Xml
Qt5::Script Qt5::Widgets Qt5::PrintSupport Qt5::Multimedia Qt5::SerialPort Qt5::UiTools
${GL_LIB} ${GLUT_LIB} ${GLU_LIB} ${TURBOJPEG_LIB} ${OpenCV_LIBS}
${EXTRA_LIBS}
${EXTRA_LIBS} dl
)
endif()

View file

@ -9,11 +9,16 @@
#include <dbghelp.h>
#include <psapi.h>
#else
#ifdef MACOSX
#include <mach-o/dyld.h>
#else
#include <link.h>
#endif
#include <execinfo.h>
#include <signal.h>
#include <unistd.h>
#include <err.h>
#include <regex>
#include <dlfcn.h>
#endif
#include "tgl.h"
@ -26,6 +31,7 @@
#include "toonz/tproject.h"
#include "toonz/tscenehandle.h"
#include "toonz/toonzscene.h"
#include "tsystem.h"
#include <QOperatingSystemVersion>
#include <QDesktopServices>
@ -41,6 +47,8 @@
#include <QTextEdit>
#include <QPushButton>
#include <QDebug>
static QWidget *s_parentWindow = NULL;
static bool s_reportProjInfo = false;
#ifdef _WIN32
@ -56,6 +64,15 @@ static const char *filenameOnly(const char *path) {
return path;
}
//-----------------------------------------------------------------------------
static QString obfuscateUsername(QString path) {
QString username = TSystem::getUserName();
QString newPath = path;
newPath.replace("/" + username + "/", "/USER/");
newPath.replace("\\" + username + "\\", "\\USER\\");
return newPath;
}
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// Windows platform functions
@ -93,7 +110,8 @@ static void printModules(std::string &out) {
for (unsigned int i = 0; i < size / sizeof(HMODULE); i++) {
char moduleName[512];
GetModuleFileNameA(modules[i], moduleName, 512);
out.append(moduleName);
QString path = obfuscateUsername(QString(moduleName));
out.append(path.toStdString());
out.append("\n");
}
}
@ -291,12 +309,13 @@ static bool sh(std::string &out, const char *cmd) {
//-----------------------------------------------------------------------------
static bool addr2line(std::string &out, const char *exepath, const char *addr) {
static bool addr2line(std::string &out, const char *exepath, const size_t addr,
const size_t laddr) {
char cmd[512];
#ifdef OSX
sprintf(cmd, "atos -o \"%.400s\" %s 2>&1", exepath, addr);
#ifdef MACOSX
sprintf(cmd, "atos -o \"%.400s\" -l %p %p 2>&1", exepath, laddr, addr);
#else
sprintf(cmd, "addr2line -f -p -e \"%.400s\" %s 2>&1", exepath, addr);
sprintf(cmd, "addr2line -fpCis -e \"%.400s\" %p 2>&1", exepath, addr);
#endif
return sh(out, cmd);
}
@ -307,7 +326,35 @@ static bool generateMinidump(TFilePath dumpFile) { return false; }
//-----------------------------------------------------------------------------
static void printModules(std::string &out) {}
#define HAS_MODULES
#ifdef LINUX
static int printModuleInfo(struct dl_phdr_info *i, size_t size, void *data) {
std::string *out = (std::string *)data;
char addr[512];
sprintf(addr, "%p", (long)i->dlpi_addr);
out->append(std::string(addr) + " - " + std::string(i->dlpi_name) + "\n");
return 0;
}
#endif
static void printModules(std::string &out) {
#ifdef MACOSX
char str[512];
int c = _dyld_image_count();
for (int i = 0; i < c; i++) {
const char *image_name = _dyld_get_image_name(i);
const struct mach_header *header = _dyld_get_image_header(i);
uintptr_t loadaddr = (uintptr_t)header;
sprintf(str, "%p", loadaddr);
QString path = obfuscateUsername(QString(image_name));
out.append(std::string(str) + " - " + path.toStdString());
out.append("\n");
}
#else
dl_iterate_phdr(printModuleInfo, &out);
#endif
}
//-----------------------------------------------------------------------------
@ -319,42 +366,55 @@ static void printBacktrace(std::string &out) {
const int size = 256;
void *buffer[size];
// Get executable path
char exepath[512];
memset(exepath, 0, 512);
if (readlink("/proc/self/exe", exepath, 512) < 0)
fprintf(stderr, "Couldn't get exe path\n");
// Back trace
int nptrs = backtrace(buffer, size);
char **bts = backtrace_symbols(buffer, nptrs);
std::regex re("\\[(.+)\\]");
if (bts) {
for (int i = 0; i < nptrs; ++i) {
// Skip first frames since they point to this function
if (frameStack++ < frameSkip) continue;
char numStr[32];
memset(numStr, 0, sizeof(numStr));
sprintf(numStr, "%3i> ", frameStack - frameSkip);
out.append(numStr);
int nptrs = backtrace(buffer, size);
for (int i = 0; i < nptrs; ++i) {
// Skip first frames since they point to this function
if (frameStack++ < frameSkip) continue;
char numStr[32];
memset(numStr, 0, sizeof(numStr));
sprintf(numStr, "%3i> ", frameStack - frameSkip);
out.append(numStr);
std::string sym = bts[i];
std::string line;
std::smatch ms;
std::string line;
std::string sym = "??? at ??:?";
std::string module = "???";
size_t addr = (size_t)buffer[i];
bool found = false;
if (std::regex_search(sym, ms, re)) {
std::string addr = ms[1];
if (addr2line(line, exepath, addr.c_str())) {
found = (line.rfind("??", 0) != 0);
}
}
bool found = false;
out.append(found ? line : (sym + "\n"));
Dl_info info;
int infoFound = dladdr(buffer[i], &info);
if (infoFound) module = std::string(info.dli_fname);
#ifdef MACOSX
if (module.find("Tahoma2D.app/Contents/MacOS") != std::string::npos) {
std::string dsym = module;
int pos = dsym.find("Contents");
dsym.replace(pos, 14, "DSYM/Contents/Resources/DWARF");
TFilePath file(dsym);
if (TFileStatus(file).doesExist()) module = dsym;
}
}
free(bts);
char addrstr[512];
sprintf(addrstr, "%p", addr);
sym = std::string(addrstr) + " (in " + module + ")";
#else
link_map *link_map;
dladdr1(buffer[i], &info, (void **)&link_map, RTLD_DL_LINKMAP);
addr -= link_map->l_addr;
#endif
if (infoFound &&
addr2line(line, module.c_str(), addr, (size_t)info.dli_fbase)) {
found = (line.rfind("??", 0) != 0) &&
(line.find("cannot load symbol", 0) != 0) &&
(line.find("command not found") != 0);
}
out.append(found ? line : (sym + "\n"));
}
}
void signalHandler(int sig) {
@ -543,6 +603,7 @@ bool CrashHandler::trigger(const QString reason, bool showDialog) {
char dateName[128];
std::string out;
// Get time and build filename
time_t acc_time;
time(&acc_time);
@ -558,7 +619,7 @@ bool CrashHandler::trigger(const QString reason, bool showDialog) {
bool minidump = generateMinidump(fpDump, s_exceptionPtr);
#else
bool minidump = generateMinidump(fpDump);
#endif;
#endif
// Generate report
try {
@ -572,11 +633,11 @@ bool CrashHandler::trigger(const QString reason, bool showDialog) {
out.append("\n");
printGPUInfo(out);
out.append("\nCrash File: ");
out.append(fpCrsh.getQString().toStdString());
out.append(obfuscateUsername(fpCrsh.getQString()).toStdString());
#ifdef HAS_MINIDUMP
out.append("\nMini Dump File: ");
if (minidump)
out.append(fpDump.getQString().toStdString());
out.append(obfuscateUsername(fpDump.getQString()).toStdString());
else
out.append("Failed");
#endif
@ -595,18 +656,21 @@ bool CrashHandler::trigger(const QString reason, bool showDialog) {
std::wstring sceneName = currentScene->getSceneName();
out.append("\nApplication Dir: ");
out.append(QCoreApplication::applicationDirPath().toStdString());
out.append(obfuscateUsername(QCoreApplication::applicationDirPath())
.toStdString());
out.append("\nStuff Dir: ");
out.append(TEnv::getStuffDir().getQString().toStdString());
out.append(
obfuscateUsername(TEnv::getStuffDir().getQString()).toStdString());
out.append("\n");
out.append("\nProject Name: ");
out.append(currentProject->getName().getQString().toStdString());
out.append("\nScene Name: ");
out.append(QString::fromStdWString(sceneName).toStdString());
out.append("\nProject Path: ");
out.append(projectPath.getQString().toStdString());
out.append(obfuscateUsername(projectPath.getQString()).toStdString());
out.append("\nScene Path: ");
out.append(currentScene->getScenePath().getQString().toStdString());
out.append(obfuscateUsername(currentScene->getScenePath().getQString())
.toStdString());
out.append("\n");
}
} catch (...) {

View file

@ -446,11 +446,15 @@ int main(int argc, char *argv[]) {
}
#endif
// Set show icons in menus flag (use iconVisibleInMenu to disable selectively)
QApplication::instance()->setAttribute(Qt::AA_DontShowIconsInMenus, false);
TEnv::setApplicationFileName(argv[0]);
// Set show icons in menus flag (use iconVisibleInMenu to disable selectively)
bool dontShowIcon =
!Preferences::instance()->isShowAdvancedOptionsEnabled() ||
!Preferences::instance()->getBoolValue(showIconsInMenu);
QApplication::instance()->setAttribute(Qt::AA_DontShowIconsInMenus,
dontShowIcon);
// splash screen
QPixmap splashPixmap =
QIcon(":Resources/tahoma2d_splash.svg").pixmap(QSize(344, 344));

View file

@ -568,11 +568,19 @@ QIcon createQIcon(const QString &iconSVGName, bool useFullOpacity,
// there can be scaling artifacts with high dpi and load these in addition
if (baseImg.width() == (16 * devPixRatio) &&
baseImg.height() == (16 * devPixRatio)) {
QSize expandSize(20, 20);
QImage toolBaseImg(compositeImage(baseImg, expandSize));
QImage toolOverImg(compositeImage(overImg, expandSize));
QImage toolOnImg(compositeImage(onImg, expandSize));
addImagesToIcon(icon, toolBaseImg, toolOverImg, toolOnImg, useFullOpacity);
for (auto screen : QApplication::screens()) {
QSize expandSize(20, 20);
int otherDevPixRatio = screen->devicePixelRatio();
if (otherDevPixRatio != devPixRatio) {
expandSize.setWidth(16 * otherDevPixRatio);
expandSize.setHeight(16 * otherDevPixRatio);
}
QImage toolBaseImg(compositeImage(baseImg, expandSize));
QImage toolOverImg(compositeImage(overImg, expandSize));
QImage toolOnImg(compositeImage(onImg, expandSize));
addImagesToIcon(icon, toolBaseImg, toolOverImg, toolOnImg,
useFullOpacity);
}
}
return icon;