File tree Expand file tree Collapse file tree 3 files changed +17
-3
lines changed Expand file tree Collapse file tree 3 files changed +17
-3
lines changed Original file line number Diff line number Diff line change 1
1
#include < QDebug>
2
+ #include < QMessageBox>
2
3
#include < string>
3
4
#include < unistd.h>
4
5
#include " environment.h"
@@ -144,7 +145,15 @@ void MainDialog::activate()
144
145
145
146
void MainDialog::initConfig (std::string &config_file)
146
147
{
147
- xml_init (config_file.data ());
148
+ bool success = xml_init (config_file.data ());
149
+
150
+ if (!success) {
151
+ QMessageBox msgBox;
152
+ msgBox.setText (tr (" Error loading " ) + QString (config_file.data ()));
153
+ msgBox.setInformativeText (tr (" Run labwc-tweaks from a terminal to view error messages" ));
154
+ msgBox.exec ();
155
+ exit (EXIT_FAILURE);
156
+ }
148
157
149
158
/* Ensure all relevant nodes exist before we start getting/setting */
150
159
xpath_add_node (" /labwc_config/theme/cornerRadius" );
Original file line number Diff line number Diff line change @@ -142,11 +142,13 @@ create_basic_rcxml(const char *filename)
142
142
fclose (file );
143
143
}
144
144
145
- void
145
+ bool
146
146
xml_init (const char * filename )
147
147
{
148
148
LIBXML_TEST_VERSION
149
149
150
+ bool success = true;
151
+
150
152
if (access (filename , F_OK )) {
151
153
create_basic_rcxml (filename );
152
154
}
@@ -156,12 +158,15 @@ xml_init(const char *filename)
156
158
ctx .doc = xmlReadFile (filename , NULL , XML_PARSE_NOBLANKS );
157
159
if (!ctx .doc ) {
158
160
fprintf (stderr , "warn: xmlReadFile('%s')\n" , filename );
161
+ success = false;
159
162
}
160
163
ctx .xpath_ctx_ptr = xmlXPathNewContext (ctx .doc );
161
164
if (!ctx .xpath_ctx_ptr ) {
162
165
fprintf (stderr , "warn: xmlXPathNewContext()\n" );
163
166
xmlFreeDoc (ctx .doc );
167
+ success = false;
164
168
}
169
+ return success ;
165
170
}
166
171
167
172
void
Original file line number Diff line number Diff line change 2
2
#ifndef __XML_H
3
3
#define __XML_H
4
4
5
- void xml_init (const char * filename );
5
+ bool xml_init (const char * filename );
6
6
void xml_save (void );
7
7
void xml_save_as (const char * filename );
8
8
void xml_finish (void );
You can’t perform that action at this time.
0 commit comments