fix resource dir not find bug

This commit is contained in:
dreamsourcelabTAI 2021-11-25 10:50:39 +08:00
parent 050b6023d5
commit 5740946c7c
13 changed files with 35 additions and 18 deletions

View File

@ -51,7 +51,6 @@ void usage()
"\n", DS_BIN_NAME, DS_DESCRIPTION);
}
char DS_RES_PATH[256] = {0};
int main(int argc, char *argv[])
{
@ -146,8 +145,6 @@ int main(int argc, char *argv[])
open_file = argvFinal[argcFinal - 1];
}
QString path = GetAppDataDir();
strcpy(DS_RES_PATH, path.toUtf8().data());
//#ifdef Q_OS_DARWIN
//#endif

View File

@ -74,6 +74,9 @@ bool AppControl::Init()
return false;
}
QString resdir = GetResourceDir();
sr_set_firmware_resource_dir(resdir.toUtf8());
QString dir = GetAppDataDir() + "/decoders";
char path[256] = {0};
strcpy(path, dir.toUtf8().data());

View File

@ -307,5 +307,10 @@ QString GetAppDataDir()
}
QString GetResourceDir(){
return GetAppDataDir() + "/res";
QDir dir = GetAppDataDir() + "/res";
if (dir.exists()){
return dir.absolutePath();
}
qDebug() << "dir is not exists:" << dir.absolutePath();
assert(false);
}

View File

@ -35,8 +35,6 @@
struct sr_context;
struct sr_dev_driver;
struct sr_dev_inst;
struct libusbhp_t;
struct libusbhp_device_t;
namespace pv {

View File

@ -86,7 +86,6 @@
#include <stdarg.h>
#include <glib.h>
#include <list>
#include <libusb.h>
#include "ui/msgbox.h"
#include "config/appconfig.h"
#include "appcontrol.h"

View File

@ -200,7 +200,6 @@ void LogoBar::on_actionManual_triggered()
void LogoBar::on_actionIssue_triggered()
{
QDir dir(GetAppDataDir());
QDesktopServices::openUrl(QUrl(QLatin1String("https://github.com/DreamSourceLab/DSView/issues")));
}

View File

@ -23,7 +23,6 @@
#include "../extdef.h"
#include <assert.h>
#include <libusb.h>
#include <QAction>
#include <QDebug>
#include <QLabel>

View File

@ -27,6 +27,9 @@
#include <libusb.h>
#endif
// firmware binary file directory, endswith letter '/'
extern char DS_RES_PATH[256];
/**
* @file
*
@ -119,6 +122,9 @@ SR_PRIV int sr_session_send(const struct sr_dev_inst *sdi,
const struct sr_datafeed_packet *packet);
SR_PRIV int sr_session_stop_sync(void);
SR_PRIV int usb_hotplug_callback(struct libusb_context *ctx, struct libusb_device *dev,
libusb_hotplug_event event, void *user_data);
/*--- std.c -----------------------------------------------------------------*/
typedef int (*dev_close_t)(struct sr_dev_inst *sdi);

View File

@ -134,8 +134,6 @@ enum {
#define MAX_TIMEBASE SR_SEC(10)
#define MIN_TIMEBASE SR_NS(10)
extern char DS_RES_PATH[256];
/** libsigrok loglevels. */
enum {
SR_LOG_NONE = 0, /**< Output no messages at all. */

View File

@ -186,5 +186,7 @@ SR_API void sr_set_export_original_data(int flag);
SR_API int sr_get_export_original_flag();
SR_API void sr_set_firmware_resource_dir(const char *dir);
#endif

View File

@ -34,6 +34,8 @@
#define sr_warn(s, args...) sr_warn(LOG_PREFIX s, ## args)
#define sr_err(s, args...) sr_err(LOG_PREFIX s, ## args)
char DS_RES_PATH[256] = {0};
int bExportOriginalData = 0; //able export all data
int session_loop_stop_flag = 0;
@ -832,4 +834,17 @@ SR_API int sr_get_export_original_flag()
return bExportOriginalData;
}
void sr_set_firmware_resource_dir(const char *dir)
{
if (dir){
strcpy(DS_RES_PATH, dir);
int len = strlen(DS_RES_PATH);
if (DS_RES_PATH[len-1] != '/'){
DS_RES_PATH[len] = '/';
DS_RES_PATH[len+1] = 0;
}
}
}
/** @} */

View File

@ -33,8 +33,6 @@ INCLUDEPATH += /usr/include/libusb-1.0
INCLUDEPATH += /usr/include/boost
INCLUDEPATH += /usr/include/python3.8
INCLUDEPATH += ..
#INCLUDEPATH += ../libsigrok4DSL
#INCLUDEPATH += ../DSView
LIBS += /usr/lib/x86_64-linux-gnu/libglib-2.0.so
LIBS += /usr/lib/x86_64-linux-gnu/libusb-1.0.so
@ -55,8 +53,6 @@ INCLUDEPATH += /usr/local/include/libusb-1.0
INCLUDEPATH += /usr/local/include/boost
INCLUDEPATH += /Library/Frameworks/Python.framework/Versions/3.4/include/python3.4m
INCLUDEPATH += ..
#INCLUDEPATH += ../libsigrok4DSL
#INCLUDEPATH += ../DSView
#LIBS += -framework CoreFoundation
#LIBS += -framework CoreServices

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 4.11.0, 2021-11-24T15:20:06. -->
<!-- Written by QtCreator 4.11.0, 2021-11-24T19:16:06. -->
<qtcreator>
<data>
<variable>EnvironmentId</variable>